For anyone who is looking for an answer to the urgent question of how to combine two outline shapes into one outline shape (rather than casting a shadow on a combined shape), here is a possible solution:
<svg width="400" height="400"> <defs> <rect id="canvas" width="100%" height="100%" fill="white" /> <rect id="shape1" x="40" y="50" width="40" height="70" /> <circle id="shape2" cx="50" cy="50" r="50" /> <mask id="shape1-cutout"> <use href="#canvas" /> <use href="#shape1" /> </mask> <mask id="shape2-cutout"> <use href="#canvas" /> <use href="#shape2" /> </mask> </defs> <use href="#shape1" stroke="red" fill="none" mask="url(#shape2-cutout)" /> <use href="#shape2" stroke="red" fill="none" mask="url(#shape1-cutout)" /> </svg>
This essentially draws a circle with a rectangular shape cut out of it and draws a rectangle with a circle cut out of it. When you put these βcut-outβ shapes on top of each other, you get what looks like a single outline shape.
Here is what SVG actually does:
- It defines a white rectangle called a βcanvasβ that is the same size as the SVG.
- It defines two shapes that should be combined ("shape1" and "shape2").
- It defines a mask for each shape that combines the canvas (with white fill) with the shape (with black fill by default). Note that when you apply a mask to a figure, that part of the figure that matches the white area of ββthe mask is displayed, and that part that matches the black part is hidden.
- He draws each figure with a mask of another figure.
devuxer
source share