diff options
| -rw-r--r-- | src/state.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/state.rs b/src/state.rs index 02a3a85..c2f7848 100644 --- a/src/state.rs +++ b/src/state.rs @@ -84,13 +84,17 @@ impl State { let poly_points = self.find_poly(); self.ctx.set_line_width(0.005); - self.ctx.begin_path(); - self.ctx.move_to(poly_points[0].x, poly_points[0].y); - for p in poly_points { + let mut iter = poly_points.into_iter(); + let mut last = iter.next().ok_or("no poly points")?; + for p in iter { + self.ctx.begin_path(); + self.ctx.move_to(last.x, last.y); self.ctx.line_to(p.x, p.y); + self.ctx.set_stroke_style_str(&last.color); + self.ctx.stroke(); + + last = p; } - self.ctx.set_stroke_style_str("blue"); - self.ctx.stroke(); Ok(()) } |
