A mask can be attached to any type of object to restrict its visibility. Masks can be drawn in any of the shapes supported by the system. Masks can be rotated provided the shape of the mask supports rotation. [Eg. if it is a rectangular mask, it can be rotated, unlike circles - as it doesn't make sense to rotate one! ] You can also create custom masks. Let's dive in to make masks 🎭
Components required to make a mask:
- position x, y coordinates
- shape needs a shape type (eg: rectangle)
* if the shape is a polygon then a points array is needed with x, y coordinates - size needs height and width ( not needed in case of polygons )
- stroke needs a color & width [optional]
- fill [optional]
Let's look at a few masks to understand this better:
We'll start with a basic image (See the shot below to begin)


The Image
{
"duration": 1000,
"objects": [
{
"comment": "Background Image",
"opacity": 1,
"scale": 1,
"url": "https://media.kubric.io/api/assetlib/1bb74c46-94c4-4412-b09b-45e4e26fadff.jpeg",
"contain":true,
"position": {
"y": 0,
"x": 0
},
"type": "image",
"size": {
"h": 1178,
"w": 1400
}
}
],
"size": {
"h": 1178,
"w": 1400
}
}
A Rectangular mask


A Rectangular Mask
This is how to insert a rectangle mask looks -
"mask": {
"position": {
"y": 100,
"x": 100
},
"shape": "rectangle",
"size": {
"h": 850,
"w": 1200
},
"fill": "transparent"
}
Here's how to insert that into a shot:
{
"duration": 1000,
"objects": [
{
"comment": "Simple foreground color",
"opacity": 1,
"kind": "rectangle",
"scale": 1,
"color": "#7678ed",
"shape": "rectangle",
"position": {
"y": 0,
"x": 0
},
"type": "shape",
"size": {
"h": 1178,
"w": 1400
}
},
{
"comment": "Background Image",
"opacity": 1,
"scale": 1,
"url": "https://media.kubric.io/api/assetlib/1bb74c46-94c4-4412-b09b-45e4e26fadff.jpeg",
"contain": true,
"position": {
"y": 0,
"x": 0
},
"type": "image",
"size": {
"h": 1178,
"w": 1400
},
"mask": {
"position": {
"y": 100,
"x": 100
},
"shape": "rectangle",
"size": {
"h": 850,
"w": 1200
},
"fill": "transparent"
}
}
],
"size": {
"h": 1178,
"w": 1400
}
}
A Circular mask


A Circular Mask
If we replace the above mask object with the one below, we get a circular mask -
"mask": {
"position": {
"y": 600,
"x": 600
},
"shape": "circle",
"size": 500,
"fill": "transparent"
}
A Polygon mask


A Polygon Mask
"mask": {
"position": {
"y": 0,
"x": 0
},
"shape": "polygon"
"stroke": {
"color": "black",
"width": 1
},
"points": [
{
"y": 100,
"x": 100
},
{
"y": 100,
"x": 1300
},
{
"y": 1100,
"x": 700
},
{
"y": 800,
"x": 100
}
]
}
Mask Rotation


A Rotated Rectangular mask
"mask": {
"position": {
"y": 100,
"x": 100
},
"shape": "rectangle",
"size": {
"h": 850,
"w": 1200
},
"rotate": {
"axis": "top-left",
"rotateBy": 12
},
"fill": "transparent"
}
Updated 2 months ago
What's Next
Object Rotation |