1
0
Fork
You've already forked svgwriter
0
Typed SVG Writer
  • Rust 99%
  • Jinja 1%
2026年01月05日 20:11:27 +01:00
codegen add feature flag to allow raw xml content 2026年01月02日 12:38:54 +01:00
src add feature flag to allow raw xml content 2026年01月02日 12:38:54 +01:00
.gitignore initial commit 2022年07月25日 18:59:45 +02:00
.gitmodules vendor xmlwriter 2022年09月23日 16:11:34 +02:00
Cargo.toml Release svgwriter 0.1.1 2026年01月05日 20:11:27 +01:00
LICENSE.md initial commit 2022年07月25日 18:59:45 +02:00
README.md enable tests for xmlwriter 2026年01月02日 10:52:28 +01:00
rustfmt.toml vendor xmlwriter 2022年09月23日 16:11:34 +02:00

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:

Image produced by example code