easy-svg
Typed Rust SVG builders generated at compile time from the offline MDN reference
in SVG/. Elements, attributes, permitted children, value helpers, and hover
documentation update when the reference is replaced.
use ;
use Color;
let svg = new
.view_box
.add_child;
assert_eq!;
Colors are typed: pass a named constant (Color::GOLD, Color::DARK_ORANGE,
Color::CURRENT_COLOR), build one with Color::rgb(...) / Color::rgba(...) /
Color::hex(...), or use Paint::NONE / Paint::url(...). A misspelled color
such as "fakecolor" is a compile error rather than an invalid SVG.
Lengths are typed too: pick the unit by constructor (Length::pixels(600),
Length::percent(50), Length::em(1.5), Length::unitless(10)) instead of
hand-writing a unit suffix. A bare "600px" no longer compiles; use
Length::raw(...) for genuinely dynamic values like calc(...).
Parents expose typed .add_child(...) and .add_children(...) methods, so an
element can only contain children the spec permits. Genuinely open-ended values
accept strings; Paint::raw(...), .attr(...) and .add_child_unchecked(...)
are explicit escape hatches for deliberately building invalid SVGs.
Use .to_string_pretty() for copy-friendly output.
To regenerate after replacing SVG/: