From 1362058db5bd8bb5ed69aa6816a034a86d0757f9 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sat, 6 Apr 2024 01:55:41 +0000 Subject: [PATCH] sdl2-demo: fix painting of zones The Y coordinate was not inverted, and the zone polygon would not get closed. --- src/bin/topola-sdl2-demo/painter.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bin/topola-sdl2-demo/painter.rs b/src/bin/topola-sdl2-demo/painter.rs index ab21b60..7f814d2 100644 --- a/src/bin/topola-sdl2-demo/painter.rs +++ b/src/bin/topola-sdl2-demo/painter.rs @@ -72,13 +72,17 @@ impl<'a> Painter<'a> { let mut it = polygon.exterior_coords_iter(); if let Some(initial_vertex) = it.next() { - path.move_to(vec2f(initial_vertex.x as f32, initial_vertex.y as f32)); + path.move_to(vec2f(initial_vertex.x as f32, -initial_vertex.y as f32)); } for vertex in it { - path.line_to(vec2f(vertex.x as f32, vertex.y as f32)); + path.line_to(vec2f(vertex.x as f32, -vertex.y as f32)); } + path.close_path(); + + self.canvas.set_stroke_style(color); + self.canvas.set_fill_style(color); self.canvas.set_line_width(0.0); self.canvas.fill_path(path, FillRule::Winding); }