sdl2-demo: fix painting of zones

The Y coordinate was not inverted, and the zone polygon would not get
closed.
This commit is contained in:
Mikolaj Wielgus 2024-04-06 01:55:41 +00:00
parent 9bf18db4d1
commit 1362058db5
1 changed files with 6 additions and 2 deletions

View File

@ -72,13 +72,17 @@ impl<'a> Painter<'a> {
let mut it = polygon.exterior_coords_iter(); let mut it = polygon.exterior_coords_iter();
if let Some(initial_vertex) = it.next() { 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 { 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.set_line_width(0.0);
self.canvas.fill_path(path, FillRule::Winding); self.canvas.fill_path(path, FillRule::Winding);
} }