Class: Ellipse

Phaser.Geom. Ellipse

An Ellipse object.

This is a geometry object, containing numerical values and related methods to inspect and modify them. It is not a Game Object, in that you cannot add it to the display list, and it has no texture. To render an Ellipse you should look at the capabilities of the Graphics class.


new Ellipse( [x] [, y] [, width] [, height])

Parameters:
Name Type Argument Default Description
x number <optional>
0

The x position of the center of the ellipse.

y number <optional>
0

The y position of the center of the ellipse.

width number <optional>
0

The width of the ellipse.

height number <optional>
0

The height of the ellipse.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 14)

Members


bottom :number

The bottom position of the Ellipse.

Type:
  • number
Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 353)

height :number

The height of the ellipse.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/geom/ellipse/Ellipse.js (Line 84)

left :number

The left position of the Ellipse.

Type:
  • number
Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 290)

The right position of the Ellipse.

Type:
  • number
Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 311)

top :number

The top position of the Ellipse.

Type:
  • number
Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 332)

<readonly> type :number

The geometry constant type of this object: GEOM_CONST.ELLIPSE. Used for fast type comparisons.

Type:
  • number
Since: 3.19.0
Source: src/geom/ellipse/Ellipse.js (Line 43)

width :number

The width of the ellipse.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/geom/ellipse/Ellipse.js (Line 74)

x :number

The x position of the center of the ellipse.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/geom/ellipse/Ellipse.js (Line 54)

y :number

The y position of the center of the ellipse.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/geom/ellipse/Ellipse.js (Line 64)

Methods


<static> Area(ellipse)

Calculates the area of the Ellipse.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the area of.

Since: 3.0.0
Source: src/geom/ellipse/Area.js (Line 7)
Returns:

The area of the Ellipse.

Type
number

<static> Circumference(ellipse)

Returns the circumference of the given Ellipse.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the circumference of.

Since: 3.0.0
Source: src/geom/ellipse/Circumference.js (Line 7)
Returns:

The circumference of th Ellipse.

Type
number

<static> CircumferencePoint(ellipse, angle [, out])

Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle.

Parameters:
Name Type Argument Description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the circumference point on.

angle number

The angle from the center of the Ellipse to the circumference to return the point from. Given in radians.

out Phaser.Geom.Point | object <optional>

A Point, or point-like object, to store the results in. If not given a Point will be created.

Since: 3.0.0
Source: src/geom/ellipse/CircumferencePoint.js (Line 9)
Returns:

A Point object where the x and y properties are the point on the circumference.

Type
Phaser.Geom.Point | object

<static> Clone(source)

Creates a new Ellipse instance based on the values contained in the given source.

Parameters:
Name Type Description
source Phaser.Geom.Ellipse

The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties.

Since: 3.0.0
Source: src/geom/ellipse/Clone.js (Line 9)
Returns:

A clone of the source Ellipse.

Type
Phaser.Geom.Ellipse

<static> Contains(ellipse, x, y)

Check to see if the Ellipse contains the given x / y coordinates.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The Ellipse to check.

x number

The x coordinate to check within the ellipse.

y number

The y coordinate to check within the ellipse.

Since: 3.0.0
Source: src/geom/ellipse/Contains.js (Line 7)
Returns:

True if the coordinates are within the ellipse, otherwise false.

Type
boolean

<static> ContainsPoint(ellipse, point)

Check to see if the Ellipse contains the given Point object.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The Ellipse to check.

point Phaser.Geom.Point | object

The Point object to check if it's within the Circle or not.

Since: 3.0.0
Source: src/geom/ellipse/ContainsPoint.js (Line 9)
Returns:

True if the Point coordinates are within the circle, otherwise false.

Type
boolean

<static> ContainsRect(ellipse, rect)

Check to see if the Ellipse contains all four points of the given Rectangle object.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The Ellipse to check.

rect Phaser.Geom.Rectangle | object

The Rectangle object to check if it's within the Ellipse or not.

Since: 3.0.0
Source: src/geom/ellipse/ContainsRect.js (Line 9)
Returns:

True if all of the Rectangle coordinates are within the ellipse, otherwise false.

Type
boolean

<static> CopyFrom(source, dest)

Copies the x, y, width and height properties from the source Ellipse into the given dest Ellipse, then returns the dest Ellipse.

Parameters:
Name Type Description
source Phaser.Geom.Ellipse

The source Ellipse to copy the values from.

dest Phaser.Geom.Ellipse

The destination Ellipse to copy the values to.

Since: 3.0.0
Source: src/geom/ellipse/CopyFrom.js (Line 7)
Returns:

The destination Ellipse.

Type
Phaser.Geom.Ellipse

<static> Equals(ellipse, toCompare)

Compares the x, y, width and height properties of the two given Ellipses. Returns true if they all match, otherwise returns false.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The first Ellipse to compare.

toCompare Phaser.Geom.Ellipse

The second Ellipse to compare.

Since: 3.0.0
Source: src/geom/ellipse/Equals.js (Line 7)
Returns:

true if the two Ellipse equal each other, otherwise false.

Type
boolean

<static> GetBounds(ellipse [, out])

Returns the bounds of the Ellipse object.

Parameters:
Name Type Argument Description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the bounds from.

out Phaser.Geom.Rectangle | object <optional>

A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created.

Since: 3.0.0
Source: src/geom/ellipse/GetBounds.js (Line 9)
Returns:

The Rectangle object containing the Ellipse bounds.

Type
Phaser.Geom.Rectangle | object

<static> GetPoint(ellipse, position [, out])

Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point at 180 degrees around the circle.

Parameters:
Name Type Argument Description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the circumference point on.

position number

A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse.

out Phaser.Geom.Point | object <optional>

An object to store the return values in. If not given a Point object will be created.

Since: 3.0.0
Source: src/geom/ellipse/GetPoint.js (Line 12)
Returns:

A Point, or point-like object, containing the coordinates of the point around the ellipse.

Type
Phaser.Geom.Point | object

<static> GetPoints(ellipse, quantity [, stepRate] [, out])

Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, based on the given quantity or stepRate values.

Parameters:
Name Type Argument Description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the points from.

quantity number

The amount of points to return. If a falsey value the quantity will be derived from the stepRate instead.

stepRate number <optional>

Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate.

out array | Array.<Phaser.Geom.Point> <optional>

An array to insert the points in to. If not provided a new array will be created.

Since: 3.0.0
Source: src/geom/ellipse/GetPoints.js (Line 12)
Returns:

An array of Point objects pertaining to the points around the circumference of the ellipse.

Type
array | Array.<Phaser.Geom.Point>

<static> Offset(ellipse, x, y)

Offsets the Ellipse by the values given.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The Ellipse to be offset (translated.)

x number

The amount to horizontally offset the Ellipse by.

y number

The amount to vertically offset the Ellipse by.

Since: 3.0.0
Source: src/geom/ellipse/Offset.js (Line 7)
Returns:

The Ellipse that was offset.

Type
Phaser.Geom.Ellipse

<static> OffsetPoint(ellipse, point)

Offsets the Ellipse by the values given in the x and y properties of the Point object.

Parameters:
Name Type Description
ellipse Phaser.Geom.Ellipse

The Ellipse to be offset (translated.)

point Phaser.Geom.Point | object

The Point object containing the values to offset the Ellipse by.

Since: 3.0.0
Source: src/geom/ellipse/OffsetPoint.js (Line 7)
Returns:

The Ellipse that was offset.

Type
Phaser.Geom.Ellipse

<static> Random(ellipse [, out])

Returns a uniformly distributed random point from anywhere within the given Ellipse.

Parameters:
Name Type Argument Description
ellipse Phaser.Geom.Ellipse

The Ellipse to get a random point from.

out Phaser.Geom.Point | object <optional>

A Point or point-like object to set the random x and y values in.

Since: 3.0.0
Source: src/geom/ellipse/Random.js (Line 9)
Returns:

A Point object with the random values set in the x and y properties.

Type
Phaser.Geom.Point | object

contains(x, y)

Check to see if the Ellipse contains the given x / y coordinates.

Parameters:
Name Type Description
x number

The x coordinate to check within the ellipse.

y number

The y coordinate to check within the ellipse.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 95)
Returns:

True if the coordinates are within the ellipse, otherwise false.

Type
boolean

getMajorRadius()

Returns the major radius of the ellipse. Also known as the Semi Major Axis.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 277)
Returns:

The major radius.

Type
number

getMinorRadius()

Returns the minor radius of the ellipse. Also known as the Semi Minor Axis.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 264)
Returns:

The minor radius.

Type
number

getPoint(position [, out])

Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point at 180 degrees around the circle.

Parameters:
Name Type Argument Description
position number

A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse.

out Phaser.Geom.Point | object <optional>

An object to store the return values in. If not given a Point object will be created.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 111)
Returns:

A Point, or point-like object, containing the coordinates of the point around the ellipse.

Type
Phaser.Geom.Point | object

getPoints(quantity [, stepRate] [, output])

Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, based on the given quantity or stepRate values.

Parameters:
Name Type Argument Description
quantity number

The amount of points to return. If a falsey value the quantity will be derived from the stepRate instead.

stepRate number <optional>

Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate.

output array | Array.<Phaser.Geom.Point> <optional>

An array to insert the points in to. If not provided a new array will be created.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 131)
Returns:

An array of Point objects pertaining to the points around the circumference of the ellipse.

Type
array | Array.<Phaser.Geom.Point>

getRandomPoint( [point])

Returns a uniformly distributed random point from anywhere within the given Ellipse.

Parameters:
Name Type Argument Description
point Phaser.Geom.Point | object <optional>

A Point or point-like object to set the random x and y values in.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 151)
Returns:

A Point object with the random values set in the x and y properties.

Type
Phaser.Geom.Point | object

isEmpty()

Checks to see if the Ellipse is empty: has a width or height equal to zero.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 251)
Returns:

True if the Ellipse is empty, otherwise false.

Type
boolean

setEmpty()

Sets this Ellipse to be empty with a width and height of zero. Does not change its position.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 191)
Returns:

This Ellipse object.

Type
Phaser.Geom.Ellipse

setPosition(x, y)

Sets the position of this Ellipse.

Parameters:
Name Type Description
x number

The x position of the center of the ellipse.

y number

The y position of the center of the ellipse.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 208)
Returns:

This Ellipse object.

Type
Phaser.Geom.Ellipse

setSize(width [, height])

Sets the size of this Ellipse. Does not change its position.

Parameters:
Name Type Argument Default Description
width number

The width of the ellipse.

height number <optional>
width

The height of the ellipse.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 229)
Returns:

This Ellipse object.

Type
Phaser.Geom.Ellipse

setTo(x, y, width, height)

Sets the x, y, width and height of this ellipse.

Parameters:
Name Type Description
x number

The x position of the center of the ellipse.

y number

The y position of the center of the ellipse.

width number

The width of the ellipse.

height number

The height of the ellipse.

Since: 3.0.0
Source: src/geom/ellipse/Ellipse.js (Line 168)
Returns:

This Ellipse object.

Type
Phaser.Geom.Ellipse