Advanced
The height of the display object, in pixels.
The width of the display object, in pixels.
Calculates and returns the (world) bounds of the display object as a Rectangle. Takes into account transforms and child bounds.
Optional
skipUpdate: booleanSetting 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.
Optional
bounds: BoundsOptional bounds to store the result of the bounds calculation
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);
Retrieves the local bounds of the container as a Bounds object. Uses cached values when possible for better performance.
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
Optional
height: number
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.