DSL Catalog

The DSL has two related vocabularies. Lowercase calls such as rect, circle, and linearGradient are SVG element names. The full sumi gem recognizes standard elements. It checks their attributes, content, and nesting before writing the document.

Sumi'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 Documents for the validation lifecycle and the MDN SVG element reference for the standard element vocabulary.

Internal element data

An attribute name that starts with - stores internal element data. Sumi keeps the value in memory, but does not write it to SVG. Use -context with Ancestral. Duplicate and Disidentify use -id to retain a source id without rendering it.

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 Sumi 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 .sumi scripts.

Alphabetical index

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

_

_

underscoredocumentcomposition

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

_ "© 2026 Acme Studio"

A

Adopt

coredocumentcomposition

Move an existing subtree under a new parent.

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

AdoptFirst

coredocumentcomposition

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

transformdocumentlayouttransforms

Center an element by comparing an inner and outer box.

label = Sumi::Geometry::Rect[32, 12]
card = Sumi::Geometry::Rect[120, 48]
title = text "BOARDING", x: 0, y: 10
title.Align :center, inner: label, outer: card

See geometry alignment.

Ancestral

underscoredocumentcontextcomposition

Read merged -context data from the current element and its ancestors. The leading - keeps this data in memory and out of SVG output. The nearest element wins when keys repeat.

g "-context": {radius: 10, tone: "tomato"} do
  g "-context": {tone: "gold"} do
    context = self.Ancestral # internal, not rendered
    circle r: context[:radius], fill: context[:tone]
  end
end

Append

coredocumentcomposition

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

ArcBy

wrappersdocumentdrawing

Draw an SVG elliptical arc to a relative endpoint.

ArcBy x: 4, y: 12, dx: 20, dy: 0, rx: 10, ry: 6, sweep: true, fill: "none", stroke: "black"

See calculated arcs and ellipses.

ArcTo

wrappersdocumentdrawing

Draw an SVG elliptical arc between absolute endpoints.

ArcTo x1: 4, y1: 12, x2: 24, y2: 12, rx: 10, ry: 6, sweep: true, fill: "none", stroke: "black"

See calculated arcs and ellipses.

B

base

graphics::modulescriptcompositionround trip

Register shared drawing steps that run before a callable module's public methods.

Build an anonymous callable with SVG.Module { ... }. For an existing or explicitly declared module, use extend SVG::Module. Use extend SVG::Modules for an owned module tree.

Public instance methods are drawing steps; private and protected methods are helpers. Each invocation uses a fresh callable receiver rather than the document object.

status = SVG.Module do
  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 do
  Call status
end.Render

C

Call

Run a configured Ruby module as a drawing step on the current element.

Build an anonymous callable with SVG.Module { ... }. For an existing or explicitly declared module, use extend SVG::Module. Use extend SVG::Modules for an owned module tree.

Public instance methods are drawing steps; private and protected methods are helpers. Each invocation uses a fresh callable receiver rather than the document object.

price = SVG.Module do
  def call(value) = text "$#{value}", x: 8, y: 16
end
SVG :minimal do
  Call price, 48
end.Render

See callable modules.

Canvas

Build a canvas from a paper profile or explicit dimensions and margins.

canvas = Canvas width: 80, height: 50, margins: 5
SVG :minimal, canvas do
  rect width: canvas.inner.width, height: canvas.inner.height
end.Render

CData

validatedocumentqualitycomposition

Join the element's direct text values for SVG validation.

label = text "Total", "$48"
label.CData # => "Total\n$48"

Classes

coredocumentcomposition

Read distinct CSS class names without changing the element.

row = g class: [:invoice, "overdue invoice"]
text row.Classes.join(" "), y: 12

Classify

coredocumentcomposition

Add CSS class tokens without duplicating existing values.

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

Comment

underscoredocumentcompositionquality

Insert a safely encoded XML comment.

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

css

wrappersdocumentcompositiondrawing

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

toplevelscriptdocumentsscript 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 do
  circle cx: 12, cy: 12, r: 10
end.Render

Document!

toplevelscriptdocumentsscript tools

Explicitly replace a named document profile.

Document! :catalog_badge, attributes: {viewBox: "0 0 80 32"}
SVG :catalog_badge do
  rect width: 80, height: 32, rx: 4
end.Render

Defaults

coredocumentcomposition

Fill only attributes that the element does not already have.

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

Disidentify

identifydocumentqualitycomposition

Move rendered id values to -id data while retaining their source identity. The leading - keeps the values in memory and out of SVG output.

art = g id: "art" do
  circle id: "dot", r: 2
end
art.Disidentify
art[:"-id"] # => "art"

Draw

hatchinkscapedrawing

Draw one or more Geometry objects into the current SVG element.

Draw Sumi::Geometry::Line.([4, 4], [76, 4]), class: %w[guide trim]

See drawing geometry.

Duplicate

duplicatedocumentcompositionlayout

Copy an independent subtree and optionally translate or customize it. Copied id values move to -id; the leading - keeps them in memory and out of SVG output.

source = circle id: "dot", r: 2
source.Duplicate dx: 8 do |node|
  node[:id] = "dot-copy" if node[:"-id"]
end

DuplicateX

duplicatedocumentcompositionlayout

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

dot = circle r: 2
dot.DuplicateX 8

DuplicateY

duplicatedocumentcompositionlayout

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

dot = circle r: 2
dot.DuplicateY 8

E

Element

coredocumentcompositionround trip

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

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

Evaluate

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

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

transformdocumenttransforms

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

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

FlipX

transformdocumenttransforms

Reflect an element horizontally with an SVG scale transform.

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

FlipY

transformdocumenttransforms

Reflect an element vertically with an SVG scale transform.

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

Forward

coredocumentcontextcomposition

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

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

G

Grid

toplevelscriptlayoutscript 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

inkscapescriptcompositioneditors

Render a callable module inside a regular group with stable wrapper attributes.

Build an anonymous callable with SVG.Module { ... }. For an existing or explicitly declared module, use extend SVG::Module. Use extend SVG::Modules for an owned module tree.

Public instance methods are drawing steps; private and protected methods are helpers. Each invocation uses a fresh callable receiver rather than the document object.

mark = SVG.Module do
  def call = path d: "M 0 8 L 5 13 L 16 0", fill: "none", stroke: "seagreen"
end
SVG :inkscape do
  Group mark, attributes: {id: "approval-mark"}
end.Render

H

Hatch

hatchinkscapedrawinglayout

Sweep parallel Geometry lines through a closed shape and draw them.

no_print = Sumi::Geometry::Rect[48, 18, position: [6, 6]]
Hatch no_print, angle: 30, step: 3, class: %w[guide no-print]

See sweeps and hatching.

HLineBy

wrappersdocumentdrawing

Draw a relative horizontal path segment from a starting point.

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

HLineTo

wrappersdocumentdrawing

Draw a horizontal path segment to an absolute x coordinate.

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

I

Identifiers

identifydocumentqualitycontext

Snapshot rendered ids and expose duplicate-id collisions.

art = g do
  circle id: "dot", r: 2
end
art.Identifiers["dot"].Classify "indexed"

Imprint

imprintdocumentoutput

Declare PDF page metadata and editable paint controls without changing the SVG.

g id: "outline" do
  rect width: 10, height: 10, fill: "none", stroke: "black"
end
Imprint do
  Page name: "Practice", tags: ["guide"]
  Target "ink", selectors: ["#outline"]
  Param "display", targets: ["ink"], property: "display",
    schema: {type: "string", enum: %w[inline none]}
  Param "opacity", targets: ["ink"], property: "stroke-opacity",
    schema: {type: "number", minimum: 0, maximum: 1}
end

See editable PDF export.

InkscapeTemplateInfo

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

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

Is?

coredocumentcontextquality

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

dot = circle r: 2
dot.Is? :circle # => true

L

layer

inkscapedocumentcompositioneditors

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

layer id: "ink" do
  path d: "M 0 0 L 8 3"
end

Layer

inkscapescriptcompositioneditors

Render a callable module inside an Inkscape layer.

Build an anonymous callable with SVG.Module { ... }. For an existing or explicitly declared module, use extend SVG::Module. Use extend SVG::Modules for an owned module tree.

Public instance methods are drawing steps; private and protected methods are helpers. Each invocation uses a fresh callable receiver rather than the document object.

labels = SVG.Module do
  def call = text "DRAFT", x: 8, y: 16
end
SVG :inkscape do
  Layer labels, attributes: {id: "annotations"}
end.Render

layer!

inkscapedocumentcompositioneditors

Build a generic group, or an Inkscape layer marked insensitive to editor interaction.

layer! id: "locked" do
  rect width: 8, height: 4
end

Layer!

inkscapescriptcompositioneditors

Render a callable module inside a locked Inkscape layer.

Build an anonymous callable with SVG.Module { ... }. For an existing or explicitly declared module, use extend SVG::Module. Use extend SVG::Modules for an owned module tree.

Public instance methods are drawing steps; private and protected methods are helpers. Each invocation uses a fresh callable receiver rather than the document object.

guides = SVG.Module do
  def call = LineTo x1: 4, y1: 4, x2: 76, y2: 4, class: %w[guide trim]
end
SVG :inkscape do
  Layer! guides, attributes: {id: "print-guides"}
end.Render

License

RDFinkscapeeditors

Add RDF work metadata with an explicit license URL.

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

License_CC0

RDFinkscapeeditors

Mark a work with Creative Commons Zero metadata.

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

License_CC_BY

RDFinkscapeeditors

Add Creative Commons Attribution 4.0 metadata.

License_CC_BY title: "Badge", creator: "Sumi"

License_CC_BY_NC

RDFinkscapeeditors

Add Creative Commons Attribution-NonCommercial 4.0 metadata.

License_CC_BY_NC title: "Badge", creator: "Sumi"

License_CC_BY_NC_ND

RDFinkscapeeditors

Add Attribution-NonCommercial-NoDerivatives metadata.

License_CC_BY_NC_ND title: "Badge", creator: "Sumi"

License_CC_BY_NC_SA

RDFinkscapeeditors

Add Attribution-NonCommercial-ShareAlike metadata.

License_CC_BY_NC_SA title: "Badge", creator: "Sumi"

License_CC_BY_ND

RDFinkscapeeditors

Add Creative Commons Attribution-NoDerivatives metadata.

License_CC_BY_ND title: "Badge", creator: "Sumi"

License_CC_BY_SA

RDFinkscapeeditors

Add Creative Commons Attribution-ShareAlike metadata.

License_CC_BY_SA title: "Badge", creator: "Sumi"

License_LAL

RDFinkscapeeditors

Add Free Art License metadata.

License_LAL title: "Badge", creator: "Sumi"

LineBy

wrappersdocumentdrawing

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

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

LineTo

wrappersdocumentdrawing

Draw a line path between two absolute points.

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

Lint

lintdocumentquality

Reject structural problems such as duplicate rendered ids.

badge = g do
  circle id: "outline", r: 2
end
badge.Lint

Load

toplevelscriptround tripscript tools

Evaluate another .sumi file relative to the active script while preserving the load stack.

Load "part"
SVG :minimal do
  circle r: PART_RADIUS
end.Render

See script loading.

M

Matrix

transformdocumenttransforms

Append an explicit six-value SVG transformation matrix.

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

Mixin

Add a named or anonymous DSL extension to a document profile.

profile = SVG.Document attributes: {}
Mixin profile do
  define_method(:Badge) { circle r: 4 }
end
SVG profile do
  Badge()
end.Render

Module

facadescriptcompositionround trip

Build an anonymous callable with public drawing steps and private or protected helpers.

Build an anonymous callable with SVG.Module { ... }. For an existing or explicitly declared module, use extend SVG::Module. Use extend SVG::Modules for an owned module tree.

Public instance methods are drawing steps; private and protected methods are helpers. Each invocation uses a fresh callable receiver rather than the document object.

label = SVG.Module do
  def call(value) = draw value

  private

  def draw(value) = text value
end
SVG :minimal do
  Call label, "Ready"
end.Render

See callable modules.

N

NS?

validateinkscapequalitycontexteditors

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

self.NS? :inkscape # => true

O

Orphan

coredocumentcomposition

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

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

Out

savescriptoutputscript tools

Render a checked document to standard output.

SVG :minimal do
  circle r: 3
end.Out

P

Pages

Declare explicit Inkscape pages inside a namedview.

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

Paper

toplevelscriptdocumentsscript tools

Register or verify an idempotent named paper profile.

Paper 90, 50, :catalog_card
SVG :minimal, :catalog_card do
  rect width: 90, height: 50
end.Render

Paper!

toplevelscriptdocumentsscript tools

Explicitly replace a custom named paper profile.

Paper! 90, 50, :catalog_card
SVG :minimal, :catalog_card do
  rect width: 90, height: 50
end.Render

PDF

exportscriptoutput

Render and export the document as a PDF through the optional native stack.

SVG width: 20, height: 20 do
  circle cx: 10, cy: 10, r: 8
end.PDF "example.pdf"

See export setup.

PNG

exportscriptoutput

Render and export the document as a PNG through the optional native stack.

SVG width: 20, height: 20 do
  circle cx: 10, cy: 10, r: 8
end.PNG "example.png"

See export setup.

Prepend

coredocumentcomposition

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::basescriptdocumentsqualityoutput

Run selected validation and lint checks explicitly before rendering.

drawing = SVG :minimal do
  rect width: 4, height: 2
end
drawing.PreRender validate: true, lint: true
drawing.Render

R

RDF

RDFinkscapeeditors

Build an RDF metadata container inside an Inkscape document.

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

RDFWork

RDFinkscapeeditors

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

RDFWork title: "Badge", creator: "Sumi"

Render

renderscriptoutputquality

Serialize a document, element, or subtree as SVG/XML without running the document checks.

drawing = SVG :minimal do
  circle r: 3
end
drawing.Render

RenderChildren

renderscriptoutputcomposition

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

drawing = SVG :minimal do
  circle r: 2
  rect width: 3, height: 2
end
drawing.RenderChildren

Root

coredocumentcontext

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

dot = circle r: 2
dot.Root.equal? self # => true

Root?

coredocumentcontext

Report whether the element is the document root.

dot = circle r: 2
self.Root? # => true
dot.Root?  # => false

Rotate

transformdocumenttransforms

Append an SVG rotation, optionally around an explicit center.

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

RotateLeft

transformdocumenttransforms

Rotate an element left by a quarter turn.

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

RotateRight

transformdocumenttransforms

Rotate an element right by a quarter turn.

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

Ruler

toplevelscriptlayoutscript tools

Fit major and minor intervals into a span without drawing SVG elements.

ruler = Ruler brut: 180, unit: 1, multiple: 10
SVG do
  ruler.ds.each { |x| line x1: x, y1: 0, x2: x, y2: 6 }
end.Render

See Rulers.

S

Save

savescriptoutput

Render a checked document to an SVG file.

SVG :minimal do
  circle r: 3
end.Save "example.svg"

Scale

transformdocumenttransforms

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

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

Skew

transformdocumenttransforms

Append horizontal and vertical SVG skew transforms together.

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

SkewX

transformdocumenttransforms

Append a horizontal SVG skew transform.

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

SkewY

transformdocumenttransforms

Append a vertical SVG skew transform.

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

square

wrappersdocumentdrawing

Draw a square through the familiar SVG rect vocabulary.

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

Stay

coredocumentcontext

Stop a traversal immediately and return a selected value.

g id: "target" do
  circle r: 2
end
found = Traverse { |node| Stay node if node[:id] == "target" }
found.Classify "selected"

Symbol

symbolsdocumentcomposition

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

Symbol "status dot" do
  circle r: 2
end

symbol!

inkscapedocumentcompositioneditors

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

symbol! id: "hidden" do
  circle r: 2
end

Symbols

symbolsinkscapecompositionround trip

Collect symbols declared by a callable module into a defs element.

Build an anonymous callable with SVG.Module { ... }. For an existing or explicitly declared module, use extend SVG::Module. Use extend SVG::Modules for an owned module tree.

Public instance methods are drawing steps; private and protected methods are helpers. Each invocation uses a fresh callable receiver rather than the document object.

icons = SVG.Module do
  def dot = circle r: 2
  def tick = path d: "M 0 2 L 2 4 L 6 0"
end
Symbols icons

T

Tile

tiledocumentlayout

Define one template and place references across a two-dimensional grid.

Tile "seat-map", nx: 4, ny: 3, dx: 8, dy: 8 do
  rect width: 5, height: 5, rx: 1
end

TileX

tiledocumentlayout

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

TileX "ticket-holes", n: 8, d: 6 do
  circle r: 1, fill: "white"
end

TileY

tiledocumentlayout

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

TileY "timeline", n: 5, d: 10 do
  circle r: 2, fill: "seagreen"
end

Translate

transformdocumenttransforms

Append a two-axis SVG translation.

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

TranslateX

transformdocumenttransforms

Append a horizontal SVG translation.

dot = circle r: 2
dot.TranslateX 8

TranslateY

transformdocumenttransforms

Append a vertical SVG translation.

dot = circle r: 2
dot.TranslateY 8

Traverse

coredocumentcontextquality

Walk an element and its descendants in document order.

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

TraverseUp

coredocumentcontext

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

validatedocumentquality

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

badge = circle r: 3, fill: "tomato"
badge.Validate

VLineBy

wrappersdocumentdrawing

Draw a relative vertical path segment from a starting point.

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

VLineTo

wrappersdocumentdrawing

Draw a vertical path segment to an absolute y coordinate.

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

W

With

coredocumentcompositioncontext

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

marker = circle r: 2
marker.With "status dot" do |id|
  marker[:id] = id
end

Within

coredocumentcompositioncontext

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 do
  rect width: 4, height: 2
end

Write

savescriptoutput

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

SVG :minimal do
  circle r: 3
end.Write "example.svg"