Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Line

[package]
name = "line"
version = "0.1.0"
edition = "2024"

[dependencies]
svg = "0.18.0"
use svg::Document;
use svg::node::element::Line;

fn main() {
    let document = Document::new().set("viewBox", (0, 0, 70, 70)).add(
        Line::new()
            .set("x1", 10)
            .set("y1", 10)
            .set("x2", 10)
            .set("y2", 60)
            .set("stroke", "black")
            .set("stroke-width", 3),
    );

    svg::save("line.svg", &document).unwrap();
}
<svg viewBox="0 0 70 70" xmlns="http://www.w3.org/2000/svg">
<line stroke="black" stroke-width="3" x1="10" x2="10" y1="10" y2="60"/>
</svg>

Line