DSL Catalog

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.

SVG elements

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.

Browse by task

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.

Documents

Choose a document profile and control when Sevgi prepares or renders it.

Composition

Build an SVG tree, then move, group, or reuse its branches.

Context & traversal

Query the current element and move through its parents or children.

Drawing helpers

Draw common shape and line patterns without hand-writing path data.

Transforms

Attach SVG transforms without assembling transform strings.

Layout & repetition

Arrange repeated work with alignment, tiling, grids, and pages.

Round trip & reuse

Convert SVG/XML, load files, and reuse callable modules.

Quality & inspection

Validate SVG structure and inspect element identity before output.

Output

Render, print, save, and export drawings.

Editors & metadata

Add Inkscape pages and metadata, including RDF licenses.

Script tools

Work with the top-level commands available in `.sevgi` scripts.

Alphabetical index

_ · A · B · C · D · E · F · G · H · I · L · M · N · O · P · R · S · T · V · W

_

_

Underscore document composition

Add floating encoded text or content at the current point in the tree.

_ "© 2026 Acme Studio"

A

Adopt

Core document composition

Move an existing subtree under a new parent.

toolbar = g id: "toolbar"
export = text "Export", x: 8, y: 16
export.Adopt toolbar

AdoptFirst

Core document composition

Move 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

Align

Transform document layouttransforms

Center 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.

Ancestral

Underscore document contextcomposition

Merge non-rendering context along the direct root-to-element chain.

g "-context": {tone: "tomato"} do
  rect width: 4, height: 2, fill: Ancestral()[:tone]
end

Append

Core document composition

Move 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

B

base

Graphics::Module script compositionround trip

Register 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

C

Call

Call script compositionround trip

Run 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.

Canvas

Toplevel script documentslayoutscript tools

Build 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

CData

Validate document qualitycomposition

Read the joined text content used by SVG validation.

node = text "hello"
node[:data_text] = node.CData

Classify

Core document composition

Add CSS class tokens without duplicating existing values.

row = g class: "invoice-row"
row.Classify :overdue, "needs-review"

Comment

Underscore document compositionquality

Insert a safely encoded XML comment.

Comment "Invoice totals calculated on 2026-07-14"

css

Wrappers document compositiondrawing

Turn 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

D

Document

Toplevel script documentsscript tools

Define, 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!

Toplevel script documentsscript tools

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

Defaults

Core document composition

Fill only attributes that the element does not already have.

avatar = circle fill: "gold"
avatar.Defaults r: 16, fill: "gray", stroke: "white"

Disidentify

Identify document qualitycomposition

Hide rendered ids as internal metadata while retaining their source identity.

g(id: "art") { circle id: "dot", r: 2 }
Disidentify()

Draw

Hatch inkscape drawing

Draw 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.

Duplicate

Duplicate document compositionlayout

Copy 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

DuplicateX

Duplicate document compositionlayout

Copy an element and translate the copy along the x axis.

dot = circle r: 2
dot.DuplicateX 8

DuplicateY

Duplicate document compositionlayout

Copy an element and translate the copy along the y axis.

dot = circle r: 2
dot.DuplicateY 8

E

Element

Core document compositionround trip

Build an explicitly named XML element when a bare Ruby call is unsuitable.

Element "custom:mark", "hello", "custom:kind": "spark"

Evaluate

Toplevel script round tripscript toolscomposition

Import an inline SVG/XML node directly under an existing SVG element.

drawing = SVG :minimal
Evaluate '<circle id="mark" r="2"/>', drawing, id: "mark"

EvaluateChildren

Toplevel script round tripscript toolscomposition

Import 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"

F

Flip

Transform document transforms

Append a two-axis reflection to the element's SVG transform list.

line = path d: "M 0 0 L 8 3"
line.Flip

FlipX

Transform document transforms

Reflect an element horizontally with an SVG scale transform.

line = path d: "M 0 0 L 8 3"
line.FlipX

FlipY

Transform document transforms

Reflect an element vertically with an SVG scale transform.

line = path d: "M 0 0 L 8 3"
line.FlipY

Forward

Core document contextcomposition

Pass the current element as the first argument to another receiver.

Forward proc { |node| node.Classify "forwarded" }, :call

G

Grid

Toplevel script layoutscript tools

Fit 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.

Group

Inkscape script compositioneditors

Render 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

H

Hatch

Hatch inkscape drawinglayout

Sweep 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.

HLineBy

Wrappers document drawing

Draw a relative horizontal path segment from a starting point.

HLineBy x: 2, y: 4, length: 12, stroke: "black"

HLineTo

Wrappers document drawing

Draw a horizontal path segment to an absolute x coordinate.

HLineTo x1: 2, y1: 4, x2: 14, stroke: "black"

I

Identifiers

Identify document qualitycontext

Snapshot rendered ids and expose duplicate-id collisions.

circle id: "dot", r: 2
self[:data_ids] = Identifiers().namespace.keys.join(",")

InkscapeTemplateInfo

Inkscape inkscape editorsdocuments

Add Inkscape's reusable-template name, description, and author metadata.

InkscapeTemplateInfo name: "Badge", desc: "A tiny badge", author: "Sevgi"

Is?

Core document contextquality

Ask whether the current element has a particular SVG/XML name.

dot = circle r: 2
dot[:data_circle] = dot.Is? :circle

L

layer

Polyfills / Inkscape document compositioneditors

Build a generic group, or an Inkscape layer when using the Inkscape profile.

layer(id: "ink") { path d: "M 0 0 L 8 3" }

Layer

Inkscape script compositioneditors

Render 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!

Inkscape inkscape compositioneditors

Build an Inkscape layer marked insensitive to editor interaction.

layer!(id: "locked") { rect width: 8, height: 4 }

Layer!

Inkscape script compositioneditors

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

License

RDF inkscape editors

Add RDF work metadata with an explicit license URL.

License title: "Badge", creator: "Sevgi", license: "https://example.test/license"

License_CC0

RDF inkscape editors

Mark a work with Creative Commons Zero metadata.

License_CC0 title: "Public badge", creator: "Sevgi"

License_CC_BY

RDF inkscape editors

Add Creative Commons Attribution 4.0 metadata.

License_CC_BY title: "Badge", creator: "Sevgi"

License_CC_BY_NC

RDF inkscape editors

Add Creative Commons Attribution-NonCommercial 4.0 metadata.

License_CC_BY_NC title: "Badge", creator: "Sevgi"

License_CC_BY_NC_ND

RDF inkscape editors

Add Attribution-NonCommercial-NoDerivatives metadata.

License_CC_BY_NC_ND title: "Badge", creator: "Sevgi"

License_CC_BY_NC_SA

RDF inkscape editors

Add Attribution-NonCommercial-ShareAlike metadata.

License_CC_BY_NC_SA title: "Badge", creator: "Sevgi"

License_CC_BY_ND

RDF inkscape editors

Add Creative Commons Attribution-NoDerivatives metadata.

License_CC_BY_ND title: "Badge", creator: "Sevgi"

License_CC_BY_SA

RDF inkscape editors

Add Creative Commons Attribution-ShareAlike metadata.

License_CC_BY_SA title: "Badge", creator: "Sevgi"

License_LAL

RDF inkscape editors

Add Free Art License metadata.

License_LAL title: "Badge", creator: "Sevgi"

LineBy

Wrappers document drawing

Draw a relative line from a screen-space angle and length.

LineBy x: 2, y: 2, angle: 30, length: 12, stroke: "black"

LineTo

Wrappers document drawing

Draw a line path between two absolute points.

LineTo x1: 2, y1: 2, x2: 14, y2: 8, stroke: "black"

Lint

Lint document quality

Reject structural problems such as duplicate rendered ids.

circle id: "one", r: 2
Lint()

Load

Toplevel script round tripscript tools

Evaluate 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.

M

Matrix

Transform document transforms

Append an explicit six-value SVG transformation matrix.

shape = rect width: 4, height: 2
shape.Matrix 1, 0.2, 0, 1, 6, 3

Mixin

Toplevel script documentsscript toolscomposition

Add 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

N

NS?

Validate inkscape qualitycontexteditors

Ask whether a namespace is declared on the element or an ancestor.

rect width: 2, data_inkscape: NS?(:inkscape)

O

Orphan

Core document composition

Detach an element and retain it as an independent subtree root.

spare = circle r: 2
spare.Orphan
g { spare.Adopt self }

Out

Save script outputscript tools

Render a checked document to standard output.

SVG(:minimal) { circle r: 3 }.Out

P

Pages

Inkscape inkscape layouteditorsdocuments

Declare explicit Inkscape pages inside a namedview.

Pages({x: 0, y: 0, width: 100, height: 60, label: "front"})

Paper

Toplevel script documentsscript tools

Register or verify an idempotent named paper profile.

Paper 90, 50, :catalog_card
SVG(:minimal, :catalog_card) { rect width: 90, height: 50 }.Render

Paper!

Toplevel script documentsscript tools

Explicitly replace a custom named paper profile.

Paper! 90, 50, :catalog_card
SVG(:minimal, :catalog_card) { rect width: 90, height: 50 }.Render

PDF

Export script output

Render 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.

PNG

Export script output

Render 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.

Prepend

Core document composition

Move 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

PreRender

Document::Base script documentsqualityoutput

Run selected validation and lint checks explicitly before rendering.

drawing = SVG(:minimal) { rect width: 4, height: 2 }
drawing.PreRender validate: true, lint: true
drawing.Render

R

RDF

RDF inkscape editors

Build an RDF metadata container inside an Inkscape document.

RDF { Element :"cc:Work", "rdf:about": "" }

RDFWork

RDF inkscape editors

Describe a work with common Dublin Core and Creative Commons metadata.

RDFWork title: "Badge", creator: "Sevgi"

Render

Render script outputquality

Serialize a checked document, element, or subtree as SVG/XML.

SVG(:minimal) { circle r: 3 }.Render

RenderChildren

Render script outputcomposition

Serialize only an element's children, leaving out the element itself.

SVG(:minimal) { circle r: 2; rect width: 3, height: 2 }.RenderChildren

Root

Core document context

Return the topmost element of the current tree, including a detached subtree.

dot = circle r: 2
dot[:data_root] = dot.Root.name

Root?

Core document context

Report whether the element is the document root.

dot = circle r: 2
self[:data_root] = Root?()
dot[:data_root] = dot.Root?()

Rotate

Transform document transforms

Append an SVG rotation, optionally around an explicit center.

shape = rect width: 8, height: 3
shape.Rotate 25, 4, 1.5

RotateLeft

Transform document transforms

Rotate an element left by a quarter turn.

line = path d: "M 0 0 L 8 3"
line.RotateLeft

RotateRight

Transform document transforms

Rotate an element right by a quarter turn.

line = path d: "M 0 0 L 8 3"
line.RotateRight

S

Save

Save script output

Render a checked document to an SVG file.

SVG(:minimal) { circle r: 3 }.Save "example.svg"

Scale

Transform document transforms

Append a one- or two-axis SVG scale transform.

dot = circle r: 3
dot.Scale 1.5, 0.75

Skew

Transform document transforms

Append horizontal and vertical SVG skew transforms together.

shape = rect width: 8, height: 3
shape.Skew 12, -4

SkewX

Transform document transforms

Append a horizontal SVG skew transform.

shape = rect width: 8, height: 3
shape.SkewX 12

SkewY

Transform document transforms

Append a vertical SVG skew transform.

shape = rect width: 8, height: 3
shape.SkewY 12

square

Wrappers document drawing

Draw a square through the familiar SVG rect vocabulary.

square x: 2, y: 2, length: 8, rx: 1

Stay

Core document context

Stop 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]

Symbol

Symbols document composition

Build a titled SVG symbol with an id derived from its human-readable name.

Symbol("status dot") { circle r: 2 }

symbol!

Polyfills / Inkscape document compositioneditors

Build an SVG symbol element directly, including in profiles without a wrapper.

symbol!(id: "hidden") { circle r: 2 }

Symbols

Symbols inkscape compositionround trip

Collect 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

T

Tile

Tile document layout

Define 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 }

TileX

Tile document layout

Define one template and place references at a fixed horizontal interval.

TileX("ticket-holes", n: 8, d: 6) { circle r: 1, fill: "white" }

TileY

Tile document layout

Define one template and place references at a fixed vertical interval.

TileY("timeline", n: 5, d: 10) { circle r: 2, fill: "seagreen" }

Translate

Transform document transforms

Append a two-axis SVG translation.

dot = circle r: 2
dot.Translate 8, 4

TranslateX

Transform document transforms

Append a horizontal SVG translation.

dot = circle r: 2
dot.TranslateX 8

TranslateY

Transform document transforms

Append a vertical SVG translation.

dot = circle r: 2
dot.TranslateY 8

Traverse

Core document contextquality

Walk an element and its descendants in document order.

g { circle r: 2; rect width: 3, height: 2 }
Traverse { |node| node.Classify "visited" }

TraverseUp

Core document context

Walk from an element toward the root through its ancestors.

g do
  dot = circle r: 2
  dot.TraverseUp { |node| node[:data_seen] = true }
end

V

Validate

Validate document quality

Check SVG element, attribute, namespace, and content rules immediately.

circle r: 3, fill: "tomato"
Validate()

VLineBy

Wrappers document drawing

Draw a relative vertical path segment from a starting point.

VLineBy x: 4, y: 2, length: 12, stroke: "black"

VLineTo

Wrappers document drawing

Draw a vertical path segment to an absolute y coordinate.

VLineTo x1: 4, y1: 2, y2: 14, stroke: "black"

W

With

Core document compositioncontext

Run a block with a sanitized generated id and return the original element.

marker = circle r: 2
marker.With("status dot") { |id| marker[:id] = id }

Within

Core document compositioncontext

Evaluate 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 }

Write

Save script output

Write rendered SVG to a named destination without the Save convenience checks.

SVG(:minimal) { circle r: 3 }.Write "example.svg"