MaskRenderer

The MaskRenderer component renders a filled shape: a rectangle, a circle, or a polygon. It is useful for UI elements, visual effects, or masking other content. It uses the entity’s Transform for position. See Rendering for an overview.

Options

OptionTypeDefaultDescription
shapeMaskShapeMaskShape.Rectangle, MaskShape.Circumference, or MaskShape.Polygon.
widthnumber0Width in pixels. Rectangle only.
heightnumber0Height in pixels. Rectangle only.
radiusnumber0Radius in pixels. Circumference only.
vertexModelVector2[][]Polygon vertices. Polygon only.
colorstring"#000000"Fill color.
offsetVector2(0, 0)Offset from the entity’s position.
rotationnumber0Rotation in radians.
opacitynumber1Opacity between 0 and 1.
layerstring"Default"The render layer.

Example

import { Transform, MaskRenderer, MaskShape } from "angry-pixel";

this.entityManager.createEntity([
    new Transform(),
    new MaskRenderer({
        shape: MaskShape.Rectangle,
        width: 32,
        height: 32,
        color: "#000000",
        layer: "UI",
    }),
]);