Skip to content

Commit

Permalink
Refactor rect to use canvas roundRect
Browse files Browse the repository at this point in the history
  • Loading branch information
ksen0 committed Sep 3, 2024
1 parent 94e1969 commit a975515
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/core/p5.Renderer2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ class Renderer2D extends p5.Renderer {
radiusY = h / 2;

// Determines whether to add a line to the center, which should be done
// when the mode is PIE or default, as well as when the start and end
// when the mode is PIE or default; as well as when the start and end
// angles do not form a full circle.
const createPieSlice = ! (
mode === constants.CHORD ||
Expand Down Expand Up @@ -600,7 +600,7 @@ class Renderer2D extends p5.Renderer {
radiusX = w / 2,
radiusY = h / 2;
if (!this._clipping) ctx.beginPath();

ctx.ellipse(centerX, centerY, radiusX, radiusY, 0, 0, 2 * Math.PI);

if (!this._clipping && doFill) {
Expand Down Expand Up @@ -745,14 +745,7 @@ class Renderer2D extends p5.Renderer {
bl = hh;
}

// Draw shape
if (!this._clipping) ctx.beginPath();
ctx.moveTo(x + tl, y);
ctx.arcTo(x + w, y, x + w, y + h, tr);
ctx.arcTo(x + w, y + h, x, y + h, br);
ctx.arcTo(x, y + h, x, y, bl);
ctx.arcTo(x, y, x + w, y, tl);
ctx.closePath();
ctx.roundRect(x, y, w, h, [tl, tr, br, bl]);
}
if (!this._clipping && this._doFill) {
ctx.fill();
Expand Down

0 comments on commit a975515

Please sign in to comment.