Phaser API Documentation

  Version: 
<static> FromPoints(points, [out])

Description:

Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds.

The points parameter is an array of Point-like objects:

const points = [
    [100, 200],
    [200, 400],
    { x: 30, y: 60 }
]

Parameters:

name type arguments description
points array

An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public x and y properties) which should be surrounded by the Rectangle.

out Phaser.Geom.Rectangle <optional>

Optional Rectangle to adjust.

Returns:
Description:

The adjusted out Rectangle, or a new Rectangle if none was provided.

Since: 3.0.0