Mask

Masks are used to crop or shape elements. The maskData property can be applied to image, video, and other visual elements to control their visible area.

Mask Types

  • crop: Simple rectangular crop
  • shape: Shape-based mask (ellipse, rectangle, star, polygon, etc.)
  • text: Text-based mask
  • path: Custom path mask

Crop Mask

PropTypeRequiredExampleValue RangeDescription
typestringtrue-cropThe type of mask.
centerXnumbertrue--The horizontal position of the mask center, in pixels.
centerYnumbertrue--The vertical position of the mask center, in pixels.
widthnumbertrue--The width of the mask, in pixels.
heightnumbertrue--The height of the mask, in pixels.
inversebooleanfalse--Whether to invert the mask (create a cutout effect).
imageElement.json
1{ 2 "id": "0a2db861-19c0-47d0-9e71-5a56a357e2e9", 3 "type": "Image", 4 "start": 0, 5 "duration": 5, 6 "trackIndex": 0, 7 "x": -58.59302855661144, 8 "y": 48.394393104046685, 9 "blendMode": "normal", 10 "anchorX": 1051.1350332909515, 11 "anchorY": 2519.1996978825114, 12 "rotation": 0, 13 "maskData": { 14 "type": "crop", 15 "centerX": 1051.1350332909515, 16 "centerY": 2519.1996978825114, 17 "width": 2121.862754282655, 18 "height": 2949.902587890625 19 }, 20 "scaleX": 0.23356401384083045, 21 "scaleY": 0.23356401384083045, 22 "alpha": 1, 23 "skewX": 0, 24 "skewY": 0, 25 "keyframes": [], 26 "externalUrl": "https://images.pexels.com/photos/30465303/pexels-photo-30465303.jpeg", 27 "ext": "jpeg" 28} 29

Shape Mask

PropTypeRequiredExampleValue RangeDescription
typestringtrue-shapeThe type of mask.
shapeTypestringtrue-SHAPE_RECT | SHAPE_ELLIPSE | SHAPE_STAR | SHAPE_POLYGON | SHAPE_PATHThe type of shape for the mask.
xnumbertrue--The horizontal position of the mask, in pixels.
ynumbertrue--The vertical position of the mask, in pixels.
scaleXnumbertrue--The horizontal scale of the mask.
scaleYnumbertrue--The vertical scale of the mask.
rotationnumbertrue--The rotation of the mask, in radians.
widthnumberfalse--The width of the mask, in pixels.
heightnumberfalse--The height of the mask, in pixels.
fillstringtrue--The fill color of the mask, in hexadecimal format.
viewobjecttrue--The view transformation properties of the mask.
pointNumnumberfalse--Number of points for polygon or star shapes.
innerRadiusnumberfalse--Inner radius for star shapes (relative to outer radius).
outerRadiusnumberfalse--Outer radius for star shapes.
cornerRadiusnumberfalse--Corner radius for rounded rectangle shapes.
inversebooleanfalse--Whether to invert the mask (create a cutout effect).
imageElement.json
1{ 2 "id": "0a2db861-19c0-47d0-9e71-5a56a357e2e9", 3 "type": "Image", 4 "start": 0, 5 "duration": 5, 6 "trackIndex": 0, 7 "x": -58.59302855661144, 8 "y": 48.394393104046685, 9 "blendMode": "normal", 10 "anchorX": 1051.1350332909515, 11 "anchorY": 2519.1996978825114, 12 "rotation": 0, 13 "maskData": { 14 "type": "shape", 15 "shapeType": "SHAPE_ELLIPSE", 16 "x": 1935.8609161703698, 17 "y": 2120.7135441063306, 18 "scaleX": 1, 19 "scaleY": 1, 20 "rotation": 0, 21 "width": 2604, 22 "height": 2604, 23 "fill": "#ffffff", 24 "view": { 25 "scaleX": 1, 26 "scaleY": 1, 27 "x": 0, 28 "y": 0, 29 "width": 2604, 30 "height": 2604, 31 "rotation": 0, 32 "anchorX": 0, 33 "anchorY": 0 34 } 35 }, 36 "scaleX": 0.23356401384083045, 37 "scaleY": 0.23356401384083045, 38 "alpha": 1, 39 "skewX": 0, 40 "skewY": 0, 41 "keyframes": [], 42 "externalUrl": "https://images.pexels.com/photos/30465303/pexels-photo-30465303.jpeg", 43 "ext": "jpeg" 44} 45

Text Mask

Use text as a mask to crop an element into text shapes.

PropTypeRequiredExampleValue RangeDescription
typestringtrue-textThe type of mask.
xnumbertrue--The horizontal position of the text mask, in pixels.
ynumbertrue--The vertical position of the text mask, in pixels.
rotationnumbertrue--The rotation of the text mask, in radians.
scalenumbertrue--The scale of the text mask.
fontSizenumbertrue--The font size of the text, in pixels.
fontFamilystringtrue--The font family name.
textstringtrue--The text content.
isBoldbooleantrue--Whether the text is bold.
isItalicbooleantrue--Whether the text is italic.
letterSpacingnumbertrue--Letter spacing in pixels.
inversebooleanfalse--Whether to invert the mask (create a cutout effect).

Path Mask

Use a custom vector path (Bezier curves) as a mask.

PropTypeRequiredExampleValue RangeDescription
typestringtrue-pathThe type of mask.
cnumbertrue--Whether the path is closed (1) or open (0). Closed paths can be filled.
varraytrue--Array of path vertex points. Each point is a [x, y] array.
iarraytrue--Array of incoming tangent control points for each vertex.
oarraytrue--Array of outgoing tangent control points for each vertex.
inversebooleanfalse--Whether to invert the mask (create a cutout effect).

Important Notes

  • Coordinate System: All positions (x, y, centerX, centerY) are in pixels relative to the element's original size.
  • Rotation Units: Rotation values are in radians, not degrees. To convert degrees to radians: radians = degrees * Math.PI / 180.
  • Inverse Masks: When inverse: true, the mask creates a cutout effect - the element is visible everywhere except the masked area.
  • Mask vs Region:
    • maskData crops the element itself (node-level clipping)
    • filterAgent.region limits where a filter effect is applied (effect-level masking)
  • Performance: Complex masks (especially path masks with many vertices) may impact rendering performance.