MaskRenderer

The MaskRenderer component renders filled shapes such as rectangles, circles, or polygons.
It supports different shape types with configurable dimensions, colors, positioning, and rotation.
Shapes can be rendered with variable opacity and assigned to specific render layers.
This component is useful for creating UI elements, visual effects, or masking other rendered content.

Properties

PropertyTypeDescription
shapeMaskShapeShape type: Rectangle, Circumference, or Polygon.
widthnumberWidth of the mask in pixels (only for rectangles).
heightnumberHeight of the mask in pixels (only for rectangles).
radiusnumberRadius of the mask in pixels (only for circumferences).
vertexModelVector2[]Polygon vertices (only for polygons).
colorstringMask color.
offsetVector2Offset on the X and Y axes relative to the entity’s center.
rotationnumberMask rotation in radians.
opacitynumberMask opacity (value between 0 and 1).
layerstringRender layer where the mask will be drawn.

Example with rectangle

const maskRenderer = new MaskRenderer({
    shape: MaskShape.Rectangle,
    width: 32,
    height: 32,
    color: "#000000",
    offset: new Vector2(0, 0),
    rotation: 0,
    opacity: 1,
    layer: "Default",
});

Example with circumference

const maskRenderer = new MaskRenderer({
    shape: MaskShape.Circumference,
    radius: 16,
    color: "#000000",
    offset: new Vector2(0, 0),
    opacity: 1,
    layer: "Default",
});

Example with polygon

const maskRenderer = new MaskRenderer({
    shape: MaskShape.Polygon,
    vertexModel: [new Vector2(0, 0), new Vector2(32, 0), new Vector2(32, 32), new Vector2(0, 32)],
    color: "#000000",
    offset: new Vector2(0, 0),
    opacity: 1,
    layer: "Default",
});

Notes

  • Each shape requires different properties:
    • Rectangle: requires width and height.
    • Circumference: requires radius.
    • Polygon: requires vertexModel.
  • Rotation (rotation) only affects rectangles and polygons.
  • The opacity value allows creating semi-transparent masks if set below 1.
  • The rendering system applies visual properties and positioning. The component only defines the mask attributes.