Mask API
A mask in Loopic is an ordinary layer whose element is a Rectangle, Ellipse or Path, linked as the mask of one or more other layers. This layer is called a Mask Layer, and each layer it clips is a Masked Layer. There is no separate mask object: a Mask Layer is a Layer object like any other.
From Actions code, you reach masks through the Masked Layer: its maskLayers property holds its Mask Layers, as Layer objects.
Action example
const masked = this.findElementByKey("_photo").layer;
const maskElement = masked.maskLayers[0].element;
maskElement.style.width.value = 800;
How masks are applied
- A Mask Layer and the layers it masks must be in the same composition.
- One Mask Layer can mask several layers, and a layer can have several Mask Layers. With several, only the area inside all of them is visible.
- A Mask Layer keeps masking when it's hidden. Hiding it only stops its own shape being drawn.
- A Mask Layer clips only between its own start and end frames. Outside that range, the Masked Layer is shown unclipped.
- A guide layer isn't exported, so a guide used as a Mask Layer has no effect in the exported graphic.
Mask properties
The shape of the mask comes from these style properties of the Mask Layer's element. Change or animate them as you would on any element, and the mask follows.
| Name | Type | Rectangle | Ellipse | Path |
|---|---|---|---|---|
| x | number | ✅ | ✅ | ✅ |
| y | number | ✅ | ✅ | ✅ |
| width | number | ✅ | ✅ | |
| height | number | ✅ | ✅ | |
| borderRadius, borderTopLeftRadius, borderTopRightRadius, borderBottomLeftRadius, borderBottomRightRadius | number | ✅ |
A Path mask follows the points of the path, offset by its x and y. Other properties of the Mask Layer, such as rotation, scaleX, scaleY or opacity, don't change the mask.