pixi.js
    Preparing search index...

    Interface MeasureMixinAdvanced

    The MeasureMixin interface provides methods for measuring and manipulating the size and bounds of a display object. It includes methods to get and set the size of the object, retrieve its local bounds, and calculate its global bounds.

    interface MeasureMixin {
        height: number;
        width: number;
        getBounds(skipUpdate?: boolean, bounds?: Bounds): Bounds;
        getLocalBounds(): Bounds;
        getSize(out?: Size): Size;
        setSize(width: number, height?: number): void;
        setSize(value: Optional<Size, "height">): void;
    }

    Hierarchy

    • Required<MeasureMixinConstructor>
      • MeasureMixin
    Index

    Properties

    height: number

    The height of the display object, in pixels.

    new Container({ height: 100});
    
    0
    
    width: number

    The width of the display object, in pixels.

    new Container({ width: 100});
    
    0
    

    Methods

    • Calculates and returns the (world) bounds of the display object as a Rectangle. Takes into account transforms and child bounds.

      Parameters

      • OptionalskipUpdate: boolean

        Setting to true will stop the transforms of the scene graph from being updated. This means the calculation returned MAY be out of date BUT will give you a nice performance boost.

      • Optionalbounds: Bounds

        Optional bounds to store the result of the bounds calculation

      Returns Bounds

      The minimum axis-aligned rectangle in world space that fits around this object

      // Basic bounds calculation
      const bounds = sprite.getBounds();
      console.log(`World bounds: ${bounds.x}, ${bounds.y}, ${bounds.width}, ${bounds.height}`);

      // Reuse bounds object for performance
      const recycleBounds = new Bounds();
      sprite.getBounds(false, recycleBounds);

      // Skip update for performance
      const fastBounds = sprite.getBounds(true);
      • Includes transform calculations
      • Updates scene graph by default
      • Can reuse bounds objects
      • Common in hit testing
    • Retrieves the local bounds of the container as a Bounds object. Uses cached values when possible for better performance.

      Returns Bounds

      The bounding area

      // Basic bounds check
      const bounds = container.getLocalBounds();
      console.log(`Width: ${bounds.width}, Height: ${bounds.height}`);
      // subsequent calls will reuse the cached bounds
      const cachedBounds = container.getLocalBounds();
      console.log(bounds === cachedBounds); // true
    • Parameters

      • width: number
      • Optionalheight: number

      Returns void

    • Parameters

      • value: Optional<Size, "height">

      Returns void