new Point( [x] [, y])
Parameters:
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
x |
number |
<optional> |
0 | The x coordinate of this Point. |
y |
number |
<optional> |
x | The y coordinate of this Point. |
- Since: 3.0.0
- Source: src/geom/point/Point.js (Line 10)
Members
-
<readonly> type :number
-
The geometry constant type of this object:
GEOM_CONST.POINT. Used for fast type comparisons.Type:
- number
- Since: 3.19.0
- Source: src/geom/point/Point.js (Line 31)
-
x :number
-
The x coordinate of this Point.
Type:
- number
- Since: 3.0.0
- Default Value:
-
- 0
- Source: src/geom/point/Point.js (Line 42)
-
y :number
-
The y coordinate of this Point.
Type:
- number
- Since: 3.0.0
- Default Value:
-
- 0
- Source: src/geom/point/Point.js (Line 52)
Methods
-
<static> Ceil(point)
-
Apply
Math.ceil()to each coordinate of the given Point.Parameters:
Name Type Description pointPhaser.Geom.Point The Point to ceil.
- Since: 3.0.0
- Source: src/geom/point/Ceil.js (Line 7)
Returns:
The Point with
Math.ceil()applied to its coordinates.- Type
- Phaser.Geom.Point
-
<static> Clone(source)
-
Clone the given Point.
Parameters:
Name Type Description sourcePhaser.Geom.Point The source Point to clone.
- Since: 3.0.0
- Source: src/geom/point/Clone.js (Line 9)
Returns:
The cloned Point.
- Type
- Phaser.Geom.Point
-
<static> CopyFrom(source, dest)
-
Copy the values of one Point to a destination Point.
Parameters:
Name Type Description sourcePhaser.Geom.Point The source Point to copy the values from.
destPhaser.Geom.Point The destination Point to copy the values to.
- Since: 3.0.0
- Source: src/geom/point/CopyFrom.js (Line 7)
Returns:
The destination Point.
- Type
- Phaser.Geom.Point
-
<static> Equals(point, toCompare)
-
A comparison of two
Pointobjects to see if they are equal.Parameters:
Name Type Description pointPhaser.Geom.Point The original
Pointto compare against.toComparePhaser.Geom.Point The second
Pointto compare.- Since: 3.0.0
- Source: src/geom/point/Equals.js (Line 7)
Returns:
Returns true if the both
Pointobjects are equal.- Type
- boolean
-
<static> Floor(point)
-
Apply
Math.ceil()to each coordinate of the given Point.Parameters:
Name Type Description pointPhaser.Geom.Point The Point to floor.
- Since: 3.0.0
- Source: src/geom/point/Floor.js (Line 7)
Returns:
The Point with
Math.floor()applied to its coordinates.- Type
- Phaser.Geom.Point
-
<static> GetCentroid(points [, out])
-
Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin.
Parameters:
Name Type Argument Description pointsArray.<Phaser.Types.Math.Vector2Like> An array of Vector2Like objects to get the geometric center of.
outPhaser.Geom.Point <optional>
A Point object to store the output coordinates in. If not given, a new Point instance is created.
- Since: 3.0.0
- Source: src/geom/point/GetCentroid.js (Line 9)
Returns:
A Point object representing the geometric center of the given points.
- Type
- Phaser.Geom.Point
-
<static> GetMagnitude(point)
-
Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point.
Parameters:
Name Type Description pointPhaser.Geom.Point The point to calculate the magnitude for
- Since: 3.0.0
- Source: src/geom/point/GetMagnitude.js (Line 7)
Returns:
The resulting magnitude
- Type
- number
-
<static> GetMagnitudeSq(point)
-
Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point)
Parameters:
Name Type Description pointPhaser.Geom.Point Returns square of the magnitude/length of given point.
- Since: 3.0.0
- Source: src/geom/point/GetMagnitudeSq.js (Line 7)
Returns:
Returns square of the magnitude of given point.
- Type
- number
-
<static> GetRectangleFromPoints(points [, out])
-
Calculates the Axis Aligned Bounding Box (or aabb) from an array of points.
Parameters:
Name Type Argument Description pointsArray.<Phaser.Types.Math.Vector2Like> An array of Vector2Like objects to get the AABB from.
outPhaser.Geom.Rectangle <optional>
A Rectangle object to store the results in. If not given, a new Rectangle instance is created.
- Since: 3.0.0
- Source: src/geom/point/GetRectangleFromPoints.js (Line 9)
Returns:
A Rectangle object holding the AABB values for the given points.
-
<static> Interpolate(pointA, pointB [, t] [, out])
-
Returns the linear interpolation point between the two given points, based on
t.Parameters:
Name Type Argument Default Description pointAPhaser.Geom.Point The starting
Pointfor the interpolation.pointBPhaser.Geom.Point The target
Pointfor the interpolation.tnumber <optional>
0 The amount to interpolate between the two points. Generally, a value between 0 (returns the starting
Point) and 1 (returns the targetPoint). If omitted, 0 is used.outPhaser.Geom.Point | object <optional>
An optional
Pointobject whosexandyvalues will be set to the result of the interpolation (can also be any object withxandyproperties). If omitted, a newPointcreated and returned.- Since: 3.0.0
- Source: src/geom/point/Interpolate.js (Line 9)
Returns:
Either the object from the
outargument with the propertiesxandyset to the result of the interpolation or a newly createdPointobject.- Type
- Phaser.Geom.Point | object
-
<static> Invert(point)
-
Swaps the X and the Y coordinate of a point.
Parameters:
Name Type Description pointPhaser.Geom.Point The Point to modify.
- Since: 3.0.0
- Source: src/geom/point/Invert.js (Line 7)
Returns:
The modified
point.- Type
- Phaser.Geom.Point
-
<static> Negative(point [, out])
-
Inverts a Point's coordinates.
Parameters:
Name Type Argument Description pointPhaser.Geom.Point The Point to invert.
outPhaser.Geom.Point <optional>
The Point to return the inverted coordinates in.
- Since: 3.0.0
- Source: src/geom/point/Negative.js (Line 9)
Returns:
The modified
outPoint, or a new Point if none was provided.- Type
- Phaser.Geom.Point
-
<static> Project(pointA, pointB [, out])
-
Calculates the vector projection of
pointAonto the nonzeropointB. This is the orthogonal projection ofpointAonto a straight line paralle topointB.Parameters:
Name Type Argument Description pointAPhaser.Geom.Point Point A, to be projected onto Point B.
pointBPhaser.Geom.Point Point B, to have Point A projected upon it.
outPhaser.Geom.Point <optional>
The Point object to store the position in. If not given, a new Point instance is created.
- Since: 3.0.0
- Source: src/geom/point/Project.js (Line 10)
Returns:
A Point object holding the coordinates of the vector projection of
pointAontopointB.- Type
- Phaser.Geom.Point
-
<static> ProjectUnit(pointA, pointB [, out])
-
Calculates the vector projection of
pointAonto the nonzeropointB. This is the orthogonal projection ofpointAonto a straight line paralle topointB.Parameters:
Name Type Argument Description pointAPhaser.Geom.Point Point A, to be projected onto Point B. Must be a normalized point with a magnitude of 1.
pointBPhaser.Geom.Point Point B, to have Point A projected upon it.
outPhaser.Geom.Point <optional>
The Point object to store the position in. If not given, a new Point instance is created.
- Since: 3.0.0
- Source: src/geom/point/ProjectUnit.js (Line 9)
Returns:
A unit Point object holding the coordinates of the vector projection of
pointAontopointB.- Type
- Phaser.Geom.Point
-
<static> SetMagnitude(point, magnitude)
-
Changes the magnitude (length) of a two-dimensional vector without changing its direction.
Parameters:
Name Type Description pointPhaser.Geom.Point The Point to treat as the end point of the vector.
magnitudenumber The new magnitude of the vector.
- Since: 3.0.0
- Source: src/geom/point/SetMagnitude.js (Line 9)
Returns:
The modified Point.
- Type
- Phaser.Geom.Point
-
setTo( [x] [, y])
-
Set the x and y coordinates of the point to the given values.
Parameters:
Name Type Argument Default Description xnumber <optional>
0 The x coordinate of this Point.
ynumber <optional>
x The y coordinate of this Point.
- Since: 3.0.0
- Source: src/geom/point/Point.js (Line 63)
Returns:
This Point object.
- Type
- Phaser.Geom.Point
