Skip to content

A strongly typed SVG composing library written in Rust. This library allows you to ensure the soundness of your generated SVGs at the compile time of your project.

License

Notifications You must be signed in to change notification settings

yxdunc/svg_composer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG Composer

Latest version

A strongly typed SVG composing library written in Rust. This library allows you to ensure the soundness of your generated SVGs at the compile time of your project.

This project was made originaly for the generative art project : https://stegano.graphics

Rendering example of stegano.graphics using this library: rendering example image

Disclaimer

This library is still in early development and some API changes are to be expected, mainly to further enforce typing.

Example

let svg_document = Document::new(
    vec![Box::new(
        Path::new()
            .set_stroke(Paint::from_color(Color::from_name(ColorName::Fuchsia)))
            .set_stroke_width(Size::from_length(10.0))
            .add_commands(vec![
                Box::new(MoveTo {
                    point: (11., 1.),
                    coordinate_type: CoordinateType::Absolute,
                }),
                Box::new(LineTo {
                    point: (10.0, 20.0),
                    option: LineToOption::Default,
                    coordinate_type: CoordinateType::Relative,
                }),
                Box::new(LineTo {
                    point: (-20.0, 0.0),
                    option: LineToOption::Default,
                    coordinate_type: CoordinateType::Relative,
                }),
                Box::new(End {}),
            ]),
    )],
    Some([0., 0., 100., 100.]),
);

// This rendering outputs a .svg file which can then be rendered as an image by an svg renderer
println!("{}", svg_document.render());

About

A strongly typed SVG composing library written in Rust. This library allows you to ensure the soundness of your generated SVGs at the compile time of your project.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages