✂️ How to cut out a shape from another shape?

Say I have a rectangle, how do I cut a shape (say a circle or a triangle) though it so what’s behind the cut shape is shown through the hole?

Inkscape provides many ways two paths can be combined (union, difference, intersection, exclusion, division, …); see the image below or read the Boolean operations section here. What I look for is difference, but having intersection and exclusion would be a nice extra :slightly_smiling_face:

Thanks! :blossom:
This will help me finish a package I make, which emulates the look of torn or cut pieces of paper (like the ones you see in Xeroxed punk zines).

I searched the documentation, the forum and the Universe but couldn’t find any solution.

The clip parameter can do intersection in simple cases. block (maybe with round corner) is the only shape supported right now afaik.

No idea for compilicated shape boolean operations (e.g. combination / exclusion).

1 Like

Hi @afiaith with the new curve, you can draw shapes and also cut out sections (by calling curve.close() and drawing a second curve with curve.move() etc.). The negative shapes for cutting out need to have vertices specified be in reverse direction compared to the main shape (e.g., clockwise vs. counter-clockwise). It is even possible to get intersections in a limited way by playing with fill-rule: "even-odd".

Edit: note that this can just be used to poke holes in a shape, not to “bite off something from the edge”. Here, I recommend shaping the outer-most curve the desired way directly. Unfortunately there is no better way currently.

6 Likes

Thanks! I was hoping there’s some trick, package or an official way to do that. I do think such boolean operations would be a welcome addition (maybe I’ll open an issue on Typst’s GitHub; IMHO this should be a core feature), but for the specific needs of my case it’s indeed possible to refactor the code and make it shape an outline curve instead of trying to remove stuff from a rectangle.