Skip to main content
Version: Phaser v4.0.0

QuadraticBezier

A quadratic Bézier curve constructed from three points: a start point, a single control point, and an end point. This is a second-degree Bézier curve, where the control point influences the curvature of the path between the start and end points.

Constructor

new QuadraticBezier(p0, p1, p2)

Parameters

nametypeoptionaldescription
p0Phaser.Math.Vector2 | Array.<number>NoStart point, or an array of point pairs.
p1Phaser.Math.Vector2NoControl Point 1.
p2Phaser.Math.Vector2NoThe end point of the curve.

Scope: static

Extends

Phaser.Curves.Curve

Source: src/curves/QuadraticBezierCurve.js#L12
Since: 3.2.0

Inherited Members

From Phaser.Curves.Curve:


Public Members

p0

p0: Phaser.Math.Vector2

Description:

The start point.

Source: src/curves/QuadraticBezierCurve.js#L45
Since: 3.2.0


p1

p1: Phaser.Math.Vector2

Description:

The first control point.

Source: src/curves/QuadraticBezierCurve.js#L54
Since: 3.2.0


p2

p2: Phaser.Math.Vector2

Description:

The end point of the curve.

Source: src/curves/QuadraticBezierCurve.js#L63
Since: 3.2.0


Inherited Methods

From Phaser.Curves.Curve:


Public Methods

draw

<instance> draw(graphics, [pointsTotal])

Description:

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 on-top of anything else already rendered to it.

Tags:

  • generic

Parameters:

nametypeoptionaldefaultdescription
graphicsPhaser.GameObjects.GraphicsNoGraphics object to draw onto.
pointsTotalnumberYes32Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing.

Overrides: Phaser.Curves.Curve#draw

Returns: Phaser.GameObjects.Graphics - Graphics object that was drawn to.

Source: src/curves/QuadraticBezierCurve.js#L134
Since: 3.2.0


fromJSON

<static> fromJSON(data)

Description:

Creates a curve from a JSON object, e.g. created by toJSON.

Parameters:

nametypeoptionaldescription
dataPhaser.Types.Curves.JSONCurveNoThe JSON object containing this curve data.

Returns: Phaser.Curves.QuadraticBezier - The created curve instance.

Source: src/curves/QuadraticBezierCurve.js#L192
Since: 3.2.0


getPoint

<instance> getPoint(t, [out])

Description:

Get point at relative position in curve according to length.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
tnumberNoThe position along the curve to return. Where 0 is the start and 1 is the end.
outPhaser.Math.Vector2YesA Vector2 object to store the result in. If not given will be created.

Returns: Phaser.Math.Vector2 - The coordinates of the point on the curve. If an out object was given this will be returned.

Source: src/curves/QuadraticBezierCurve.js#L107
Since: 3.2.0


getResolution

<instance> getResolution(divisions)

Description:

Returns the resolution of this curve. For a Quadratic Bezier, the resolution is equal to the number of divisions requested.

Parameters:

nametypeoptionaldescription
divisionsnumberNoOptional divisions value.

Returns: number - The curve resolution.

Source: src/curves/QuadraticBezierCurve.js#L92
Since: 3.2.0


getStartPoint

<instance> getStartPoint([out])

Description:

Gets the starting point on the curve.

Tags:

  • generic

Parameters:

nametypeoptionaldescription
outPhaser.Math.Vector2YesA Vector2 object to store the result in. If not given will be created.

Overrides: Phaser.Curves.Curve#getStartPoint

Returns: Phaser.Math.Vector2 - The coordinates of the point on the curve. If an out object was given this will be returned.

Source: src/curves/QuadraticBezierCurve.js#L73
Since: 3.2.0


toJSON

<instance> toJSON()

Description:

Converts the curve into a JSON compatible object.

Returns: Phaser.Types.Curves.JSONCurve - The JSON object containing this curve data.

Source: src/curves/QuadraticBezierCurve.js#L170
Since: 3.2.0