From 967b676fa69a1b5f4aee1f0c1c106cb1bf55c6e1 Mon Sep 17 00:00:00 2001 From: ksen0 Date: Tue, 3 Sep 2024 08:14:35 +0200 Subject: [PATCH] Clarify arc stroke behavior in different modes --- src/core/p5.Renderer2D.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 865559ded1..436fea7cbf 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -569,8 +569,18 @@ class Renderer2D extends p5.Renderer { if (this._doStroke) { if (!this._clipping) ctx.beginPath(); ctx.ellipse(centerX, centerY, radiusX, radiusY, 0, start, stop); - if (createPieSlice) ctx.lineTo(centerX, centerY); - if (mode !== constants.OPEN) ctx.closePath(); + + if (mode === constants.PIE && createPieSlice) { + // In PIE mode, stroke is added to the center and back to path, + // unless the pie forms a complete ellipse (see: createPieSlice) + ctx.lineTo(centerX, centerY); + } + + if (mode === constants.PIE || mode === constants.CHORD) { + // Stroke connects back to path begin for both PIE and CHORD + ctx.closePath(); + } + if (!this._clipping) ctx.stroke(); }