# LayerMixin.createMask
Adds a mask to this layer

{/* Do not edit this file. It is automatically generated by API Documenter. */}

## LayerMixin.createMask() method

Adds a mask to this layer

**Signature:**

```typescript
createMask(opts: MaskOptions): Mask;
```

## Parameters

<table>
  <thead>
    <tr>
      <th>
        Parameter
      </th>

      <th>
        Type
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        opts
      </td>

      <td>
        [MaskOptions](../../types/mask-options)
      </td>

      <td>
        Options for creating the mask
      </td>
    </tr>
  </tbody>
</table>

**Returns:**

[Mask](../mask)

The newly created mask

## Example

```ts
// 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,
});
```
