1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use super::*;
impl<T> ToSVG for Circle<T>
where
T: Display,
{
fn to_svg(&self) -> SVG {
let attributes = vec![
("cx", format!("{}", self.center.x)),
("cy", format!("{}", self.center.y)),
("r", format!("{}", self.radius)),
];
SVG::new("circle", attributes, vec![])
}
}
impl<T> ToSVG for Ellipse<T>
where
T: Display + PartialEq + Zero,
{
fn to_svg(&self) -> SVG {
let mut attributes = vec![
("cx", format!("{}", self.center.x)),
("cy", format!("{}", self.center.y)),
("rx", format!("{}", self.radius.0)),
("ry", format!("{}", self.radius.1)),
];
if !self.is_horizontal() {
let rotate = format!("rotate({}, {} {})", self.rotate, self.center.x, self.center.y);
attributes.push(("transform", rotate));
}
SVG::new("ellipse", attributes, vec![])
}
}