new Line(p0, [p1])
name | type | arguments | description |
---|---|---|---|
p0 | Array.<number> | Phaser.Math.Vector2 |
The first endpoint. |
|
p1 | Phaser.Math.Vector2 | <optional> |
The second endpoint. |
For a curve on a Path, false
means the Path will ignore this curve.
The quantity of arc length divisions within the curve.
An array of cached arc length values.
The default number of divisions within the curve.
Does the data of this curve need updating?
The first endpoint.
The second endpoint.
String based identifier for the type of curve.
Draws this curve on the given Graphics object.
The curve is drawn using Graphics.lineBetween
so will be drawn at whatever the present Graphics line color is.
The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it.
name | type | description |
---|---|---|
graphics | Phaser.GameObjects.Graphics |
The Graphics instance onto which this curve will be drawn. |
The Graphics object to which the curve was drawn.
Returns a Rectangle where the position and dimensions match the bounds of this Curve.
name | type | arguments | description |
---|---|---|---|
out | Phaser.Geom.Rectangle | <optional> |
A Rectangle object to store the bounds in. If not given a new Rectangle will be created. |
A Rectangle object holding the bounds of this curve. If out
was given it will be this object.
Returns an array of points, spaced out X distance pixels apart. The smaller the distance, the larger the array will be.
name | type | description |
---|---|---|
distance | number |
The distance, in pixels, between each point along the curve. |
An Array of Point objects.
Get a point at the end of the curve.
name | type | arguments | description |
---|---|---|---|
out | Phaser.Math.Vector2 | <optional> |
Optional Vector object to store the result in. |
Vector2 containing the coordinates of the curves end point.
Get total curve arc length
The total length of the curve.
Get a list of cumulative segment lengths.
These lengths are
name | type | arguments | description |
---|---|---|---|
divisions | number | <optional> |
The number of divisions or segments. |
An array of cumulative lengths.
Get point at relative position in curve according to length.
name | type | arguments | description |
---|---|---|---|
t | number |
The position along the curve to return. Where 0 is the start and 1 is the end. |
|
out | Phaser.Math.Vector2 | <optional> |
A Vector2 object to store the result in. If not given will be created. |
The coordinates of the point on the curve. If an out
object was given this will be returned.
Gets a point at a given position on the line.
name | type | arguments | description |
---|---|---|---|
u | number |
The position along the curve to return. Where 0 is the start and 1 is the end. |
|
out | Phaser.Math.Vector2 | <optional> |
A Vector2 object to store the result in. If not given will be created. |
The coordinates of the point on the curve. If an out
object was given this will be returned.
Get a sequence of evenly spaced points from the curve.
You can pass divisions
, stepRate
, or neither.
The number of divisions will be
divisions
, if divisions
> 0; orthis.getLength / stepRate
, if stepRate
> 0; orthis.defaultDivisions
1 + divisions
points will be returned.
name | type | arguments | description |
---|---|---|---|
divisions | number | <optional> |
The number of divisions to make. |
stepRate | number | <optional> |
The curve distance between points, implying |
out | array | Array.<Phaser.Math.Vector2> | <optional> |
An optional array to store the points in. |
An array of Points from the curve.
Get a random point from the curve.
name | type | arguments | description |
---|---|---|---|
out | Phaser.Math.Vector2 | <optional> |
A point object to store the result in. |
The point.
Gets the resolution of the line.
name | type | arguments | Default | description |
---|---|---|---|---|
divisions | number | <optional> | 1 |
The number of divisions to consider. |
The resolution. Equal to the number of divisions.
Get a sequence of equally spaced points (by arc distance) from the curve.
1 + divisions
points will be returned.
name | type | arguments | Default | description |
---|---|---|---|---|
divisions | number | <optional> | this.defaultDivisions |
The number of divisions to make. |
stepRate | number | <optional> |
Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive. |
|
out | array | Array.<Phaser.Math.Vector2> | <optional> |
An optional array to store the points in. |
An array of points.
Gets the starting point on the curve.
name | type | arguments | description |
---|---|---|---|
out | Phaser.Math.Vector2 | <optional> |
A Vector2 object to store the result in. If not given will be created. |
The coordinates of the point on the curve. If an out
object was given this will be returned.
Given a distance in pixels, get a t to find p.
name | type | arguments | description |
---|---|---|---|
distance | number |
The distance, in pixels. |
|
divisions | number | <optional> |
Optional amount of divisions. |
The distance.
Gets the slope of the line as a unit vector.
name | type | arguments | description |
---|---|---|---|
t | number | <optional> |
The relative position on the line, [0..1]. |
out | Phaser.Math.Vector2 | <optional> |
A vector to store the result in. |
The tangent vector.
Get a unit vector tangent at a relative position on the curve, by arc length.
name | type | arguments | description |
---|---|---|---|
u | number |
The relative position on the curve, [0..1]. |
|
out | Phaser.Math.Vector2 | <optional> |
A vector to store the result in. |
The tangent vector.
Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant.
name | type | arguments | description |
---|---|---|---|
u | number |
A float between 0 and 1. |
|
distance | number |
The distance, in pixels. |
|
divisions | number | <optional> |
Optional amount of divisions. |
The equidistant value.
Gets a JSON representation of the line.
The JSON object containing this curve data.
Calculate and cache the arc lengths.
Configures this line from a JSON representation.
name | type | description |
---|---|---|
data | Phaser.Types.Curves.JSONCurve |
The JSON object containing this curve data. |
A new LineCurve object.