diff options
| author | brian cully <bjc@spork.org> | 2025-12-29 10:46:09 -0500 |
|---|---|---|
| committer | brian cully <bjc@spork.org> | 2025-12-29 10:46:09 -0500 |
| commit | 8a95b3c2949ff14dd940c32a077c7a856197239f (patch) | |
| tree | e3dd004a811c437d7415508884f7e3060a807bc2 /src | |
| parent | 470e1819153da90885e9cd94ba0177aa2ccfac9b (diff) | |
| download | polyring-8a95b3c2949ff14dd940c32a077c7a856197239f.tar.gz polyring-8a95b3c2949ff14dd940c32a077c7a856197239f.zip | |
wasm rainbow polyring
Diffstat (limited to 'src')
| -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(()) } |
