Skip to content

Commit

Permalink
Clarify arc stroke behavior in different modes
Browse files Browse the repository at this point in the history
  • Loading branch information
ksen0 committed Sep 3, 2024
1 parent a975515 commit 967b676
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/p5.Renderer2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 967b676

Please sign in to comment.