Add some backwards-compat in here
Getty Ritter
6 years ago
4 | 4 | |
5 | 5 | /// An SVG document |
6 | 6 | pub struct SVG { |
7 |
stuff: Vec<Box< |
|
7 | stuff: Vec<Box<AsSVG>>, | |
8 | 8 | size: (f64, f64), |
9 | 9 | } |
10 | 10 | |
20 | 20 | |
21 | 21 | fn inches(amt: f64) -> Inches { Inches { amt } } |
22 | 22 | |
23 |
fn xml_tag(w: &mut Vec<u8>, name: &str, attrs: &[(&str, & |
|
23 | fn xml_tag(w: &mut Vec<u8>, name: &str, attrs: &[(&str, &Display)]) { | |
24 | 24 | write!(w, "<{}", name); |
25 |
for |
|
25 | for &(k, v) in attrs { | |
26 | 26 | write!(w, " {}=\"{}\"", k, v); |
27 | 27 | } |
28 | 28 | writeln!(w, "/>"); |
29 | 29 | } |
30 | 30 | |
31 |
fn xml_open(w: &mut Vec<u8>, name: &str, attrs: &[(&str, & |
|
31 | fn xml_open(w: &mut Vec<u8>, name: &str, attrs: &[(&str, &Display)]) { | |
32 | 32 | write!(w, "<{}", name); |
33 |
for |
|
33 | for &(k, v) in attrs { | |
34 | 34 | write!(w, " {}=\"{}\"", k, v); |
35 | 35 | } |
36 | 36 | writeln!(w, ">"); |
132 | 132 | let mut path = Vec::new(); |
133 | 133 | let (x, y) = self.start; |
134 | 134 | write!(&mut path, "M{} {}", x, y); |
135 |
for |
|
135 | for &(x, y) in self.points.iter() { | |
136 | 136 | write!(&mut path, " L{} {}", x, y); |
137 | 137 | } |
138 | 138 | String::from_utf8(path).unwrap() |