Phaser.Geom.Rectangle

Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height)

Constructor

new Rectangle([x], [y], [width], [height])

Parameters:

nametypeoptionaldefaultdescription
xnumberYes0The X coordinate of the top left corner of the Rectangle.
ynumberYes0The Y coordinate of the top left corner of the Rectangle.
widthnumberYes0The width of the Rectangle.
heightnumberYes0The height of the Rectangle.

Scope: static

Source: src/geom/rectangle/Rectangle.js - Line: 15
Since: 3.0.0

Methods:

Area

<static> Area(rect)

Description:

Calculates the area of the given Rectangle object.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe rectangle to calculate the area of.

Returns: number - The area of the Rectangle object.

Source: src/geom/rectangle/Area.js - Line: 7
Since: 3.0.0


Ceil

<static> Ceil(rect)

Tags:

  • generic

Description:

Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to adjust.

Returns: Phaser.Geom.Rectangle - The adjusted Rectangle.

Source: src/geom/rectangle/Ceil.js - Line: 7
Since: 3.0.0


CeilAll

<static> CeilAll(rect)

Tags:

  • generic

Description:

Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to modify.

Returns: Phaser.Geom.Rectangle - The modified Rectangle.

Source: src/geom/rectangle/CeilAll.js - Line: 7
Since: 3.0.0


CenterOn

<static> CenterOn(rect, x, y)

Tags:

  • generic

Description:

Moves the top-left corner of a Rectangle so that its center is at the given coordinates.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to be centered.
xnumberNoThe X coordinate of the Rectangle's center.
ynumberNoThe Y coordinate of the Rectangle's center.

Returns: Phaser.Geom.Rectangle - The centered rectangle.

Source: src/geom/rectangle/CenterOn.js - Line: 7
Since: 3.0.0


Clone

<static> Clone(source)

Description:

Creates a new Rectangle which is identical to the given one.

Parameters:

nametypeoptionaldescription
sourcePhaser.Geom.RectangleNoThe Rectangle to clone.

Returns: Phaser.Geom.Rectangle - The newly created Rectangle, which is separate from the given one.

Source: src/geom/rectangle/Clone.js - Line: 9
Since: 3.0.0


contains

<instance> contains(x, y)

Description:

Checks if the given point is inside the Rectangle's bounds.

Parameters:

nametypeoptionaldescription
xnumberNoThe X coordinate of the point to check.
ynumberNoThe Y coordinate of the point to check.

Returns: boolean - true if the point is within the Rectangle's bounds, otherwise false.

Source: src/geom/rectangle/Rectangle.js - Line: 92
Since: 3.0.0


Contains

<static> Contains(rect, x, y)

Description:

Checks if a given point is inside a Rectangle's bounds.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to check.
xnumberNoThe X coordinate of the point to check.
ynumberNoThe Y coordinate of the point to check.

Returns: boolean - true if the point is within the Rectangle's bounds, otherwise false.

Source: src/geom/rectangle/Contains.js - Line: 7
Since: 3.0.0


ContainsPoint

<static> ContainsPoint(rect, point)

Description:

Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle object.
pointPhaser.Geom.PointNoThe point object to be checked. Can be a Phaser Point object or any object with x and y values.

Returns: boolean - A value of true if the Rectangle object contains the specified point, otherwise false.

Source: src/geom/rectangle/ContainsPoint.js - Line: 9
Since: 3.0.0


ContainsRect

<static> ContainsRect(rectA, rectB)

Description:

Tests if one rectangle fully contains another.

Parameters:

nametypeoptionaldescription
rectAPhaser.Geom.RectangleNoThe first rectangle.
rectBPhaser.Geom.RectangleNoThe second rectangle.

Returns: boolean - True only if rectA fully contains rectB.

Source: src/geom/rectangle/ContainsRect.js - Line: 7
Since: 3.0.0


CopyFrom

<static> CopyFrom(source, dest)

Tags:

  • generic

Description:

Copy the values of one Rectangle to a destination Rectangle.

Parameters:

nametypeoptionaldescription
sourcePhaser.Geom.RectangleNoThe source Rectangle to copy the values from.
destPhaser.Geom.RectangleNoThe destination Rectangle to copy the values to.

Returns: Phaser.Geom.Rectangle - The destination Rectangle.

Source: src/geom/rectangle/CopyFrom.js - Line: 7
Since: 3.0.0


Decompose

<static> Decompose(rect, [out])

Description:

Create an array of points for each corner of a Rectangle If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle object to be decomposed.
outarrayYesIf provided, each point will be added to this array.

Returns: array - Will return the array you specified or a new array containing the points of the Rectangle.

Source: src/geom/rectangle/Decompose.js - Line: 7
Since: 3.0.0


Equals

<static> Equals(rect, toCompare)

Description:

Compares the x, y, width and height properties of two rectangles.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoRectangle A
toComparePhaser.Geom.RectangleNoRectangle B

Returns: boolean - true if the rectangles' properties are an exact match, otherwise false.

Source: src/geom/rectangle/Equals.js - Line: 7
Since: 3.0.0


FitInside

<static> FitInside(target, source)

Tags:

  • generic

Description:

Adjusts the target rectangle, changing its width, height and position, so that it fits inside the area of the source rectangle, while maintaining its original aspect ratio.

Unlike the FitOutside function, there may be some space inside the source area not covered.

Parameters:

nametypeoptionaldescription
targetPhaser.Geom.RectangleNoThe target rectangle to adjust.
sourcePhaser.Geom.RectangleNoThe source rectangle to envelop the target in.

Returns: Phaser.Geom.Rectangle - The modified target rectangle instance.

Source: src/geom/rectangle/FitInside.js - Line: 9
Since: 3.0.0


FitOutside

<static> FitOutside(target, source)

Tags:

  • generic

Description:

Adjusts the target rectangle, changing its width, height and position, so that it fully covers the area of the source rectangle, while maintaining its original aspect ratio.

Unlike the FitInside function, the target rectangle may extend further out than the source.

Parameters:

nametypeoptionaldescription
targetPhaser.Geom.RectangleNoThe target rectangle to adjust.
sourcePhaser.Geom.RectangleNoThe source rectangle to envelope the target in.

Returns: Phaser.Geom.Rectangle - The modified target rectangle instance.

Source: src/geom/rectangle/FitOutside.js - Line: 9
Since: 3.0.0


Floor

<static> Floor(rect)

Tags:

  • generic

Description:

Rounds down (floors) the top left X and Y coordinates of the given Rectangle to the largest integer less than or equal to them

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe rectangle to floor the top left X and Y coordinates of

Returns: Phaser.Geom.Rectangle - The rectangle that was passed to this function with its coordinates floored.

Source: src/geom/rectangle/Floor.js - Line: 7
Since: 3.0.0


FloorAll

<static> FloorAll(rect)

Tags:

  • generic

Description:

Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to adjust.

Returns: Phaser.Geom.Rectangle - The adjusted Rectangle.

Source: src/geom/rectangle/FloorAll.js - Line: 7
Since: 3.0.0


FromPoints

<static> FromPoints(points, [out])

Tags:

  • generic

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:

nametypeoptionaldescription
pointsarrayNoAn 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.
outPhaser.Geom.RectangleYesOptional Rectangle to adjust.

Returns: Phaser.Geom.Rectangle - The adjusted out Rectangle, or a new Rectangle if none was provided.

Source: src/geom/rectangle/FromPoints.js - Line: 10
Since: 3.0.0


FromXY

<static> FromXY(x1, y1, x2, y2, [out])

Tags:

  • generic

Description:

Create the smallest Rectangle containing two coordinate pairs.

Parameters:

nametypeoptionaldescription
x1numberNoThe X coordinate of the first point.
y1numberNoThe Y coordinate of the first point.
x2numberNoThe X coordinate of the second point.
y2numberNoThe Y coordinate of the second point.
outPhaser.Geom.RectangleYesOptional Rectangle to adjust.

Returns: Phaser.Geom.Rectangle - The adjusted out Rectangle, or a new Rectangle if none was provided.

Source: src/geom/rectangle/FromXY.js - Line: 9
Since: 3.23.0


GetAspectRatio

<static> GetAspectRatio(rect)

Description:

Calculates the width/height ratio of a rectangle.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe rectangle.

Returns: number - The width/height ratio of the rectangle.

Source: src/geom/rectangle/GetAspectRatio.js - Line: 7
Since: 3.0.0


GetCenter

<static> GetCenter(rect, [out])

Tags:

  • generic

Description:

Returns the center of a Rectangle as a Point.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to get the center of.
outPhaser.Geom.Point | objectYesOptional point-like object to update with the center coordinates.

Returns: Phaser.Geom.Point, object - The modified out object, or a new Point if none was provided.

Source: src/geom/rectangle/GetCenter.js - Line: 9
Since: 3.0.0


getLineA

<instance> getLineA([line])

Tags:

  • generic

Description:

Returns a Line object that corresponds to the top of this Rectangle.

Parameters:

nametypeoptionaldescription
linePhaser.Geom.LineYesA Line object to set the results in. If undefined a new Line will be created.

Returns: Phaser.Geom.Line - A Line object that corresponds to the top of this Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 257
Since: 3.0.0


getLineB

<instance> getLineB([line])

Tags:

  • generic

Description:

Returns a Line object that corresponds to the right of this Rectangle.

Parameters:

nametypeoptionaldescription
linePhaser.Geom.LineYesA Line object to set the results in. If undefined a new Line will be created.

Returns: Phaser.Geom.Line - A Line object that corresponds to the right of this Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 278
Since: 3.0.0


getLineC

<instance> getLineC([line])

Tags:

  • generic

Description:

Returns a Line object that corresponds to the bottom of this Rectangle.

Parameters:

nametypeoptionaldescription
linePhaser.Geom.LineYesA Line object to set the results in. If undefined a new Line will be created.

Returns: Phaser.Geom.Line - A Line object that corresponds to the bottom of this Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 299
Since: 3.0.0


getLineD

<instance> getLineD([line])

Tags:

  • generic

Description:

Returns a Line object that corresponds to the left of this Rectangle.

Parameters:

nametypeoptionaldescription
linePhaser.Geom.LineYesA Line object to set the results in. If undefined a new Line will be created.

Returns: Phaser.Geom.Line - A Line object that corresponds to the left of this Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 320
Since: 3.0.0


getPoint

<instance> getPoint(position, [output])

Tags:

  • generic

Description:

Calculates the coordinates of a point at a certain position on the Rectangle's perimeter.

The position is a fraction between 0 and 1 which defines how far into the perimeter the point is.

A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.

Parameters:

nametypeoptionaldescription
positionnumberNoThe normalized distance into the Rectangle's perimeter to return.
outputPhaser.Geom.Point | objectYesAn object to update with the x and y coordinates of the point.

Returns: Phaser.Geom.Point, object - The updated output object, or a new Point if no output object was given.

Source: src/geom/rectangle/Rectangle.js - Line: 108
Since: 3.0.0


GetPoint

<static> GetPoint(rectangle, position, [out])

Tags:

  • generic

Description:

Calculates the coordinates of a point at a certain position on the Rectangle's perimeter.

The position is a fraction between 0 and 1 which defines how far into the perimeter the point is.

A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.

Parameters:

nametypeoptionaldescription
rectanglePhaser.Geom.RectangleNoThe Rectangle to get the perimeter point from.
positionnumberNoThe normalized distance into the Rectangle's perimeter to return.
outPhaser.Geom.Point | objectYesAn object to update with the x and y coordinates of the point.

Returns: Phaser.Geom.Point - The updated output object, or a new Point if no output object was given.

Source: src/geom/rectangle/GetPoint.js - Line: 10
Since: 3.0.0


getPoints

<instance> getPoints(quantity, [stepRate], [output])

Tags:

  • generic

Description:

Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required.

Parameters:

nametypeoptionaldescription
quantitynumberNoThe number of points to return. Set to false or 0 to return an arbitrary number of points (perimeter / stepRate) evenly spaced around the Rectangle based on the stepRate.
stepRatenumberYesIf quantity is 0, determines the normalized distance between each returned point.
outputarray | Array.<Phaser.Geom.Point>YesAn array to which to append the points.

Returns: array, Array.<Phaser.Geom.Point> - The modified output array, or a new array if none was provided.

Source: src/geom/rectangle/Rectangle.js - Line: 130
Since: 3.0.0


GetPoints

<static> GetPoints(rectangle, step, quantity, [out])

Tags:

  • generic

Description:

Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required.

Parameters:

nametypeoptionaldescription
rectanglePhaser.Geom.RectangleNoThe Rectangle object to get the points from.
stepnumberNoStep between points. Used to calculate the number of points to return when quantity is falsey. Ignored if quantity is positive.
quantitynumberNoThe number of evenly spaced points from the rectangles perimeter to return. If falsey, step param will be used to calculate the number of points.
outarray | Array.<Phaser.Geom.Point>YesAn optional array to store the points in.

Returns: array, Array.<Phaser.Geom.Point> - An array of Points from the perimeter of the rectangle.

Source: src/geom/rectangle/GetPoints.js - Line: 10
Since: 3.0.0


getRandomPoint

<instance> getRandomPoint([point])

Tags:

  • generic

Description:

Returns a random point within the Rectangle's bounds.

Parameters:

nametypeoptionaldescription
pointPhaser.Geom.PointYesThe object in which to store the x and y coordinates of the point.

Returns: Phaser.Geom.Point - The updated point, or a new Point if none was provided.

Source: src/geom/rectangle/Rectangle.js - Line: 149
Since: 3.0.0


GetSize

<static> GetSize(rect, [out])

Tags:

  • generic

Description:

Returns the size of the Rectangle, expressed as a Point object. With the value of the width as the x property and the height as the y property.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to get the size from.
outPhaser.Geom.Point | objectYesThe Point object to store the size in. If not given, a new Point instance is created.

Returns: Phaser.Geom.Point, object - A Point object where x holds the width and y holds the height of the Rectangle.

Source: src/geom/rectangle/GetSize.js - Line: 9
Since: 3.0.0


Inflate

<static> Inflate(rect, x, y)

Tags:

  • generic

Description:

Increases the size of a Rectangle by a specified amount.

The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to inflate.
xnumberNoHow many pixels the left and the right side should be moved by horizontally.
ynumberNoHow many pixels the top and the bottom side should be moved by vertically.

Returns: Phaser.Geom.Rectangle - The inflated Rectangle.

Source: src/geom/rectangle/Inflate.js - Line: 9
Since: 3.0.0


Intersection

<static> Intersection(rectA, rectB, [out])

Tags:

  • generic

Description:

Takes two Rectangles and first checks to see if they intersect. If they intersect it will return the area of intersection in the out Rectangle. If they do not intersect, the out Rectangle will have a width and height of zero.

Parameters:

nametypeoptionaldescription
rectAPhaser.Geom.RectangleNoThe first Rectangle to get the intersection from.
rectBPhaser.Geom.RectangleNoThe second Rectangle to get the intersection from.
outPhaser.Geom.RectangleYesA Rectangle to store the intersection results in.

Returns: Phaser.Geom.Rectangle - The intersection result. If the width and height are zero, no intersection occurred.

Source: src/geom/rectangle/Intersection.js - Line: 10
Since: 3.11.0


isEmpty

<instance> isEmpty()

Description:

Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0.

Returns: boolean - true if the Rectangle is empty. A Rectangle object is empty if its width or height is less than or equal to 0.

Source: src/geom/rectangle/Rectangle.js - Line: 244
Since: 3.0.0


MarchingAnts

<static> MarchingAnts(rect, [step], [quantity], [out])

Tags:

  • generic

Description:

Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based on either the step value, or the quantity.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to get the perimeter points from.
stepnumberYesThe distance between each point of the perimeter. Set to null if you wish to use the quantity parameter instead.
quantitynumberYesThe total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value.
outarray | Array.<Phaser.Geom.Point>YesAn array in which the perimeter points will be stored. If not given, a new array instance is created.

Returns: array, Array.<Phaser.Geom.Point> - An array containing the perimeter points from the Rectangle.

Source: src/geom/rectangle/MarchingAnts.js - Line: 10
Since: 3.0.0


MergePoints

<static> MergePoints(target, points)

Tags:

  • generic

Description:

Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds.

Parameters:

nametypeoptionaldescription
targetPhaser.Geom.RectangleNoThe Rectangle which should be merged.
pointsArray.<Phaser.Geom.Point>NoAn array of Points (or any object with public x and y properties) which should be merged with the Rectangle.

Returns: Phaser.Geom.Rectangle - The modified Rectangle.

Source: src/geom/rectangle/MergePoints.js - Line: 7
Since: 3.0.0


MergeRect

<static> MergeRect(target, source)

Tags:

  • generic

Description:

Merges the source rectangle into the target rectangle and returns the target. Neither rectangle should have a negative width or height.

Parameters:

nametypeoptionaldescription
targetPhaser.Geom.RectangleNoTarget rectangle. Will be modified to include source rectangle.
sourcePhaser.Geom.RectangleNoRectangle that will be merged into target rectangle.

Returns: Phaser.Geom.Rectangle - Modified target rectangle that contains source rectangle.

Source: src/geom/rectangle/MergeRect.js - Line: 7
Since: 3.0.0


MergeXY

<static> MergeXY(target, x, y)

Tags:

  • generic

Description:

Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds.

Parameters:

nametypeoptionaldescription
targetPhaser.Geom.RectangleNoThe Rectangle which should be merged and modified.
xnumberNoThe X coordinate of the point which should be merged.
ynumberNoThe Y coordinate of the point which should be merged.

Returns: Phaser.Geom.Rectangle - The modified target Rectangle.

Source: src/geom/rectangle/MergeXY.js - Line: 7
Since: 3.0.0


Offset

<static> Offset(rect, x, y)

Tags:

  • generic

Description:

Nudges (translates) the top left corner of a Rectangle by a given offset.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to adjust.
xnumberNoThe distance to move the Rectangle horizontally.
ynumberNoThe distance to move the Rectangle vertically.

Returns: Phaser.Geom.Rectangle - The adjusted Rectangle.

Source: src/geom/rectangle/Offset.js - Line: 7
Since: 3.0.0


OffsetPoint

<static> OffsetPoint(rect, point)

Tags:

  • generic

Description:

Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector).

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to adjust.
pointPhaser.Geom.Point | Phaser.Math.Vector2NoThe point whose coordinates should be used as an offset.

Returns: Phaser.Geom.Rectangle - The adjusted Rectangle.

Source: src/geom/rectangle/OffsetPoint.js - Line: 7
Since: 3.0.0


Overlaps

<static> Overlaps(rectA, rectB)

Description:

Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid".

Parameters:

nametypeoptionaldescription
rectAPhaser.Geom.RectangleNoThe first Rectangle to check.
rectBPhaser.Geom.RectangleNoThe second Rectangle to check.

Returns: boolean - true if the two Rectangles overlap, false otherwise.

Source: src/geom/rectangle/Overlaps.js - Line: 7
Since: 3.0.0


Perimeter

<static> Perimeter(rect)

Description:

Calculates the perimeter of a Rectangle.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to use.

Returns: number - The perimeter of the Rectangle, equal to (width * 2) + (height * 2).

Source: src/geom/rectangle/Perimeter.js - Line: 7
Since: 3.0.0


PerimeterPoint

<static> PerimeterPoint(rectangle, angle, [out])

Tags:

  • generic

Description:

Returns a Point from the perimeter of a Rectangle based on the given angle.

Parameters:

nametypeoptionaldescription
rectanglePhaser.Geom.RectangleNoThe Rectangle to get the perimeter point from.
anglenumberNoThe angle of the point, in degrees.
outPhaser.Geom.PointYesThe Point object to store the position in. If not given, a new Point instance is created.

Returns: Phaser.Geom.Point - A Point object holding the coordinates of the Rectangle perimeter.

Source: src/geom/rectangle/PerimeterPoint.js - Line: 10
Since: 3.0.0


Random

<static> Random(rect, out)

Tags:

  • generic

Description:

Returns a random point within a Rectangle.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle to return a point from.
outPhaser.Geom.PointNoThe object to update with the point's coordinates.

Returns: Phaser.Geom.Point - The modified out object, or a new Point if none was provided.

Source: src/geom/rectangle/Random.js - Line: 9
Since: 3.0.0


RandomOutside

<static> RandomOutside(outer, inner, [out])

Tags:

  • generic

Description:

Calculates a random point that lies within the outer Rectangle, but outside of the inner Rectangle. The inner Rectangle must be fully contained within the outer rectangle.

Parameters:

nametypeoptionaldescription
outerPhaser.Geom.RectangleNoThe outer Rectangle to get the random point within.
innerPhaser.Geom.RectangleNoThe inner Rectangle to exclude from the returned point.
outPhaser.Geom.PointYesA Point, or Point-like object to store the result in. If not specified, a new Point will be created.

Returns: Phaser.Geom.Point - A Point object containing the random values in its x and y properties.

Source: src/geom/rectangle/RandomOutside.js - Line: 11
Since: 3.10.0


SameDimensions

<static> SameDimensions(rect, toCompare)

Description:

Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe first Rectangle object.
toComparePhaser.Geom.RectangleNoThe second Rectangle object.

Returns: boolean - true if the objects have equivalent values for the width and height properties, otherwise false.

Source: src/geom/rectangle/SameDimensions.js - Line: 7
Since: 3.15.0


Scale

<static> Scale(rect, x, y)

Tags:

  • generic

Description:

Scales the width and height of this Rectangle by the given amounts.

Parameters:

nametypeoptionaldescription
rectPhaser.Geom.RectangleNoThe Rectangle object that will be scaled by the specified amount(s).
xnumberNoThe factor by which to scale the rectangle horizontally.
ynumberNoThe amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor x in both directions.

Returns: Phaser.Geom.Rectangle - The rectangle object with updated width and height properties as calculated from the scaling factor(s).

Source: src/geom/rectangle/Scale.js - Line: 7
Since: 3.0.0


setEmpty

<instance> setEmpty()

Description:

Resets the position, width, and height of the Rectangle to 0.

Returns: Phaser.Geom.Rectangle - This Rectangle object.

Source: src/geom/rectangle/Rectangle.js - Line: 189
Since: 3.0.0


setPosition

<instance> setPosition(x, [y])

Description:

Sets the position of the Rectangle.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe X coordinate of the top left corner of the Rectangle.
ynumberYes"x"The Y coordinate of the top left corner of the Rectangle.

Returns: Phaser.Geom.Rectangle - This Rectangle object.

Source: src/geom/rectangle/Rectangle.js - Line: 202
Since: 3.0.0


setSize

<instance> setSize(width, [height])

Description:

Sets the width and height of the Rectangle.

Parameters:

nametypeoptionaldefaultdescription
widthnumberNoThe width to set the Rectangle to.
heightnumberYes"width"The height to set the Rectangle to.

Returns: Phaser.Geom.Rectangle - This Rectangle object.

Source: src/geom/rectangle/Rectangle.js - Line: 223
Since: 3.0.0


setTo

<instance> setTo(x, y, width, height)

Description:

Sets the position, width, and height of the Rectangle.

Parameters:

nametypeoptionaldescription
xnumberNoThe X coordinate of the top left corner of the Rectangle.
ynumberNoThe Y coordinate of the top left corner of the Rectangle.
widthnumberNoThe width of the Rectangle.
heightnumberNoThe height of the Rectangle.

Returns: Phaser.Geom.Rectangle - This Rectangle object.

Source: src/geom/rectangle/Rectangle.js - Line: 166
Since: 3.0.0


Union

<static> Union(rectA, rectB, [out])

Tags:

  • generic

Description:

Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union.

Parameters:

nametypeoptionaldescription
rectAPhaser.Geom.RectangleNoThe first Rectangle to use.
rectBPhaser.Geom.RectangleNoThe second Rectangle to use.
outPhaser.Geom.RectangleYesThe Rectangle to store the union in.

Returns: Phaser.Geom.Rectangle - The modified out Rectangle, or a new Rectangle if none was provided.

Source: src/geom/rectangle/Union.js - Line: 9
Since: 3.0.0


Members:

bottom: number

bottom

Description:

The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.

Source: src/geom/rectangle/Rectangle.js - Line: 432
Since: 3.0.0


centerX: number

centerX

Description:

The x coordinate of the center of the Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 461
Since: 3.0.0


centerY: number

centerY

Description:

The y coordinate of the center of the Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 482
Since: 3.0.0


height: number

height

Description:

The height of the Rectangle, i.e. the distance between its top side (defined by y) and its bottom side.

Source: src/geom/rectangle/Rectangle.js - Line: 81
Since: 3.0.0


left: number

left

Description:

The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property.

Source: src/geom/rectangle/Rectangle.js - Line: 341
Since: 3.0.0


right: number

Description:

The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property.

Source: src/geom/rectangle/Rectangle.js - Line: 372
Since: 3.0.0


top: number

top

Description:

The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. However it does affect the height property, whereas changing the y value does not affect the height property.

Source: src/geom/rectangle/Rectangle.js - Line: 401
Since: 3.0.0


type: number

type

Description:

The geometry constant type of this object: GEOM_CONST.RECTANGLE. Used for fast type comparisons.

Source: src/geom/rectangle/Rectangle.js - Line: 40
Since: 3.19.0


width: number

width

Description:

The width of the Rectangle, i.e. the distance between its left side (defined by x) and its right side.

Source: src/geom/rectangle/Rectangle.js - Line: 71
Since: 3.0.0


x: number

x

Description:

The X coordinate of the top left corner of the Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 51
Since: 3.0.0


y: number

y

Description:

The Y coordinate of the top left corner of the Rectangle.

Source: src/geom/rectangle/Rectangle.js - Line: 61
Since: 3.0.0


Updated on