Phaser API Documentation

  Version: 

Member of: Phaser.Structs.Size

fitTo([width], [height])

Description:

The current width and height are adjusted to fit inside the given dimensions, while keeping the aspect ratio.

There may be some space inside the target area which is not covered if its aspect ratio differs.

If this Size component has a parent set, then the width and height passed to this method will be clamped so it cannot exceed that of the parent.

Parameters:

name type arguments description
width number <optional>

The new width of the Size component.

height number <optional>

The new height of the Size component. If not given, it will use the width value.

Returns:
Description:

This Size component instance.

Since: 3.16.0
Source: src/structs/Size.js (Line 521)