diff --git a/src/input.rs b/src/input.rs index d819871..91f697a 100644 --- a/src/input.rs +++ b/src/input.rs @@ -69,6 +69,10 @@ fn read_stdin() -> InputData { fn read_svg(input: &str) -> Result> { let svg = Document::from_str(input)?; let svg = svg.svg_element().unwrap(); + let svg_height = match svg.attributes().get_value(AttributeId::Height).unwrap() { + AttributeValue::Length(l) => l.num as f32, + _ => -42.0 + }; let mut house = None; let mut polys = Vec::new(); for (id, node) in svg.descendants().svg() { @@ -85,13 +89,13 @@ fn read_svg(input: &str) -> Result> { for p in &path.0 { match p { PathSegment::MoveTo { x, y, .. } => { - points.push(Point::new(*x as f32, -*y as f32)); + points.push(Point::new(*x as f32, svg_height-*y as f32)); } PathSegment::LineTo { x, y, .. } => { - points.push(Point::new(*x as f32, -*y as f32)); + points.push(Point::new(*x as f32, svg_height-*y as f32)); } PathSegment::VerticalLineTo { y, .. } => { - points.push(Point::new(points.last().unwrap().x(), -*y as f32)); + points.push(Point::new(points.last().unwrap().x(), svg_height-*y as f32)); } PathSegment::HorizontalLineTo { x, .. } => { points.push(Point::new(*x as f32, points.last().unwrap().y())); diff --git a/src/main.rs b/src/main.rs index d099a7a..11d54b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -234,7 +234,7 @@ fn main() { if opt.debug { // Performanz-Schätzung anzeigen eprintln!( - "DEBUG: {}μs/Iteration mit {} Iterationen", + "DEBUG: {}us/Iteration mit {} Iterationen", total_time.as_micros() / iterations, iterations );