1use super::Node;
2
3pub struct Line(svg::node::element::Line);
4
5impl Node for Line {
6 type Element = svg::node::element::Line;
7
8 fn to_element(self) -> Self::Element {
9 self.0
10 }
11}
12
13impl Line {
14 pub fn new() -> Self {
15 Self(svg::node::element::Line::new())
16 .stroke_width(1)
17 .stroke("000000")
18 }
19
20 pub fn points(&self, from: (f64, f64), to: (f64, f64)) -> Self {
21 Self(
22 self.0
23 .to_owned()
24 .set("x1", from.0)
25 .set("y1", from.1)
26 .set("x2", to.0)
27 .set("y2", to.1),
28 )
29 }
30}
31
32impl Line {
34 pub fn stroke_width(self, value: usize) -> Self {
35 Self(self.0.set("stroke-width", value))
36 }
37
38 pub fn stroke(self, value: &str) -> Self {
39 Self(self.0.set("stroke", format!(r"#{}", value)))
40 }
41}