Skip to content

Commit 967b676

Browse files
committed
Clarify arc stroke behavior in different modes
1 parent a975515 commit 967b676

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/p5.Renderer2D.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,18 @@ class Renderer2D extends p5.Renderer {
569569
if (this._doStroke) {
570570
if (!this._clipping) ctx.beginPath();
571571
ctx.ellipse(centerX, centerY, radiusX, radiusY, 0, start, stop);
572-
if (createPieSlice) ctx.lineTo(centerX, centerY);
573-
if (mode !== constants.OPEN) ctx.closePath();
572+
573+
if (mode === constants.PIE && createPieSlice) {
574+
// In PIE mode, stroke is added to the center and back to path,
575+
// unless the pie forms a complete ellipse (see: createPieSlice)
576+
ctx.lineTo(centerX, centerY);
577+
}
578+
579+
if (mode === constants.PIE || mode === constants.CHORD) {
580+
// Stroke connects back to path begin for both PIE and CHORD
581+
ctx.closePath();
582+
}
583+
574584
if (!this._clipping) ctx.stroke();
575585
}
576586

0 commit comments

Comments
 (0)