Clipping an imported SVG using arbitrary shape

Hey Folks

Scratching my head on how to clip an imported SVG file using an arbitrary shape, not a rectangle. The two shapes I’m currently playing with is an isosceles triangle and an isosceles triangle that uses a bezier as the base rather than a straight line. But I’d like to be able to use any arbitrary closed geometry to clip the imported drawing. By clipping, I mean to cut out a shape from an imported SVG. I’ve attached a screenshot of the original SVG and the result I’m aiming for.

The result will be used on a laser cutter so it needs to result in a clean vector file.

clip() seems to only work with rectangles. I’ve also played with beginCountour()/endCountour() but that seems to just work with shapes drawn with beginShape()/endShape()?

Any and all help is appreciated.

This can’t be done with any built-in Processing methods.

You’ll need to use something like (2d boolean) shape intersection from PGS to achieve this.

Note PGS does not preserve bezier curve elements and will subsample them into straight-line segments.

I would recommend Java over Processing.

Export your project and copy the .java file in the source folder and copy it to a new folder.
Copy all resources and core.jar to the new folder too.

Open the .java file in your Java editor(I recommend Intellij IDEA) and import core.jar as a Library.

Now you can use Java methods and Java tutorials.

Thanks! This library looks rich. I’ll take a look.

Hadn’t considered that. Thanks for the pointer.