Skip to content

Commit 8bf815c

Browse files
authored
Merge pull request #8481 from VANSH3104/bezarshape
Add transform support to bezier shapes in clip()
2 parents af1a881 + d5327c0 commit 8bf815c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/core/p5.Renderer2D.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ class Renderer2D extends Renderer {
272272
});
273273
shape.accept(visitor);
274274
if (this._clipping) {
275-
this.clipPath.addPath(visitor.path);
275+
const currentTransform = this.drawingContext.getTransform();
276+
const clipBaseTransform = this._clipBaseTransform.inverse();
277+
const relativeTransform = clipBaseTransform.multiply(currentTransform);
278+
this.clipPath.addPath(visitor.path, relativeTransform);
276279
this.clipPath.closePath();
277280
} else {
278281
if (this.states.fillColor) {
@@ -286,7 +289,7 @@ class Renderer2D extends Renderer {
286289

287290
beginClip(options = {}) {
288291
super.beginClip(options);
289-
292+
this._clipBaseTransform = this.drawingContext.getTransform();
290293
// cache the fill style
291294
this.states.setValue('_cachedFillStyle', this.drawingContext.fillStyle);
292295
const newFill = this._pInst.color(255, 0).toString();

0 commit comments

Comments
 (0)