Expand description
SVG support shared by the inline <svg> painter and the standalone
rasterizer.
§Inline SVG
The layout builder calls collect_svg while building the node for an
<svg> element. The renderer then paints the collected shapes into the
element’s content box via emit_commands, mapping the viewBox
rectangle onto the box with viewbox_meet_transform (xMidYMid meet, the
SVG default).
§Standalone SVG documents
Audio icons and <img src="*.svg"> are rasterized to RGBA pixels by
rasterize_from_bytes, which replaces the removed resvg dependency.
Coverage stays focused on solid-color fills: <path d> (including arc
segments, expanded into cubic Béziers), <rect>, <circle>, <ellipse>,
container <g>/<a>/<symbol> with composed transform/opacity
attributes, fill-rule, and opacity/fill-opacity (approximated as a
per-shape alpha multiplier). <use>/<clipPath>/gradients, strokes, and
text are out of scope.
Structs§
- Clip
Path - A clipping path: a viewBox-space path plus its fill rule, used to mask
shapes that reference it via
clip-path="url(#id)". - Raster
Result - Decoded RGBA8 pixels plus the rasterized viewport dimensions.
- SvgContent
- The vector content of an
crate::engine::layouter::types::NodeKind::Svglayout node: the element’sviewBoxand its subpaths in document order. - SvgShape
- A single shape inside an inline SVG: a viewBox-space path, its paint
(solid color or gradient), and the fill rule (default nonzero).
strokeisNonewhen the shape has no stroke.clip_pathoptionally references a clip path that masks this shape. - SvgStroke
- A resolved SVG stroke: paint color plus the geometry parameters that
stroke_pathexpands the outline with. Whengradientis set it paints the outline instead ofcolor.
Functions§
- collect_
svg - Collects the inline SVG content of an
<svg>element: itsviewBoxand the solid-color shapes of its content, recursively. - emit_
commands - Paints the shapes of an inline SVG into its content box.
- parse_
view_ box - Parses an SVG
viewBoxattribute into(min-x, min-y, width, height), defaulting missing components to zero. - path_
from_ d - Translates an SVG path
dstring into aPath. - rasterize_
from_ bytes - Parses SVG bytes and rasterizes them to straight-alpha RGBA pixels.
- viewbox_
meet_ transform - Builds the transform mapping
viewBoxcoordinates into a viewport usingxMidYMid meet(the SVG default: fit the whole box inside the viewport, centered). Without a usableviewBox, coordinates map 1:1.
Type Aliases§
- ViewBox
- An
SVG viewBoxrectangle:(min-x, min-y, width, height).