Phaser API Documentation

  Version: 
Filter

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.

Constructor:

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

Parameters:

name type arguments description
x number <optional>

The x position of the center of the ellipse.

y number <optional>

The y position of the center of the ellipse.

width number <optional>

The width of the ellipse.

height number <optional>

The height of the ellipse.

Since: 3.0.0

Members

bottom: number
Focus
Focus

Description:

The bottom position of the Ellipse.

Type:
number
Since: 3.0.0
Focus
Focus
height: number
Focus
Focus

Description:

The height of the ellipse.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
left: number
Focus
Focus

Description:

The left position of the Ellipse.

Type:
number
Since: 3.0.0
Focus
Focus
top: number
Focus
Focus

Description:

The top position of the Ellipse.

Type:
number
Since: 3.0.0
Focus
Focus
<readonly> type: number
Focus
Focus

Description:

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

Type:
number
Since: 3.19.0
Focus
Focus
width: number
Focus
Focus

Description:

The width of the ellipse.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
x: number
Focus
Focus

Description:

The x position of the center of the ellipse.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
y: number
Focus
Focus

Description:

The y position of the center of the ellipse.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus

Methods

contains(x, y)
Focus
Focus

Description:

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.

Returns:
Description:

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

Type:
  • boolean
Since: 3.0.0
Focus
Focus
getMajorRadius()
Focus
Focus

Description:

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

Returns:
Description:

The major radius.

Type:
  • number
Since: 3.0.0
Focus
Focus
getMinorRadius()
Focus
Focus

Description:

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

Returns:
Description:

The minor radius.

Type:
  • number
Since: 3.0.0
Focus
Focus
getPoint(position, [out])
Focus
Focus

Description:

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 arguments 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 object | Phaser.Geom.Point <optional>

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

Returns:
Description:

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

Type:
Since: 3.0.0
Focus
Focus
getPoints(quantity, [stepRate], [output])
Focus
Focus

Description:

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 arguments 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.

Returns:
Description:

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

Type:
Since: 3.0.0
Focus
Focus
getRandomPoint([point])
Focus
Focus

Description:

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

Parameters:

name type arguments description
point object | Phaser.Geom.Point <optional>

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

Returns:
Description:

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

Type:
Since: 3.0.0
Focus
Focus
isEmpty()
Focus
Focus

Description:

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

Returns:
Description:

True if the Ellipse is empty, otherwise false.

Type:
  • boolean
Since: 3.0.0
Focus
Focus
setEmpty()
Focus
Focus

Description:

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

Returns:
Description:

This Ellipse object.

Since: 3.0.0
Focus
Focus
setPosition(x, y)
Focus
Focus

Description:

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.

Returns:
Description:

This Ellipse object.

Since: 3.0.0
Focus
Focus
setSize(width, [height])
Focus
Focus

Description:

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

Parameters:

name type arguments Default description
width number

The width of the ellipse.

height number <optional> width

The height of the ellipse.

Returns:
Description:

This Ellipse object.

Since: 3.0.0
Focus
Focus
setTo(x, y, width, height)
Focus
Focus

Description:

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.

Returns:
Description:

This Ellipse object.

Since: 3.0.0
Focus
Focus
<static> Area(ellipse)
Focus
Focus

Description:

Calculates the area of the Ellipse.

Parameters:

name type description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the area of.

Returns:
Description:

The area of the Ellipse.

Type:
  • number
Since: 3.0.0
Source: src/geom/ellipse/Area.js (Line 7)
Focus
Focus
<static> Circumference(ellipse)
Focus
Focus

Description:

Returns the circumference of the given Ellipse.

Parameters:

name type description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the circumference of.

Returns:
Description:

The circumference of th Ellipse.

Type:
  • number
Since: 3.0.0
Focus
Focus
<static> CircumferencePoint(ellipse, angle, [out])
Focus
Focus

Description:

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

Parameters:

name type arguments 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 object | Phaser.Geom.Point <optional>

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

Returns:
Description:

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

Type:
Since: 3.0.0
Focus
Focus
<static> Clone(source)
Focus
Focus

Description:

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.

Returns:
Description:

A clone of the source Ellipse.

Since: 3.0.0
Source: src/geom/ellipse/Clone.js (Line 9)
Focus
Focus
<static> Contains(ellipse, x, y)
Focus
Focus

Description:

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.

Returns:
Description:

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

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> ContainsPoint(ellipse, point)
Focus
Focus

Description:

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

Parameters:

name type description
ellipse Phaser.Geom.Ellipse

The Ellipse to check.

point object | Phaser.Geom.Point

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

Returns:
Description:

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

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> ContainsRect(ellipse, rect)
Focus
Focus

Description:

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 object | Phaser.Geom.Rectangle

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

Returns:
Description:

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

Type:
  • boolean
Since: 3.0.0
Focus
Focus
<static> CopyFrom(source, dest)
Focus
Focus

Description:

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.

Returns:
Description:

The destination Ellipse.

Since: 3.0.0
Focus
Focus
<static> Equals(ellipse, toCompare)
Focus
Focus

Description:

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.

Returns:
Description:

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

Type:
  • boolean
Since: 3.0.0
Source: src/geom/ellipse/Equals.js (Line 7)
Focus
Focus
<static> GetBounds(ellipse, [out])
Focus
Focus

Description:

Returns the bounds of the Ellipse object.

Parameters:

name type arguments description
ellipse Phaser.Geom.Ellipse

The Ellipse to get the bounds from.

out object | Phaser.Geom.Rectangle <optional>

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

Returns:
Description:

The Rectangle object containing the Ellipse bounds.

Type:
Since: 3.0.0
Focus
Focus
<static> GetPoint(ellipse, position, [out])
Focus
Focus

Description:

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 arguments 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 object | Phaser.Geom.Point <optional>

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

Returns:
Description:

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

Type:
Since: 3.0.0
Focus
Focus
<static> GetPoints(ellipse, quantity, [stepRate], [out])
Focus
Focus

Description:

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 arguments 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.

Returns:
Description:

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

Type:
Since: 3.0.0
Focus
Focus
<static> Offset(ellipse, x, y)
Focus
Focus

Description:

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.

Returns:
Description:

The Ellipse that was offset.

Since: 3.0.0
Source: src/geom/ellipse/Offset.js (Line 7)
Focus
Focus
<static> OffsetPoint(ellipse, point)
Focus
Focus

Description:

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 object | Phaser.Geom.Point

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

Returns:
Description:

The Ellipse that was offset.

Since: 3.0.0
Focus
Focus
<static> Random(ellipse, [out])
Focus
Focus

Description:

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

Parameters:

name type arguments description
ellipse Phaser.Geom.Ellipse

The Ellipse to get a random point from.

out object | Phaser.Geom.Point <optional>

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

Returns:
Description:

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

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