Class: Ellipse

Phaser.Curves. Ellipse

An Elliptical Curve derived from the Base Curve class.

See https://en.wikipedia.org/wiki/Elliptic_curve for more details.


new Ellipse( [x] [, y] [, xRadius] [, yRadius] [, startAngle] [, endAngle] [, clockwise] [, rotation])

Parameters:
Name Type Argument Default Description
x number | Phaser.Types.Curves.EllipseCurveConfig <optional>
0

The x coordinate of the ellipse, or an Ellipse Curve configuration object.

y number <optional>
0

The y coordinate of the ellipse.

xRadius number <optional>
0

The horizontal radius of ellipse.

yRadius number <optional>
0

The vertical radius of ellipse.

startAngle integer <optional>
0

The start angle of the ellipse, in degrees.

endAngle integer <optional>
360

The end angle of the ellipse, in degrees.

clockwise boolean <optional>
false

Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false)

rotation integer <optional>
0

The rotation of the ellipse, in degrees.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 16)

Extends

Members


active :boolean

[description]

Type:
  • boolean
Since: 3.0.0
Inherited From:
Default Value:
  • true
Source: src/curves/Curve.js (Line 80)

angle :number

The rotation of the ellipse, relative to the center, in degrees.

Type:
  • number
Since: 3.14.0
Source: src/curves/EllipseCurve.js (Line 536)

arcLengthDivisions :integer

The quantity of arc length divisions within the curve.

Type:
  • integer
Since: 3.0.0
Inherited From:
Default Value:
  • 100
Source: src/curves/Curve.js (Line 50)

cacheArcLengths :Array.<number>

An array of cached arc length values.

Type:
  • Array.<number>
Since: 3.0.0
Inherited From:
Default Value:
  • []
Source: src/curves/Curve.js (Line 60)

clockwise :boolean

true if the ellipse rotation is clockwise or false if anti-clockwise.

Type:
  • boolean
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 515)

defaultDivisions :integer

The default number of divisions within the curve.

Type:
  • integer
Since: 3.0.0
Inherited From:
Default Value:
  • 5
Source: src/curves/Curve.js (Line 40)

endAngle :number

The end angle of the ellipse in degrees.

Type:
  • number
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 494)

needsUpdate :boolean

Does the data of this curve need updating?

Type:
  • boolean
Since: 3.0.0
Inherited From:
Default Value:
  • true
Source: src/curves/Curve.js (Line 70)

p0 :Phaser.Math.Vector2

The center point of the ellipse. Used for calculating rotation.

Type:
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 71)

rotation :number

The rotation of the ellipse, relative to the center, in radians.

Type:
  • number
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 557)

startAngle :number

The start angle of the ellipse in degrees.

Type:
  • number
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 473)

type :string

String based identifier for the type of curve.

Type:
  • string
Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 31)

x :number

The x coordinate of the center of the ellipse.

Type:
  • number
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 389)

xRadius :number

The horizontal radius of the ellipse.

Type:
  • number
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 431)

y :number

The y coordinate of the center of the ellipse.

Type:
  • number
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 410)

yRadius :number

The vertical radius of the ellipse.

Type:
  • number
Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 452)

Methods


<static> fromJSON(data)

Creates a curve from the provided Ellipse Curve Configuration object.

Parameters:
Name Type Description
data Phaser.Types.Curves.JSONEllipseCurve

The JSON object containing this curve data.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 603)
Returns:

The ellipse curve constructed from the configuration object.

Type
Phaser.Curves.Ellipse

draw(graphics [, pointsTotal])

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.

Parameters:
Name Type Argument Default Description
graphics Phaser.GameObjects.Graphics

The Graphics instance onto which this curve will be drawn.

pointsTotal integer <optional>
32

The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance.

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 111)
Returns:

The Graphics object to which the curve was drawn.

Type
Phaser.GameObjects.Graphics

getBounds( [out] [, accuracy])

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.

Parameters:
Name Type Argument Default Description
out Phaser.Geom.Rectangle <optional>

The Rectangle to store the bounds in. If falsey a new object will be created.

accuracy integer <optional>
16

The accuracy of the bounds calculations.

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 135)
Returns:

A Rectangle object holding the bounds of this curve. If out was given it will be this object.

Type
Phaser.Geom.Rectangle

getDistancePoints(distance)

Returns an array of points, spaced out X distance pixels apart. The smaller the distance, the larger the array will be.

Parameters:
Name Type Description
distance integer

The distance, in pixels, between each point along the curve.

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 169)
Returns:

An Array of Point objects.

Type
Array.<Phaser.Geom.Point>

getEndPoint( [out])

[description]

Parameters:
Name Type Argument Description
out Phaser.Math.Vector2 <optional>

Optional Vector object to store the result in.

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 189)
Returns:

Vector2 containing the coordinates of the curves end point.

Type
Phaser.Math.Vector2

getLength()

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 208)
Returns:

[description]

Type
number

getLengths( [divisions])

[description]

Parameters:
Name Type Argument Description
divisions integer <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 225)
Returns:

[description]

Type
Array.<number>

getPoint(t [, out])

Get point at relative position in curve according to length.

Parameters:
Name Type Argument 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.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 177)
Returns:

The coordinates of the point on the curve. If an out object was given this will be returned.

Type
Phaser.Math.Vector2

getPointAt(u [, out])

[description]

Parameters:
Name Type Argument Description
u number

[description]

out Phaser.Math.Vector2 <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 273)
Returns:

[description]

Type
Phaser.Math.Vector2

getPoints( [divisions])

[description]

Parameters:
Name Type Argument Description
divisions integer <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 295)
Returns:

[description]

Type
Array.<Phaser.Math.Vector2>

getRandomPoint( [out])

[description]

Parameters:
Name Type Argument Description
out Phaser.Math.Vector2 <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 319)
Returns:

[description]

Type
Phaser.Math.Vector2

getResolution(divisions)

[description]

Parameters:
Name Type Description
divisions number

[description]

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 162)
Returns:

[description]

Type
number

getSpacedPoints( [divisions])

[description]

Parameters:
Name Type Argument Description
divisions integer <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 340)
Returns:

[description]

Type
Array.<Phaser.Math.Vector2>

getStartPoint( [out])

Gets the starting point on the curve.

Parameters:
Name Type Argument Description
out Phaser.Math.Vector2 <optional>

A Vector2 object to store the result in. If not given will be created.

Since: 3.0.0
Overrides:
Source: src/curves/EllipseCurve.js (Line 143)
Returns:

The coordinates of the point on the curve. If an out object was given this will be returned.

Type
Phaser.Math.Vector2

getTangent(t [, out])

[description]

Parameters:
Name Type Argument Description
t number

[description]

out Phaser.Math.Vector2 <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 390)
Returns:

Vector approximating the tangent line at the point t (delta +/- 0.0001)

Type
Phaser.Math.Vector2

getTangentAt(u [, out])

[description]

Parameters:
Name Type Argument Description
u number

[description]

out Phaser.Math.Vector2 <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 429)
Returns:

[description]

Type
Phaser.Math.Vector2

getTFromDistance(distance [, divisions])

[description]

Parameters:
Name Type Argument Description
distance integer

[description]

divisions integer <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 450)
Returns:

[description]

Type
number

getUtoTmapping(u, distance [, divisions])

[description]

Parameters:
Name Type Argument Description
u number

[description]

distance integer

[description]

divisions integer <optional>

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 473)
Returns:

[description]

Type
number

setClockwise(value)

Sets if this curve extends clockwise or anti-clockwise.

Parameters:
Name Type Description
value boolean

The clockwise state of this curve.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 355)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

setEndAngle(value)

Sets the end angle of this curve.

Parameters:
Name Type Description
value number

The end angle of this curve, in radians.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 338)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

setHeight(value)

Sets the height of this curve.

Parameters:
Name Type Description
value number

The height of this curve.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 304)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

setRotation(value)

Sets the rotation of this curve.

Parameters:
Name Type Description
value number

The rotation of this curve, in radians.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 372)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

setStartAngle(value)

Sets the start angle of this curve.

Parameters:
Name Type Description
value number

The start angle of this curve, in radians.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 321)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

setWidth(value)

Sets the width of this curve.

Parameters:
Name Type Description
value number

The width of this curve.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 287)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

setXRadius(value)

Sets the horizontal radius of this curve.

Parameters:
Name Type Description
value number

The horizontal radius of this curve.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 253)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

setYRadius(value)

Sets the vertical radius of this curve.

Parameters:
Name Type Description
value number

The vertical radius of this curve.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 270)
Returns:

This curve object.

Type
Phaser.Curves.Ellipse

toJSON()

JSON serialization of the curve.

Since: 3.0.0
Source: src/curves/EllipseCurve.js (Line 578)
Returns:

The JSON object containing this curve data.

Type
Phaser.Types.Curves.JSONEllipseCurve

updateArcLengths()

[description]

Since: 3.0.0
Inherited From:
Source: src/curves/Curve.js (Line 554)