From 8a95b3c2949ff14dd940c32a077c7a856197239f Mon Sep 17 00:00:00 2001 From: brian cully Date: Mon, 29 Dec 2025 10:46:09 -0500 Subject: wasm rainbow polyring --- src/state.rs | 14 +++++++++----- 1 file 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(()) } -- cgit v1.3