#svg #path #little #color #background-color #fill #move

svg_minimal

一个利用<path>元素和少量其他功能的简化svg库

2个版本

0.1.1 2020年6月2日
0.1.0 2020年5月30日

#620图像

Download history 19/week @ 2024-03-29 2/week @ 2024-04-05 83/week @ 2024-06-07 9/week @ 2024-06-14

每月92次下载

MIT/Apache

13KB
249

svg_minimal-rs

一个利用<path>标签和少量其他功能的简化svg库。唯一的路径选项是M: move toL: line toC: bezier curveZ: close path

示例

    use svg_minimal::*;

    fn main() {
        let mut svg = MinSVG::new([0,0,100,100]). // Construct an svg with the viewBox you would like
        svg.set_background_color(Color::Green); // If not invoked there will be no background

        let mut path = Path::new(); // Construct a new path element. I guess you only really need "one per color".
        path.set_stroke_color(Color::Black); // If not invoked the color is none
        path.set_stroke_width(3); // If not invoked the stroke-width is 0

        path.move_to([0,0]);
        path.line_to([100,100]);
        path.bezier([100,80,20,0,0,0]); // Hope this works :)

        path.set_fill_color(Color::Black); // Fill the drawn path if you want to;

        svg.add_path(path); // Add the path to the svg

        let svg_string = svg.create(); // Returns the svg as a string
    }

无运行时依赖