Masking
Basic Masking
To create a shape that masks other shapes, set the mask
property to true
.
To restore the mask and prevent masking of future shapes, call the restoreCanvas()
method.
Layer masks
You can also create layers that mask other layers by using the mask
property. A layer that is a mask is generally referred to as a ‘layer mask’.
However, when creating layer masks, the restoreCanvas()
method must be made into a layer using the layer
property, as demonstrated above.
Masking draggable layers
In this example, move the shapes to see how layer masks affects the draggability of other shapes.
Using an SVG path as a mask
You can also use an SVG path as a mask using the drawPath()
method’s SVG path support.