LayerMixin.createMask

Adds a mask to this layer

LayerMixin.createMask() method

Adds a mask to this layer

Signature:

createMask(opts: MaskOptions): Mask;

Parameters

Parameter

Type

Description

opts

MaskOptions

Options for creating the mask

Returns:

Mask

The newly created mask

Example

// Create a rectangular mask path
const maskPath: PathData = {
  points: [
    { vertex: { x: 0, y: 0 }, inTan: { x: 0, y: 0 }, outTan: { x: 0, y: 0 } },
    { vertex: { x: 100, y: 0 }, inTan: { x: 0, y: 0 }, outTan: { x: 0, y: 0 } },
    { vertex: { x: 100, y: 100 }, inTan: { x: 0, y: 0 }, outTan: { x: 0, y: 0 } },
    { vertex: { x: 0, y: 100 }, inTan: { x: 0, y: 0 }, outTan: { x: 0, y: 0 } },
  ],
  closed: true,
};

// Add mask to layer
layer.createMask({
  mode: "add",
  pathData: maskPath,
  opacity: 100,
});
Last updated: August 5, 2026 at 11:47 AMEdit this page