Circle.js
Circle ⇐ Impacto.GameObjects.GameObject2D
Circle is a class that will draw a circle on the canvas.
Kind: global class
Extends: Impacto.GameObjects.GameObject2D
Constructors:
- Circle ⇐
Impacto.GameObjects.GameObject2D
- new Circle(x, y, [radius], [fillColor], [strokeColor])
- .x
- .y
- .x ⇒
number
- .y ⇒
number
- .setRadius(radius) ⇒
Circle
- .getTop() ⇒
number
- .getBottom() ⇒
number
- .getLeft() ⇒
number
- .getRight() ⇒
number
- .getCenterX() ⇒
number
- .getCenterY() ⇒
number
- .getRealTop() ⇒
number
- .getRealBottom() ⇒
number
- .getRealLeft() ⇒
number
- .getRealRight() ⇒
number
- .getRealCenterX() ⇒
number
- .getRealCenterY() ⇒
number
- .getBounds() ⇒
Object
new Circle(x, y, [radius], [fillColor], [strokeColor])
Param | Type | Default | Description |
---|---|---|---|
x | number | The horizontal position of this Circle in the world. | |
y | number | The vertical position of this Circle in the world. | |
[radius] | number | 10 | The radius of this Circle. |
[fillColor] | number | string | 0xffffff | The color the Circle will be filled with, i.e. 0xff0000 for red. |
[strokeColor] | number | string | 0x000000 | The color of the border of the Circle, i.e. 0x00ff00 for green. |
Example
const circ = new Impacto.GameObjects.Circle(400, 300, 50, "#ff0000", 0x00ff00);
Circle.x
Sets the X position of the Circle.
Kind: static property of Circle
Param | Type | Description |
---|---|---|
x | number | The horizontal position of this Circle in the world. |
Example
circ.x = 100;
Circle.y
Sets the Y position of the Circle.
Kind: static property of Circle
Param | Type | Description |
---|---|---|
y | number | The vertical position of this Circle in the world. |
Example
circ.y = 100;
Circle.x ⇒ number
Kind: static property of Circle
Returns: number
-
The horizontal position of this Circle in the world relative to the origin.
Circle.y ⇒ number
Kind: static property of Circle
Returns: number
-
The vertical position of this Circle in the world relative to the origin.
Circle.setRadius(radius) ⇒ Circle
Sets the radius of the Circle.
Kind: static method of Circle
Returns: Circle
-
This Circle.
Param | Type | Description |
---|---|---|
radius | number | The radius of this Circle. |
Example
new Impacto.GameObjects.Circle(400, 300, 50).setRadius(100); // 100
Circle.getTop() ⇒ number
Returns the top side position of the Circle.
Kind: static method of Circle
Returns: number
-
The vertical position of this Circle in the world relative to the origin.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getTop(); // 275
Circle.getBottom() ⇒ number
Returns the bottom side position of the Circle.
Kind: static method of Circle
Returns: number
-
The vertical position of this Circle in the world relative to the origin.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getBottom(); // 325
Circle.getLeft() ⇒ number
Returns the left side position of the Circle.
Kind: static method of Circle
Returns: number
-
The horizontal position of this Circle in the world relative to the origin.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getLeft(); // 375
Circle.getRight() ⇒ number
Returns the right side position of the Circle.
Kind: static method of Circle
Returns: number
-
The horizontal position of this Circle in the world relative to the origin.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getRight(); // 425
Circle.getCenterX() ⇒ number
Returns the center X position of the Circle.
Kind: static method of Circle
Returns: number
-
The horizontal position of this Circle in the world relative to the origin.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getCenterX(); // 400
Circle.getCenterY() ⇒ number
Returns the center Y position of the Circle.
Kind: static method of Circle
Returns: number
-
The vertical position of this Circle in the world relative to the origin.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getCenterY(); // 300
Circle.getRealTop() ⇒ number
Returns the real top side position of the Circle (not relative to the origin).
Kind: static method of Circle
Returns: number
-
The vertical position of this Circle in the world.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getRealTop(); // 275
Circle.getRealBottom() ⇒ number
Returns the real bottom side position of the Circle (not relative to the origin).
Kind: static method of Circle
Returns: number
-
The vertical position of this Circle in the world.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getRealBottom(); // 325
Circle.getRealLeft() ⇒ number
Returns the real left side position of the Circle (not relative to the origin).
Kind: static method of Circle
Returns: number
-
The horizontal position of this Circle in the world.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getRealLeft(); // 375
Circle.getRealRight() ⇒ number
Returns the real right side position of the Circle (not relative to the origin).
Kind: static method of Circle
Returns: number
-
The horizontal position of this Circle in the world.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getRealRight(); // 425
Circle.getRealCenterX() ⇒ number
Returns the real center X position of the Circle (not relative to the origin).
Kind: static method of Circle
Returns: number
-
The horizontal position of this Circle in the world.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getRealCenterX(); // 400
Circle.getRealCenterY() ⇒ number
Returns the real center Y position of the Circle (not relative to the origin).
Kind: static method of Circle
Returns: number
-
The vertical position of this Circle in the world.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getRealCenterY(); // 300
Circle.getBounds() ⇒ Object
Returns a box that encloses the Circle.
Kind: static method of Circle
Returns: Object
-
A box that encloses the Circle.
Example
new Impacto.GameObjects.Circle(400, 300, 50).getBounds(); // { x: 375, y: 275, width: 150, height: 150 }