LogoPixi’VN
pixi-jsInterfaces

Interface: MeasureMixin

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:38

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.

Advanced

Extends

  • Required<MeasureMixinConstructor>

Properties

height

> height: number

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:29

The height of the display object, in pixels.

Example

new Container({ height: 100});

Default

0

Inherited from

VideoSpriteMemory.height


width

> width: number

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:20

The width of the display object, in pixels.

Example

new Container({ width: 100});

Default

0

Inherited from

VideoSpriteMemory.width

Methods

getBounds()

> getBounds(skipUpdate?, bounds?): Bounds

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:88

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

Parameters

skipUpdate?

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.

bounds?

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

Example

// 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);

Remarks

  • Includes transform calculations
  • Updates scene graph by default
  • Can reuse bounds objects
  • Common in hit testing

See


getLocalBounds()

> getLocalBounds(): Bounds

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:58

Retrieves the local bounds of the container as a Bounds object. Uses cached values when possible for better performance.

Returns

Bounds

The bounding area

Example

// 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

See


getSize()

> getSize(out?): Size

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:39

Parameters

out?

Size

Returns

Size


setSize()

Call Signature

> setSize(width, height?): void

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:40

Parameters
width

number

height?

number

Returns

void

Call Signature

> setSize(value): void

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/measureMixin.d.ts:41

Parameters
value

Optional<Size, "height">

Returns

void