A quadratic BÃ©zier curve constructed from two control points.
new QuadraticBezier(p0, p1, p2)
name  type  description 

p0  Array.<number>  Phaser.Math.Vector2 
Start point, or an array of point pairs. 
p1  Phaser.Math.Vector2 
Control Point 1. 
p2  Phaser.Math.Vector2 
Control Point 2. 
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 start point.
The first control point.
The second control point.
String based identifier for the type of curve.
Draws this curve on the given Graphics object.
The curve is drawn using Graphics.strokePoints
so will be drawn at whatever the present Graphics stroke color is.
The Graphics object is not cleared before the draw, so the curve will appear ontop of anything else already rendered to it.
name  type  arguments  Default  description 

graphics  Phaser.GameObjects.Graphics 


pointsTotal  number  <optional>  32 
Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. 
Graphics
object that was drawn to.
Returns a Rectangle where the position and dimensions match the bounds of this Curve.
You can control the accuracy of the bounds. The value given is used to work out how many points to plot across the curve. Higher values are more accurate at the cost of calculation speed.
name  type  arguments  Default  description 

out  Phaser.Geom.Rectangle  <optional> 
The Rectangle to store the bounds in. If falsey a new object will be created. 

accuracy  number  <optional>  16 
The accuracy of the bounds calculations. 
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.
Get a point at a relative position on the curve, by arc length.
name  type  arguments  description 

u  number 
The relative position, [0..1]. 

out  Phaser.Math.Vector2  <optional> 
A point to store the result in. 
The point.
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.
Get the resolution of the curve.
name  type  description 

divisions  number 
Optional divisions value. 
The curve resolution.
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.
Get a unit vector tangent at a relative position on the curve. In case any sub curve does not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation
name  type  arguments  description 

t  number 
The relative position on the curve, [0..1]. 

out  Phaser.Math.Vector2  <optional> 
A vector to store the result in. 
Vector approximating the tangent line at the point t (delta +/ 0.0001)
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.
Converts the curve into a JSON compatible object.
The JSON object containing this curve data.
Calculate and cache the arc lengths.
Creates a curve from a JSON object, e. g. created by toJSON
.
name  type  description 

data  Phaser.Types.Curves.JSONCurve 
The JSON object containing this curve data. 
The created curve instance.