Optionalx1: numberThe x coordinate of the lines starting point. Default 0.
Optionaly1: numberThe y coordinate of the lines starting point. Default 0.
Optionalx2: numberThe x coordinate of the lines ending point. Default 0.
Optionaly2: numberThe y coordinate of the lines ending point. Default 0.
The bottom position of the Line.
The left position of the Line.
The right position of the Line.
The top position of the Line.
ReadonlytypeThe geometry constant type of this object: GEOM_CONST.LINE.
Used for fast type comparisons.
The x coordinate of the lines starting point.
The x coordinate of the lines ending point.
The y coordinate of the lines starting point.
The y coordinate of the lines ending point.
Get a point on a line that's a given percentage along its length.
A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line.
Optionaloutput: OAn optional Vector2 object to store the coordinates of the point on the line.
Get a number of points along a line's length.
Provide a quantity to get an exact number of points along the line.
Provide a stepRate to ensure a specific distance between each point on the line. Set quantity to 0 when
providing a stepRate.
The number of points to place on the line. Set to 0 to use stepRate instead.
OptionalstepRate: numberThe distance between each point on the line. When set, quantity is implied and should be set to 0.
Optionaloutput: OAn optional array of Vector2 objects to store the coordinates of the points on the line.
Sets this Line to match the x/y coordinates of the two given Vector2Like objects.
Any object with public x and y properties, whose values will be assigned to the x1/y1 components of this Line.
Any object with public x and y properties, whose values will be assigned to the x2/y2 components of this Line.
Set new coordinates for the line endpoints.
Optionalx1: numberThe x coordinate of the lines starting point. Default 0.
Optionaly1: numberThe y coordinate of the lines starting point. Default 0.
Optionalx2: numberThe x coordinate of the lines ending point. Default 0.
Optionaly2: numberThe y coordinate of the lines ending point. Default 0.
StaticAngleStaticBresenhamUsing Bresenham's line algorithm this will return an array of all coordinates on this line.
The start and end points are rounded before this runs as the algorithm works on integers.
The line.
OptionalstepRate: numberThe optional step rate for the points on the line. Default 1.
Optionalresults: Vector2Like[]An optional array to push the resulting coordinates into.
StaticCenterStaticCloneStaticCopyStaticEqualsStaticExtendExtends the start and end points of a Line by the given amounts.
The amounts can be positive or negative. Positive points will increase the length of the line, while negative ones will decrease it.
If no right value is provided it will extend the length of the line equally in both directions.
Pass a value of zero to leave the start or end point unchanged.
StaticGetReturns an array of quantity Points where each point is taken from the given Line,
spaced out according to the ease function specified.
const line = new Phaser.Geom.Line(100, 300, 700, 300);
const points = Phaser.Geom.Line.GetEasedPoints(line, 'sine.out', 32)
In the above example, the points array will contain 32 points spread-out across
the length of line, where the position of each point is determined by the Sine.out
ease function.
You can optionally provide a collinear threshold. In this case, the resulting points
are checked against each other, and if they are < collinearThreshold distance apart,
they are dropped from the results. This can help avoid lots of clustered points at
far ends of the line with tightly-packed eases such as Quartic. Leave the value set
to zero to skip this check.
Note that if you provide a collinear threshold, the resulting array may not always
contain quantity points.
The Line object.
The ease to use. This can be either a string from the EaseMap, or a custom function.
The number of points to return. Note that if you provide a collinearThreshold, the resulting array may not always contain this number of points.
OptionalcollinearThreshold: numberAn optional threshold. The final array is reduced so that each point is spaced out at least this distance apart. This helps reduce clustering in noisey eases. Default 0.
OptionaleaseParams: number[]An optional array of ease parameters to go with the ease.
StaticGetStaticGetGet the nearest point on a line perpendicular to the given point.
StaticGetStaticGetGet a point on a line that's a given percentage along its length.
StaticGetGet a number of points along a line's length.
Provide a quantity to get an exact number of points along the line.
Provide a stepRate to ensure a specific distance between each point on the line. Set quantity to 0 when
providing a stepRate.
See also GetEasedPoints for a way to distribute the points across the line according to an ease type or input function.
The line.
The number of points to place on the line. Set to 0 to use stepRate instead.
OptionalstepRate: numberThe distance between each point on the line. When set, quantity is implied and should be set to 0.
Optionalout: OAn optional array of Vector2 objects to store the coordinates of the points on the line.
StaticGetGet the shortest distance from a Line to the given Point.
The line to get the distance from.
The point to get the shortest distance to.
StaticHeightStaticLengthStaticNormalStaticNormalStaticNormalStaticOffsetStaticPerpStaticRandomStaticReflectStaticRotateStaticRotateStaticRotateRotate a line around the given coordinates by the given angle in radians.
The line to rotate.
The horizontal coordinate to rotate the line around.
The vertical coordinate to rotate the line around.
The angle of rotation in radians.
StaticSetStaticSlopeStaticWidth
Defines a Line segment, a part of a line between two endpoints.