From 62e74d482afa614eb098ea4cc9dc322c0f6de100 Mon Sep 17 00:00:00 2001 From: VANSH3104 Date: Sun, 1 Feb 2026 22:33:48 +0530 Subject: [PATCH] Add transform support to bezier shapes in clip() --- src/core/p5.Renderer2D.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 9390b867cf..fbe5747449 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -272,7 +272,10 @@ class Renderer2D extends Renderer { }); shape.accept(visitor); if (this._clipping) { - this.clipPath.addPath(visitor.path); + const currentTransform = this.drawingContext.getTransform(); + const clipBaseTransform = this._clipBaseTransform.inverse(); + const relativeTransform = clipBaseTransform.multiply(currentTransform); + this.clipPath.addPath(visitor.path, relativeTransform); this.clipPath.closePath(); } else { if (this.states.fillColor) { @@ -286,7 +289,7 @@ class Renderer2D extends Renderer { beginClip(options = {}) { super.beginClip(options); - + this._clipBaseTransform = this.drawingContext.getTransform(); // cache the fill style this.states.setValue('_cachedFillStyle', this.drawingContext.fillStyle); const newFill = this._pInst.color(255, 0).toString();