diff options
| -rw-r--r-- | site/pure.mjs | 16 | ||||
| -rw-r--r-- | src/state.rs | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/site/pure.mjs b/site/pure.mjs index 6a4447c..3a77aee 100644 --- a/site/pure.mjs +++ b/site/pure.mjs @@ -244,11 +244,17 @@ export default async function () { const polyPoints = findPoly3(points); ctx.lineWidth = 0.005; - ctx.beginPath(); - ctx.moveTo(polyPoints[0].x, polyPoints[0].y); - polyPoints.forEach(p => ctx.lineTo(p.x, p.y)); - ctx.strokeStyle = 'blue'; - ctx.stroke(); + let last = polyPoints[0]; + for (let i = 1; i < polyPoints.length; i++) { + const p = polyPoints[i]; + ctx.beginPath(); + ctx.moveTo(last.x, last.y); + ctx.strokeStyle = last.color; + ctx.lineTo(p.x, p.y); + ctx.stroke(); + + last = p; + } if (!paused) { self.requestAnimationFrame(render); diff --git a/src/state.rs b/src/state.rs index c2f7848..3b5e235 100644 --- a/src/state.rs +++ b/src/state.rs @@ -89,8 +89,8 @@ impl State { 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.line_to(p.x, p.y); self.ctx.stroke(); last = p; |
