_
Add floating encoded text or content at the current point in the tree.
_ "© 2026 Acme Studio"
The DSL has two related vocabularies. Lowercase calls such as rect, circle, and linearGradient are SVG element
names. The full sevgi gem recognizes standard elements and checks their attributes, content, and nesting before
writing the document.
Sevgi's own drawing words usually begin with a capital letter, which keeps operations such as Tile, Rotate, and
Include visually distinct from SVG. A few deliberate lowercase words, including css, layer, and base, appear
here too. Ordinary Ruby methods and exhaustive signatures belong in the API reference.
Use SVG element names directly and nest containers naturally:
SVG :minimal do
g id: "badge" do
circle cx: 12, cy: 12, r: 10
text "S", x: 12, y: 16, "text-anchor": "middle"
end
end.Out
Use Element for foreign XML, qualified names, or a name that collides with Ruby. See
SVG Essentials for the validation lifecycle and the
MDN SVG element reference for the standard
element vocabulary.
Some words appear in more than one group. Include, for example, belongs to both composition and round trip. Grid
belongs to layout and script tools.
Choose a document profile and control when Sevgi prepares or renders it.
Build an SVG tree, then move, group, or reuse its branches.
_
Adopt
AdoptFirst
Ancestral
Append
base
Call
CData
Classify
Comment
css
Defaults
Disidentify
Duplicate
DuplicateX
DuplicateY
Element
Evaluate
EvaluateChildren
EvaluateChildrenFile
EvaluateFile
Forward
Group
Include
IncludeChildren
layer
Layer
layer!
Layer!
Mixin
Orphan
Prepend
RenderChildren
Symbol
symbol!
Symbols
With
Within
Query the current element and move through its parents or children.
Draw common shape and line patterns without hand-writing path data.
Attach SVG transforms without assembling transform strings.
Arrange repeated work with alignment, tiling, grids, and pages.
Convert SVG/XML, load files, and reuse callable modules.
Validate SVG structure and inspect element identity before output.
Render, print, save, and export drawings.
Add Inkscape pages and metadata, including RDF licenses.
Work with the top-level commands available in `.sevgi` scripts.
_ · A · B · C · D · E · F · G · H · I · L · M · N · O · P · R · S · T · V · W
_Add floating encoded text or content at the current point in the tree.
_ "© 2026 Acme Studio"
AdoptMove an existing subtree under a new parent.
toolbar = g id: "toolbar"
export = text "Export", x: 8, y: 16
export.Adopt toolbar
AdoptFirstMove an existing subtree to the first position under a parent.
legend = g { text "Online", x: 12, y: 4 }
status = circle r: 4, fill: "seagreen"
status.AdoptFirst legend
AlignCenter an element by comparing an inner and outer box.
label = Sevgi::Geometry::Rect[32, 12]
card = Sevgi::Geometry::Rect[120, 48]
title = text "BOARDING", x: 0, y: 10
title.Align :center, inner: label, outer: card
See geometry alignment.
AncestralMerge non-rendering context along the direct root-to-element chain.
g "-context": {tone: "tomato"} do
rect width: 4, height: 2, fill: Ancestral()[:tone]
end
AppendMove existing elements to the end of a new parent's children.
button = g id: "checkout"
icon = circle cx: 8, cy: 8, r: 6, fill: "seagreen"
label = text "Pay now", x: 20, y: 12
button.Append icon, label
baseRegister shared drawing steps that run before a callable module's public methods.
Module contract: extend SVG::Module. Use extend SVG::Modules to apply
the same contract recursively to an owned module tree.
status = Module.new do
extend SVG::Module
base { circle r: 8, fill: "seagreen" }
def call = path d: "M -4 0 L -1 3 L 5 -4", fill: "none", stroke: "white"
end
SVG(:minimal) { Call status }.Render
CallRun a configured Ruby module as a drawing step on the current element.
Module contract: extend SVG::Module. Use extend SVG::Modules to apply
the same contract recursively to an owned module tree.
price = Module.new do
extend SVG::Module
def call(value) = text "$#{value}", x: 8, y: 16
end
SVG(:minimal) { Call price, 48 }.Render
See callable modules.
CanvasBuild a canvas from a paper profile or explicit dimensions and margins.
canvas = Canvas width: 80, height: 50, margins: 5
SVG(:minimal, canvas) { rect width: canvas.inner.width, height: canvas.inner.height }.Render
CDataRead the joined text content used by SVG validation.
node = text "hello"
node[:data_text] = node.CData
ClassifyAdd CSS class tokens without duplicating existing values.
row = g class: "invoice-row"
row.Classify :overdue, "needs-review"
CommentInsert a safely encoded XML comment.
Comment "Invoice totals calculated on 2026-07-14"
cssTurn a Ruby hash into a readable SVG style element.
css ".alert" => {fill: "tomato", stroke: "white", "stroke-width": 2}
circle class: "alert", cx: 10, cy: 10, r: 8
DocumentDefine, validate, or look up a document profile without replacing a conflicting definition.
Document :catalog_icon, attributes: {viewBox: "0 0 24 24"}
SVG(:catalog_icon) { circle cx: 12, cy: 12, r: 10 }.Render
Document!Explicitly replace a named document profile.
Document! :catalog_badge, attributes: {viewBox: "0 0 80 32"}
SVG(:catalog_badge) { rect width: 80, height: 32, rx: 4 }.Render
DecompileParse inline SVG/XML into an inspectable immutable Derender node.
node = Decompile '<rect id="mark" width="4" height="2"/>', id: "mark"
node.attributes
DecompileFileParse an SVG/XML file into an inspectable immutable Derender node.
DecompileFile "shape.svg", id: "mark"
DefaultsFill only attributes that the element does not already have.
avatar = circle fill: "gold"
avatar.Defaults r: 16, fill: "gray", stroke: "white"
DerenderConvert inline SVG/XML or a selected id into formatted Sevgi source.
Derender '<rect id="mark" width="4"/>', id: "mark"
See the Derender guide.
DerenderFileConvert an SVG/XML file or selected id into formatted Sevgi source.
DerenderFile "shape.svg", id: "mark"
See the Derender guide.
DisidentifyHide rendered ids as internal metadata while retaining their source identity.
g(id: "art") { circle id: "dot", r: 2 }
Disidentify()
DrawDraw one or more Geometry objects into the current SVG element.
Draw Sevgi::Geometry::Line.([4, 4], [76, 4]), class: %w[guide trim]
See drawing geometry.
DuplicateCopy an independent subtree and optionally translate or customize it.
source = circle id: "dot", r: 2
source.Duplicate dx: 8 do |node|
node[:id] = "dot-copy" if node[:"-id"]
end
DuplicateXCopy an element and translate the copy along the x axis.
dot = circle r: 2
dot.DuplicateX 8
DuplicateYCopy an element and translate the copy along the y axis.
dot = circle r: 2
dot.DuplicateY 8
ElementBuild an explicitly named XML element when a bare Ruby call is unsuitable.
Element "custom:mark", "hello", "custom:kind": "spark"
EvaluateImport an inline SVG/XML node directly under an existing SVG element.
drawing = SVG :minimal
Evaluate '<circle id="mark" r="2"/>', drawing, id: "mark"
EvaluateChildrenImport only the children of an inline SVG/XML node under an existing SVG element.
drawing = SVG :minimal
EvaluateChildren '<g id="marks"><circle r="2"/></g>', drawing, id: "marks"
EvaluateChildrenFileImport only a selected file node's children under an existing SVG element.
drawing = SVG :minimal
EvaluateChildrenFile "shape.svg", drawing, id: "group"
EvaluateFileImport a selected SVG/XML file node directly under an existing SVG element.
drawing = SVG :minimal
EvaluateFile "shape.svg", drawing, id: "mark"
FlipAppend a two-axis reflection to the element's SVG transform list.
line = path d: "M 0 0 L 8 3"
line.Flip
FlipXReflect an element horizontally with an SVG scale transform.
line = path d: "M 0 0 L 8 3"
line.FlipX
FlipYReflect an element vertically with an SVG scale transform.
line = path d: "M 0 0 L 8 3"
line.FlipY
ForwardPass the current element as the first argument to another receiver.
Forward proc { |node| node.Classify "forwarded" }, :call
GridFit a major/minor grid inside a Canvas while preserving its margins.
canvas = SVG.Canvas width: 80, height: 50, margins: 5
grid = Grid canvas, unit: 1, multiple: 10
SVG :inkscape, grid.canvas do
Draw grid.x.major.lines, class: %w[guide horizontal]
Draw grid.y.major.lines, class: %w[guide vertical]
end.Render
See fitted grids.
GroupRender a callable module inside a regular group with stable wrapper attributes.
Module contract: extend SVG::Module. Use extend SVG::Modules to apply
the same contract recursively to an owned module tree.
mark = Module.new do
extend SVG::Module
def call = path d: "M 0 8 L 5 13 L 16 0", fill: "none", stroke: "seagreen"
end
SVG(:inkscape) { Group mark, attributes: {id: "approval-mark"} }.Render
HatchSweep parallel Geometry lines through a closed shape and draw them.
no_print = Sevgi::Geometry::Rect[48, 18, position: [6, 6]]
Hatch no_print, angle: 30, step: 3, class: %w[guide no-print]
See sweeps and hatching.
HLineByDraw a relative horizontal path segment from a starting point.
HLineBy x: 2, y: 4, length: 12, stroke: "black"
HLineToDraw a horizontal path segment to an absolute x coordinate.
HLineTo x1: 2, y1: 4, x2: 14, stroke: "black"
IdentifiersSnapshot rendered ids and expose duplicate-id collisions.
circle id: "dot", r: 2
self[:data_ids] = Identifiers().namespace.keys.join(",")
IncludeImport one selected SVG/XML node, optionally omitting unwanted attributes.
Include "shape.svg", "mark", omit: :id
See direct evaluation.
IncludeChildrenImport only the children of a selected SVG/XML node.
IncludeChildren "shape.svg", "group"
See direct evaluation.
InkscapeTemplateInfoAdd Inkscape's reusable-template name, description, and author metadata.
InkscapeTemplateInfo name: "Badge", desc: "A tiny badge", author: "Sevgi"
Is?Ask whether the current element has a particular SVG/XML name.
dot = circle r: 2
dot[:data_circle] = dot.Is? :circle
layerBuild a generic group, or an Inkscape layer when using the Inkscape profile.
layer(id: "ink") { path d: "M 0 0 L 8 3" }
LayerRender a callable module inside an Inkscape layer.
Module contract: extend SVG::Module. Use extend SVG::Modules to apply
the same contract recursively to an owned module tree.
labels = Module.new do
extend SVG::Module
def call = text "DRAFT", x: 8, y: 16
end
SVG(:inkscape) { Layer labels, attributes: {id: "annotations"} }.Render
layer!Build an Inkscape layer marked insensitive to editor interaction.
layer!(id: "locked") { rect width: 8, height: 4 }
Layer!Render a callable module inside a locked Inkscape layer.
Module contract: extend SVG::Module. Use extend SVG::Modules to apply
the same contract recursively to an owned module tree.
guides = Module.new do
extend SVG::Module
def call = LineTo x1: 4, y1: 4, x2: 76, y2: 4, class: %w[guide trim]
end
SVG(:inkscape) { Layer! guides, attributes: {id: "print-guides"} }.Render
LicenseAdd RDF work metadata with an explicit license URL.
License title: "Badge", creator: "Sevgi", license: "https://example.test/license"
License_CC0Mark a work with Creative Commons Zero metadata.
License_CC0 title: "Public badge", creator: "Sevgi"
License_CC_BYAdd Creative Commons Attribution 4.0 metadata.
License_CC_BY title: "Badge", creator: "Sevgi"
License_CC_BY_NCAdd Creative Commons Attribution-NonCommercial 4.0 metadata.
License_CC_BY_NC title: "Badge", creator: "Sevgi"
License_CC_BY_NC_NDAdd Attribution-NonCommercial-NoDerivatives metadata.
License_CC_BY_NC_ND title: "Badge", creator: "Sevgi"
License_CC_BY_NC_SAAdd Attribution-NonCommercial-ShareAlike metadata.
License_CC_BY_NC_SA title: "Badge", creator: "Sevgi"
License_CC_BY_NDAdd Creative Commons Attribution-NoDerivatives metadata.
License_CC_BY_ND title: "Badge", creator: "Sevgi"
License_CC_BY_SAAdd Creative Commons Attribution-ShareAlike metadata.
License_CC_BY_SA title: "Badge", creator: "Sevgi"
License_LALAdd Free Art License metadata.
License_LAL title: "Badge", creator: "Sevgi"
LineByDraw a relative line from a screen-space angle and length.
LineBy x: 2, y: 2, angle: 30, length: 12, stroke: "black"
LineToDraw a line path between two absolute points.
LineTo x1: 2, y1: 2, x2: 14, y2: 8, stroke: "black"
LintReject structural problems such as duplicate rendered ids.
circle id: "one", r: 2
Lint()
LoadEvaluate another `.sevgi` file relative to the active script while preserving the load stack.
Load "part"
SVG(:minimal) { circle r: PART_RADIUS }.Render
See script loading.
MatrixAppend an explicit six-value SVG transformation matrix.
shape = rect width: 4, height: 2
shape.Matrix 1, 0.2, 0, 1, 6, 3
MixinAdd a named or anonymous DSL extension to a document profile.
profile = SVG.Document attributes: {}
Mixin(profile) { define_method(:Badge) { circle r: 4 } }
SVG(profile) { Badge() }.Render
NS?Ask whether a namespace is declared on the element or an ancestor.
rect width: 2, data_inkscape: NS?(:inkscape)
OrphanDetach an element and retain it as an independent subtree root.
spare = circle r: 2
spare.Orphan
g { spare.Adopt self }
OutRender a checked document to standard output.
SVG(:minimal) { circle r: 3 }.Out
PagesDeclare explicit Inkscape pages inside a namedview.
Pages({x: 0, y: 0, width: 100, height: 60, label: "front"})
PagesTabularGenerate a rectangular grid of Inkscape pages.
PagesTabular rows: 2, cols: 2, width: 100, height: 60, gap: 5
PaperRegister or verify an idempotent named paper profile.
Paper 90, 50, :catalog_card
SVG(:minimal, :catalog_card) { rect width: 90, height: 50 }.Render
Paper!Explicitly replace a custom named paper profile.
Paper! 90, 50, :catalog_card
SVG(:minimal, :catalog_card) { rect width: 90, height: 50 }.Render
PDFRender and export the document as a PDF through the optional native stack.
SVG(width: 20, height: 20) { circle cx: 10, cy: 10, r: 8 }.PDF "example.pdf"
See export setup.
PNGRender and export the document as a PNG through the optional native stack.
SVG(width: 20, height: 20) { circle cx: 10, cy: 10, r: 8 }.PNG "example.png"
See export setup.
PrependMove existing elements to the beginning of a new parent's children.
card = g { text "Boarding pass", x: 12, y: 24 }
background = rect width: 120, height: 40, rx: 4, fill: "ivory"
card.Prepend background
PreRenderRun selected validation and lint checks explicitly before rendering.
drawing = SVG(:minimal) { rect width: 4, height: 2 }
drawing.PreRender validate: true, lint: true
drawing.Render
RDFBuild an RDF metadata container inside an Inkscape document.
RDF { Element :"cc:Work", "rdf:about": "" }
RDFWorkDescribe a work with common Dublin Core and Creative Commons metadata.
RDFWork title: "Badge", creator: "Sevgi"
RenderSerialize a checked document, element, or subtree as SVG/XML.
SVG(:minimal) { circle r: 3 }.Render
RenderChildrenSerialize only an element's children, leaving out the element itself.
SVG(:minimal) { circle r: 2; rect width: 3, height: 2 }.RenderChildren
RootReturn the topmost element of the current tree, including a detached subtree.
dot = circle r: 2
dot[:data_root] = dot.Root.name
Root?Report whether the element is the document root.
dot = circle r: 2
self[:data_root] = Root?()
dot[:data_root] = dot.Root?()
RotateAppend an SVG rotation, optionally around an explicit center.
shape = rect width: 8, height: 3
shape.Rotate 25, 4, 1.5
RotateLeftRotate an element left by a quarter turn.
line = path d: "M 0 0 L 8 3"
line.RotateLeft
RotateRightRotate an element right by a quarter turn.
line = path d: "M 0 0 L 8 3"
line.RotateRight
SaveRender a checked document to an SVG file.
SVG(:minimal) { circle r: 3 }.Save "example.svg"
ScaleAppend a one- or two-axis SVG scale transform.
dot = circle r: 3
dot.Scale 1.5, 0.75
sevgiRun a `.sevgi` script as a Rake file task with arguments and dependency tracking.
sevgi "drawing", "front", theme: :dark
See Rake integration.
SkewAppend horizontal and vertical SVG skew transforms together.
shape = rect width: 8, height: 3
shape.Skew 12, -4
SkewXAppend a horizontal SVG skew transform.
shape = rect width: 8, height: 3
shape.SkewX 12
SkewYAppend a vertical SVG skew transform.
shape = rect width: 8, height: 3
shape.SkewY 12
squareDraw a square through the familiar SVG rect vocabulary.
square x: 2, y: 2, length: 8, rx: 1
StayStop a traversal immediately and return a selected value.
g(id: "target") { circle r: 2 }
found = Traverse { |node| Stay node if node.Is? :g }
self[:data_found] = found[:id]
SVGCreate an SVG document from a profile, canvas, and drawing block.
SVG(:minimal) { circle r: 4 }.Render
SymbolBuild a titled SVG symbol with an id derived from its human-readable name.
Symbol("status dot") { circle r: 2 }
symbol!Build an SVG symbol element directly, including in profiles without a wrapper.
symbol!(id: "hidden") { circle r: 2 }
SymbolsCollect symbols declared by a callable module into a defs element.
Module contract: extend SVG::Module. Use extend SVG::Modules to apply
the same contract recursively to an owned module tree.
icons = Module.new do
extend SVG::Module
def dot = circle r: 2
def tick = path d: "M 0 2 L 2 4 L 6 0"
end
Symbols icons
TileDefine one template and place references across a two-dimensional grid.
Tile("seat-map", nx: 4, ny: 3, dx: 8, dy: 8) { rect width: 5, height: 5, rx: 1 }
TileXDefine one template and place references at a fixed horizontal interval.
TileX("ticket-holes", n: 8, d: 6) { circle r: 1, fill: "white" }
TileYDefine one template and place references at a fixed vertical interval.
TileY("timeline", n: 5, d: 10) { circle r: 2, fill: "seagreen" }
TranslateAppend a two-axis SVG translation.
dot = circle r: 2
dot.Translate 8, 4
TranslateXAppend a horizontal SVG translation.
dot = circle r: 2
dot.TranslateX 8
TranslateYAppend a vertical SVG translation.
dot = circle r: 2
dot.TranslateY 8
TraverseWalk an element and its descendants in document order.
g { circle r: 2; rect width: 3, height: 2 }
Traverse { |node| node.Classify "visited" }
TraverseUpWalk from an element toward the root through its ancestors.
g do
dot = circle r: 2
dot.TraverseUp { |node| node[:data_seen] = true }
end
ValidateCheck SVG element, attribute, namespace, and content rules immediately.
circle r: 3, fill: "tomato"
Validate()
VLineByDraw a relative vertical path segment from a starting point.
VLineBy x: 4, y: 2, length: 12, stroke: "black"
VLineToDraw a vertical path segment to an absolute y coordinate.
VLineTo x1: 4, y1: 2, y2: 14, stroke: "black"
WithRun a block with a sanitized generated id and return the original element.
marker = circle r: 2
marker.With("status dot") { |id| marker[:id] = id }
WithinEvaluate a block in another element's DSL context while retaining the caller.
target = g id: "target"
dot = circle r: 2
dot.Within(receiver: target) { rect width: 4, height: 2 }
WriteWrite rendered SVG to a named destination without the Save convenience checks.
SVG(:minimal) { circle r: 3 }.Write "example.svg"