Typed SVG Writer
- Rust 99%
- Jinja 1%
| codegen | add feature flag to allow raw xml content | |
| src | add feature flag to allow raw xml content | |
| .gitignore | initial commit | |
| .gitmodules | vendor xmlwriter | |
| Cargo.toml | Release svgwriter 0.1.1 | |
| LICENSE.md | initial commit | |
| README.md | enable tests for xmlwriter | |
| rustfmt.toml | vendor xmlwriter | |
svgwriter License svgwriter on crates.io svgwriter on docs.rs Source Code Repository
svgwriter is a typed library for writing correct SVG files. It includes SVG
specification and documentation from mdn.
Example
usesvgwriter::{tags::{Path,TagWithPresentationAttributesas_},Data,Graphic};letmutsvg=Graphic::new();letsize=100;svg.set_width(size);svg.set_height(size);svg.set_view_box(format!("0 0 {size}{size}"));// draw a heart, inspired by https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#example
letd=40;letpadding=size/2-d;letmutheart=Data::new();heart.move_to(padding,padding+d/2).arc_by(d/2,d/2,0,false,true,d,0).arc_by(d/2,d/2,0,false,true,d,0).quad_by(0,d*3/4,-d,d*3/2).quad_by(-d,-d*3/4,-d,-d*3/2);svg.push(Path::new().with_d(heart).with_fill("#A919FA").with_fill_opacity(0.5).with_stroke("#A919FA").with_stroke_width(3));// write the svg to a file
write!(file,"{}",svg.to_string());This code produces the following image: