Expand description
SVG export backend.
SvgRenderer implements the Renderer trait, so the exact same render
path that draws the diagram on screen can be pointed at it to produce a
standalone .svg. Geometry has a single source of truth; this module only
translates the primitive calls into SVG nodes (built with the svg crate).
Like the on-screen painter it holds a Palette and resolves each
Swatch to a color at draw time — the canvas never sees an app-level role.
Text layout comes from the host’s TextLayout — the very engine that lays
the diagram out on screen — so the rows a run breaks into, and where each
row stands, are the screen’s. Each row is written as a <text> in the
face’s own family, with the face embedded, so the export’s text is text: a
viewer can select it, a PDF made from it carries it, a search finds it. The
viewer shapes within a row; the row is ours.
Coordinates are world space and written out directly (no zoom/pan); the
final <svg viewBox> frames whatever was drawn.
Structs§
- Ink 🔒
- A palette stroke resolved to what the SVG states: a width and a color.
- SvgRenderer
Functions§
- apply_
fill 🔒 - apply_
stroke 🔒 - Set
stroke/stroke-width(+opacity); no-op when there’s no visible stroke. - color_
hex 🔒 - fill 🔒
fill/fill-opacity, orfill="none"when fully transparent.- font_
face 🔒 - The
@font-facerule that embedsbytesunderfamily, so a viewer without the face installed sets the text in it. - framed 🔒
- The world rect an export frames: everything
drawn, and a cell’s margin around it — or a unit square for a level that drew nothing. - point_
list 🔒 - Build the
pointsattribute value for a polyline/polygon.Vec<(f32, f32)>serializes to"x y x y …", which SVG accepts. - text_
element 🔒 - One row as a
<text>at its pen, turned about it byangle. Written by hand because thesvgcrate breaks an element’s content onto lines of its own, whichxml:space="preserve"would set as spaces.