Expand description

Export a Drawing in SVG.

After importing ToSVG in scope, one can call ToSVG::to_svg on any Drawing.

See the Dessin crate for more details on how to build a drawing.

use dessin::{shape::Text, style::{FontWeight, Fill, Color}, vec2, Drawing};
use dessin_svg::ToSVG;

let mut drawing = Drawing::empty().with_canvas_size(vec2(50., 50.));

   Text::new("Hello, world!".to_owned())
       .at(vec2(10., 10.))

let svg = drawing.to_svg().unwrap();

assert_eq!(svg, r#"<svg viewBox="-25 -25 50 50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><text x="10" y="-10" text-anchor="start" font-family="Arial" font-size="16" font-weight="bold" fill='rgba(255,0,0,1)' >Hello, world!</text></svg>"#);