pixi.js
    Preparing search index...

    Interface ShapePrimitiveAdvanced

    A basic interface that defines common properties and methods for all Pixi shape primitives. Provides a standard API for shape manipulation, hit testing, and bounds calculation.

    // Implement basic shape
    class CustomShape implements ShapePrimitive {
    public readonly type = 'custom';
    public x = 0;
    public y = 0;

    // Implement required methods
    public contains(x: number, y: number): boolean {
    // Custom hit testing logic
    return true;
    }

    public getBounds(out?: Rectangle): Rectangle {
    // Custom bounds calculation
    return out || new Rectangle();
    }

    // ... implement other required methods
    }
    // Use in a container
    container.hitArea = new CustomShape();
    • Rectangle For rectangular shape implementation
    • Circle For circular shape implementation
    • Polygon For polygon shape implementation
    interface ShapePrimitive {
        type: SHAPE_PRIMITIVE | string & {};
        x: number;
        y: number;
        clone(): ShapePrimitive;
        contains(x: number, y: number): boolean;
        copyFrom(source: ShapePrimitive): void;
        copyTo(destination: ShapePrimitive): void;
        getBounds(out?: Rectangle): Rectangle;
        strokeContains(
            x: number,
            y: number,
            strokeWidth: number,
            alignment?: number,
        ): boolean;
    }

    Implemented by

    Index

    Properties

    type: SHAPE_PRIMITIVE | string & {}

    The type of the object, mainly used to avoid instanceof checks

    x: number

    The X coordinate of the shape

    y: number

    The Y coordinate of the shape

    Methods

    • Checks whether the x and y coordinates passed to this function are contained within this ShapePrimitive.

      Parameters

      • x: number
      • y: number

      Returns boolean

    • Copies the properties from another ShapePrimitive to this ShapePrimitive.

      Parameters

      Returns void

    • Copies the properties from this ShapePrimitive to another ShapePrimitive.

      Parameters

      Returns void

    • Checks whether the x and y coordinates passed to this function are contained within the stroke of this shape

      Parameters

      • x: number
      • y: number
      • strokeWidth: number
      • Optionalalignment: number

      Returns boolean