Skip to content

Commit a975515

Browse files
committed
Refactor rect to use canvas roundRect
1 parent 94e1969 commit a975515

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/core/p5.Renderer2D.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class Renderer2D extends p5.Renderer {
548548
radiusY = h / 2;
549549

550550
// Determines whether to add a line to the center, which should be done
551-
// when the mode is PIE or default, as well as when the start and end
551+
// when the mode is PIE or default; as well as when the start and end
552552
// angles do not form a full circle.
553553
const createPieSlice = ! (
554554
mode === constants.CHORD ||
@@ -600,7 +600,7 @@ class Renderer2D extends p5.Renderer {
600600
radiusX = w / 2,
601601
radiusY = h / 2;
602602
if (!this._clipping) ctx.beginPath();
603-
603+
604604
ctx.ellipse(centerX, centerY, radiusX, radiusY, 0, 0, 2 * Math.PI);
605605

606606
if (!this._clipping && doFill) {
@@ -745,14 +745,7 @@ class Renderer2D extends p5.Renderer {
745745
bl = hh;
746746
}
747747

748-
// Draw shape
749-
if (!this._clipping) ctx.beginPath();
750-
ctx.moveTo(x + tl, y);
751-
ctx.arcTo(x + w, y, x + w, y + h, tr);
752-
ctx.arcTo(x + w, y + h, x, y + h, br);
753-
ctx.arcTo(x, y + h, x, y, bl);
754-
ctx.arcTo(x, y, x + w, y, tl);
755-
ctx.closePath();
748+
ctx.roundRect(x, y, w, h, [tl, tr, br, bl]);
756749
}
757750
if (!this._clipping && this._doFill) {
758751
ctx.fill();

0 commit comments

Comments
 (0)