new Circle( [x] [, y] [, radius])
Parameters:
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
x |
number |
<optional> |
0 | The x position of the center of the circle. |
y |
number |
<optional> |
0 | The y position of the center of the circle. |
radius |
number |
<optional> |
0 | The radius of the circle. |
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 14)
Members
-
bottom :number
-
The bottom position of the Circle.
Type:
- number
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 346)
-
diameter :number
-
The diameter of the Circle.
Type:
- number
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 261)
-
left :number
-
The left position of the Circle.
Type:
- number
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 283)
-
radius :number
-
The radius of the Circle.
Type:
- number
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 239)
-
right :number
-
The right position of the Circle.
Type:
- number
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 304)
-
top :number
-
The top position of the Circle.
Type:
- number
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 325)
-
<readonly> type :number
-
The geometry constant type of this object:
GEOM_CONST.CIRCLE. Used for fast type comparisons.Type:
- number
- Since: 3.19.0
- Source: src/geom/circle/Circle.js (Line 41)
-
x :number
-
The x position of the center of the circle.
Type:
- number
- Since: 3.0.0
- Default Value:
-
- 0
- Source: src/geom/circle/Circle.js (Line 52)
-
y :number
-
The y position of the center of the circle.
Type:
- number
- Since: 3.0.0
- Default Value:
-
- 0
- Source: src/geom/circle/Circle.js (Line 62)
Methods
-
<static> Area(circle)
-
Calculates the area of the circle.
Parameters:
Name Type Description circlePhaser.Geom.Circle The Circle to get the area of.
- Since: 3.0.0
- Source: src/geom/circle/Area.js (Line 7)
Returns:
The area of the Circle.
- Type
- number
-
<static> Circumference(circle)
-
Returns the circumference of the given Circle.
Parameters:
Name Type Description circlePhaser.Geom.Circle The Circle to get the circumference of.
- Since: 3.0.0
- Source: src/geom/circle/Circumference.js (Line 7)
Returns:
The circumference of the Circle.
- Type
- number
-
<static> CircumferencePoint(circle, angle [, out])
-
Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
Parameters:
Name Type Argument Description circlePhaser.Geom.Circle The Circle to get the circumference point on.
anglenumber The angle from the center of the Circle to the circumference to return the point from. Given in radians.
outPhaser.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/circle/CircumferencePoint.js (Line 9)
Returns:
A Point object where the
xandyproperties are the point on the circumference.- Type
- Phaser.Geom.Point | object
-
<static> Clone(source)
-
Creates a new Circle instance based on the values contained in the given source.
Parameters:
Name Type Description sourcePhaser.Geom.Circle | object The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties.
- Since: 3.0.0
- Source: src/geom/circle/Clone.js (Line 9)
Returns:
A clone of the source Circle.
- Type
- Phaser.Geom.Circle
-
<static> Contains(circle, x, y)
-
Check to see if the Circle contains the given x / y coordinates.
Parameters:
Name Type Description circlePhaser.Geom.Circle The Circle to check.
xnumber The x coordinate to check within the circle.
ynumber The y coordinate to check within the circle.
- Since: 3.0.0
- Source: src/geom/circle/Contains.js (Line 7)
Returns:
True if the coordinates are within the circle, otherwise false.
- Type
- boolean
-
<static> ContainsPoint(circle, point)
-
Check to see if the Circle contains the given Point object.
Parameters:
Name Type Description circlePhaser.Geom.Circle The Circle to check.
pointPhaser.Geom.Point | object The Point object to check if it's within the Circle or not.
- Since: 3.0.0
- Source: src/geom/circle/ContainsPoint.js (Line 9)
Returns:
True if the Point coordinates are within the circle, otherwise false.
- Type
- boolean
-
<static> ContainsRect(circle, rect)
-
Check to see if the Circle contains all four points of the given Rectangle object.
Parameters:
Name Type Description circlePhaser.Geom.Circle The Circle to check.
rectPhaser.Geom.Rectangle | object The Rectangle object to check if it's within the Circle or not.
- Since: 3.0.0
- Source: src/geom/circle/ContainsRect.js (Line 9)
Returns:
True if all of the Rectangle coordinates are within the circle, otherwise false.
- Type
- boolean
-
<static> CopyFrom(source, dest)
-
Copies the
x,yandradiusproperties from thesourceCircle into the givendestCircle, then returns thedestCircle.Parameters:
Name Type Description sourcePhaser.Geom.Circle The source Circle to copy the values from.
destPhaser.Geom.Circle The destination Circle to copy the values to.
- Since: 3.0.0
- Source: src/geom/circle/CopyFrom.js (Line 7)
Returns:
The destination Circle.
- Type
- Phaser.Geom.Circle
-
<static> Equals(circle, toCompare)
-
Compares the
x,yandradiusproperties of the two given Circles. Returnstrueif they all match, otherwise returnsfalse.Parameters:
Name Type Description circlePhaser.Geom.Circle The first Circle to compare.
toComparePhaser.Geom.Circle The second Circle to compare.
- Since: 3.0.0
- Source: src/geom/circle/Equals.js (Line 7)
Returns:
trueif the two Circles equal each other, otherwisefalse.- Type
- boolean
-
<static> GetBounds(circle [, out])
-
Returns the bounds of the Circle object.
Parameters:
Name Type Argument Description circlePhaser.Geom.Circle The Circle to get the bounds from.
outPhaser.Geom.Rectangle | object <optional>
A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created.
- Since: 3.0.0
- Source: src/geom/circle/GetBounds.js (Line 9)
Returns:
The Rectangle object containing the Circles bounds.
- Type
- Phaser.Geom.Rectangle | object
-
<static> GetPoint(circle, position [, out])
-
Returns a Point object containing the coordinates of a point on the circumference of the Circle 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 circlePhaser.Geom.Circle The Circle to get the circumference point on.
positionnumber A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle.
outPhaser.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/circle/GetPoint.js (Line 12)
Returns:
A Point, or point-like object, containing the coordinates of the point around the circle.
- Type
- Phaser.Geom.Point | object
-
<static> GetPoints(circle, quantity [, stepRate] [, output])
-
Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, based on the given quantity or stepRate values.
Parameters:
Name Type Argument Description circlePhaser.Geom.Circle The Circle to get the points from.
quantitynumber The amount of points to return. If a falsey value the quantity will be derived from the
stepRateinstead.stepRatenumber <optional>
Sets the quantity by getting the circumference of the circle and dividing it by the stepRate.
outputarray <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/circle/GetPoints.js (Line 12)
Returns:
An array of Point objects pertaining to the points around the circumference of the circle.
- Type
- Array.<Phaser.Geom.Point>
-
<static> Offset(circle, x, y)
-
Offsets the Circle by the values given.
Parameters:
Name Type Description circlePhaser.Geom.Circle The Circle to be offset (translated.)
xnumber The amount to horizontally offset the Circle by.
ynumber The amount to vertically offset the Circle by.
- Since: 3.0.0
- Source: src/geom/circle/Offset.js (Line 7)
Returns:
The Circle that was offset.
- Type
- Phaser.Geom.Circle
-
<static> OffsetPoint(circle, point)
-
Offsets the Circle by the values given in the
xandyproperties of the Point object.Parameters:
Name Type Description circlePhaser.Geom.Circle The Circle to be offset (translated.)
pointPhaser.Geom.Point | object The Point object containing the values to offset the Circle by.
- Since: 3.0.0
- Source: src/geom/circle/OffsetPoint.js (Line 7)
Returns:
The Circle that was offset.
- Type
- Phaser.Geom.Circle
-
<static> Random(circle [, out])
-
Returns a uniformly distributed random point from anywhere within the given Circle.
Parameters:
Name Type Argument Description circlePhaser.Geom.Circle The Circle to get a random point from.
outPhaser.Geom.Point | object <optional>
A Point or point-like object to set the random
xandyvalues in.- Since: 3.0.0
- Source: src/geom/circle/Random.js (Line 9)
Returns:
A Point object with the random values set in the
xandyproperties.- Type
- Phaser.Geom.Point | object
-
contains(x, y)
-
Check to see if the Circle contains the given x / y coordinates.
Parameters:
Name Type Description xnumber The x coordinate to check within the circle.
ynumber The y coordinate to check within the circle.
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 93)
Returns:
True if the coordinates are within the circle, otherwise false.
- Type
- boolean
-
getPoint(position [, out])
-
Returns a Point object containing the coordinates of a point on the circumference of the Circle 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 positionnumber A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle.
outPhaser.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/circle/Circle.js (Line 109)
Returns:
A Point, or point-like object, containing the coordinates of the point around the circle.
- 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 Circle, based on the given quantity or stepRate values.
Parameters:
Name Type Argument Description quantitynumber The amount of points to return. If a falsey value the quantity will be derived from the
stepRateinstead.stepRatenumber <optional>
Sets the quantity by getting the circumference of the circle and dividing it by the stepRate.
outputarray | 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/circle/Circle.js (Line 129)
Returns:
An array of Point objects pertaining to the points around the circumference of the circle.
- Type
- array | Array.<Phaser.Geom.Point>
-
getRandomPoint( [point])
-
Returns a uniformly distributed random point from anywhere within the Circle.
Parameters:
Name Type Argument Description pointPhaser.Geom.Point | object <optional>
A Point or point-like object to set the random
xandyvalues in.- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 149)
Returns:
A Point object with the random values set in the
xandyproperties.- Type
- Phaser.Geom.Point | object
-
isEmpty()
-
Checks to see if the Circle is empty: has a radius of zero.
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 226)
Returns:
True if the Circle is empty, otherwise false.
- Type
- boolean
-
setEmpty()
-
Sets this Circle to be empty with a radius of zero. Does not change its position.
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 188)
Returns:
This Circle object.
- Type
- Phaser.Geom.Circle
-
setPosition( [x] [, y])
-
Sets the position of this Circle.
Parameters:
Name Type Argument Default Description xnumber <optional>
0 The x position of the center of the circle.
ynumber <optional>
0 The y position of the center of the circle.
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 205)
Returns:
This Circle object.
- Type
- Phaser.Geom.Circle
-
setTo( [x] [, y] [, radius])
-
Sets the x, y and radius of this circle.
Parameters:
Name Type Argument Default Description xnumber <optional>
0 The x position of the center of the circle.
ynumber <optional>
0 The y position of the center of the circle.
radiusnumber <optional>
0 The radius of the circle.
- Since: 3.0.0
- Source: src/geom/circle/Circle.js (Line 166)
Returns:
This Circle object.
- Type
- Phaser.Geom.Circle
