easy-svg

Crates.ioeasy-svg
lib.rseasy-svg
version0.3.2
created_at2025-09-01 03:00:46.412805+00
updated_at2025-09-17 02:56:26.585562+00
descriptionAuthor SVGs in Rust through a statically typed system
homepagehttps://github.com/effdotsh/easy-svg
repositoryhttps://github.com/effdotsh/easy-svg
max_upload_size
id1819085
size96,709
Ephram Cukier (effdotsh)

documentation

README

easy-svg

easy-svg is a crate for composing SVGs with rust code through a statically-typed system. The motivation behind this project is that other rust svg libraries require you to set attributes by string, leading to invalid states and a worse dev experience. easy-svg is being implemented per the Mozilla MDN SVG Reference, allowing for no ambiguity in SVG composition.

Svg::new()
    .width(500.)
    .height(500.)
    .add_child_shape_element(
        Rect::new()
            .width(200.)
            .height(400.)
            .x(20.)
            .fill(Color::DarkOliveGreen),
    )
    .add_child_text(
        Text::new()
            .x(30.)
            .y(70.)
            .fill(Color::DarkMagenta)
            .add_child_string("Hello World".to_string())
            .font_family("Arial".to_string()),
    )
    .add_child_shape_element(Circle::new().fill(Color::DarkBlue).r(20.).cx(80.).cy(85.));

svg_example_1

This project is a work in progress, and there may be minor breaking changes in the future. This crate is not yet feature-complete, however adding any individual tag or attribute is trivial so you can open an issue or file a pr updating svg_elements.yml.

Commit count: 43

cargo fmt