@vpmedia/phaser 1.94.0 → 1.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/package.json +11 -11
- package/src/phaser/core/animation.js +79 -56
- package/src/phaser/core/animation_manager.js +55 -55
- package/src/phaser/core/animation_parser.js +2 -2
- package/src/phaser/core/cache.js +154 -154
- package/src/phaser/core/device.js +2 -1
- package/src/phaser/core/device_util.js +27 -27
- package/src/phaser/core/dom.js +43 -43
- package/src/phaser/core/event_manager.js +63 -63
- package/src/phaser/core/factory.js +47 -47
- package/src/phaser/core/frame.js +30 -30
- package/src/phaser/core/frame_data.js +30 -28
- package/src/phaser/core/frame_util.js +8 -8
- package/src/phaser/core/game.js +35 -19
- package/src/phaser/core/input_pointer.js +18 -0
- package/src/phaser/core/loader.js +171 -171
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scale_manager.js +3 -2
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +56 -52
- package/src/phaser/core/sound.js +54 -54
- package/src/phaser/core/sound_manager.js +49 -49
- package/src/phaser/core/stage.js +16 -16
- package/src/phaser/core/time.js +54 -30
- package/src/phaser/core/timer.js +82 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +106 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +32 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +72 -54
- package/src/phaser/display/button.js +48 -47
- package/src/phaser/display/canvas/buffer.js +8 -8
- package/src/phaser/display/canvas/graphics.js +8 -8
- package/src/phaser/display/canvas/masker.js +5 -5
- package/src/phaser/display/canvas/pool.js +18 -18
- package/src/phaser/display/canvas/renderer.js +17 -16
- package/src/phaser/display/canvas/tinter.js +22 -22
- package/src/phaser/display/canvas/util.js +42 -42
- package/src/phaser/display/display_object.js +119 -108
- package/src/phaser/display/graphics.js +129 -112
- package/src/phaser/display/graphics_data.js +10 -10
- package/src/phaser/display/graphics_data_util.js +3 -3
- package/src/phaser/display/group.js +63 -50
- package/src/phaser/display/image.js +68 -50
- package/src/phaser/display/sprite_batch.js +2 -2
- package/src/phaser/display/sprite_util.js +19 -19
- package/src/phaser/display/text.js +217 -187
- package/src/phaser/display/webgl/abstract_filter.js +4 -4
- package/src/phaser/display/webgl/base_texture.js +9 -9
- package/src/phaser/display/webgl/blend_manager.js +7 -7
- package/src/phaser/display/webgl/earcut.js +95 -95
- package/src/phaser/display/webgl/earcut_node.js +4 -4
- package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
- package/src/phaser/display/webgl/filter_manager.js +9 -9
- package/src/phaser/display/webgl/filter_texture.js +10 -10
- package/src/phaser/display/webgl/graphics.js +37 -37
- package/src/phaser/display/webgl/graphics_data.js +4 -4
- package/src/phaser/display/webgl/mask_manager.js +6 -6
- package/src/phaser/display/webgl/render_texture.js +16 -16
- package/src/phaser/display/webgl/renderer.js +21 -20
- package/src/phaser/display/webgl/shader/complex.js +4 -4
- package/src/phaser/display/webgl/shader/fast.js +4 -4
- package/src/phaser/display/webgl/shader/normal.js +8 -8
- package/src/phaser/display/webgl/shader/primitive.js +4 -4
- package/src/phaser/display/webgl/shader/strip.js +4 -4
- package/src/phaser/display/webgl/shader_manager.js +9 -9
- package/src/phaser/display/webgl/sprite_batch.js +18 -18
- package/src/phaser/display/webgl/stencil_manager.js +16 -16
- package/src/phaser/display/webgl/texture.js +13 -13
- package/src/phaser/display/webgl/texture_util.js +8 -8
- package/src/phaser/display/webgl/util.js +25 -25
- package/src/phaser/geom/circle.js +74 -69
- package/src/phaser/geom/ellipse.js +33 -28
- package/src/phaser/geom/line.js +96 -93
- package/src/phaser/geom/matrix.js +61 -54
- package/src/phaser/geom/point.js +99 -96
- package/src/phaser/geom/polygon.js +27 -22
- package/src/phaser/geom/rectangle.js +137 -132
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/util/math.js +81 -81
- package/types/phaser/core/animation.d.ts +79 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/animation_parser.d.ts +3 -2
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +51 -44
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -21
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +18 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +175 -172
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +1 -1
- package/types/phaser/core/scale_manager.d.ts +6 -5
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +54 -30
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +82 -64
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +106 -90
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +35 -67
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +76 -53
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/graphics.d.ts +3 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +6 -3
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +18 -17
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +6 -6
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +118 -102
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +59 -47
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +58 -45
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +237 -188
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +10 -10
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics.d.ts +2 -2
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +21 -20
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/display/webgl/texture_util.d.ts +4 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +74 -69
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +33 -28
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +96 -93
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +61 -54
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +99 -96
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +29 -23
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +137 -132
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/types/phaser/geom/util/point.d.ts +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/pnpm-workspace.yaml +0 -4
|
@@ -6,34 +6,39 @@ import { GEOM_CIRCLE } from '../core/const.js';
|
|
|
6
6
|
|
|
7
7
|
export class Circle {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {number} x -
|
|
11
|
-
* @param {number} y -
|
|
12
|
-
* @param {number} diameter -
|
|
9
|
+
* Creates a new Circle instance.
|
|
10
|
+
* @param {number} x - The x coordinate of the center point (default: 0).
|
|
11
|
+
* @param {number} y - The y coordinate of the center point (default: 0).
|
|
12
|
+
* @param {number} diameter - The diameter of the circle (default: 0).
|
|
13
13
|
*/
|
|
14
14
|
constructor(x = 0, y = 0, diameter = 0) {
|
|
15
|
+
/** @type {number} */
|
|
15
16
|
this.x = x;
|
|
17
|
+
/** @type {number} */
|
|
16
18
|
this.y = y;
|
|
19
|
+
/** @type {number} */
|
|
17
20
|
this._diameter = diameter;
|
|
21
|
+
/** @type {number} */
|
|
18
22
|
this._radius = 0;
|
|
19
23
|
if (diameter > 0) {
|
|
20
24
|
this._radius = diameter * 0.5;
|
|
21
25
|
}
|
|
26
|
+
/** @type {number} */
|
|
22
27
|
this.type = GEOM_CIRCLE;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @returns {number}
|
|
31
|
+
* Calculates the circumference of this circle.
|
|
32
|
+
* @returns {number} The circumference of this circle.
|
|
28
33
|
*/
|
|
29
34
|
circumference() {
|
|
30
35
|
return 2 * (Math.PI * this._radius);
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param {Point} output -
|
|
36
|
-
* @returns {Point}
|
|
39
|
+
* Returns a random point within this circle.
|
|
40
|
+
* @param {Point} output - The point to store the result in (optional).
|
|
41
|
+
* @returns {Point} A random point within this circle.
|
|
37
42
|
*/
|
|
38
43
|
random(output = null) {
|
|
39
44
|
const result = output || new Point();
|
|
@@ -48,19 +53,19 @@ export class Circle {
|
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @returns {Rectangle}
|
|
56
|
+
* Gets the bounding rectangle of this circle.
|
|
57
|
+
* @returns {Rectangle} The bounding rectangle of this circle.
|
|
53
58
|
*/
|
|
54
59
|
getBounds() {
|
|
55
60
|
return new Rectangle(this.x - this.radius, this.y - this.radius, this.diameter, this.diameter);
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param {number} x -
|
|
61
|
-
* @param {number} y -
|
|
62
|
-
* @param {number} diameter -
|
|
63
|
-
* @returns {Circle}
|
|
64
|
+
* Sets the position and size of this circle to new values.
|
|
65
|
+
* @param {number} x - The new x coordinate of the center point.
|
|
66
|
+
* @param {number} y - The new y coordinate of the center point.
|
|
67
|
+
* @param {number} diameter - The new diameter of the circle.
|
|
68
|
+
* @returns {Circle} This circle instance for chaining.
|
|
64
69
|
*/
|
|
65
70
|
setTo(x, y, diameter) {
|
|
66
71
|
this.x = x;
|
|
@@ -71,18 +76,18 @@ export class Circle {
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {Circle} source -
|
|
76
|
-
* @returns {Circle}
|
|
79
|
+
* Copies the values from another circle to this circle.
|
|
80
|
+
* @param {Circle} source - The circle to copy values from.
|
|
81
|
+
* @returns {Circle} This circle instance for chaining.
|
|
77
82
|
*/
|
|
78
83
|
copyFrom(source) {
|
|
79
84
|
return this.setTo(source.x, source.y, source.diameter);
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param {Circle} dest -
|
|
85
|
-
* @returns {Circle}
|
|
88
|
+
* Copies the values of this circle to another circle.
|
|
89
|
+
* @param {Circle} dest - The circle to copy values to.
|
|
90
|
+
* @returns {Circle} The destination circle.
|
|
86
91
|
*/
|
|
87
92
|
copyTo(dest) {
|
|
88
93
|
dest.x = this.x;
|
|
@@ -92,10 +97,10 @@ export class Circle {
|
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @param {Circle} dest -
|
|
97
|
-
* @param {boolean} round -
|
|
98
|
-
* @returns {number}
|
|
100
|
+
* Calculates the distance between this circle and another circle.
|
|
101
|
+
* @param {Circle} dest - The other circle to calculate the distance to.
|
|
102
|
+
* @param {boolean} round - Whether to round the result (default: false).
|
|
103
|
+
* @returns {number} The distance between the circles.
|
|
99
104
|
*/
|
|
100
105
|
distance(dest, round = false) {
|
|
101
106
|
const d = distance(this.x, this.y, dest.x, dest.y);
|
|
@@ -103,39 +108,39 @@ export class Circle {
|
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
/**
|
|
106
|
-
*
|
|
107
|
-
* @returns {Circle}
|
|
111
|
+
* Creates a clone of this circle.
|
|
112
|
+
* @returns {Circle} A new circle with the same values as this one.
|
|
108
113
|
*/
|
|
109
114
|
clone() {
|
|
110
115
|
return clone(this);
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
/**
|
|
114
|
-
*
|
|
115
|
-
* @param {number} x -
|
|
116
|
-
* @param {number} y -
|
|
117
|
-
* @returns {boolean}
|
|
119
|
+
* Checks if the specified point is contained within this circle.
|
|
120
|
+
* @param {number} x - The x coordinate of the point to check.
|
|
121
|
+
* @param {number} y - The y coordinate of the point to check.
|
|
122
|
+
* @returns {boolean} True if the point is contained within this circle, false otherwise.
|
|
118
123
|
*/
|
|
119
124
|
contains(x, y) {
|
|
120
125
|
return contains(this, x, y);
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @param {number} angle -
|
|
126
|
-
* @param {boolean} asDegrees -
|
|
127
|
-
* @param {Point} out -
|
|
128
|
-
* @returns {Point}
|
|
129
|
+
* Gets a point at a specific angle on the circumference of this circle.
|
|
130
|
+
* @param {number} angle - The angle in radians (or degrees if asDegrees is true) to get the point for.
|
|
131
|
+
* @param {boolean} asDegrees - Whether the angle is provided in degrees (default: false).
|
|
132
|
+
* @param {Point} out - The point to store the result in (optional).
|
|
133
|
+
* @returns {Point} A point at the specified angle on the circumference of this circle.
|
|
129
134
|
*/
|
|
130
135
|
circumferencePoint(angle, asDegrees, out) {
|
|
131
136
|
return circumferencePoint(this, angle, asDegrees, out);
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @param {number} dx -
|
|
137
|
-
* @param {number} dy -
|
|
138
|
-
* @returns {Circle}
|
|
140
|
+
* Offsets the position of this circle by the specified amounts.
|
|
141
|
+
* @param {number} dx - The amount to offset the x coordinate by.
|
|
142
|
+
* @param {number} dy - The amount to offset the y coordinate by.
|
|
143
|
+
* @returns {Circle} This circle instance for chaining.
|
|
139
144
|
*/
|
|
140
145
|
offset(dx, dy) {
|
|
141
146
|
this.x += dx;
|
|
@@ -144,32 +149,32 @@ export class Circle {
|
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @param {Point} point -
|
|
149
|
-
* @returns {Circle}
|
|
152
|
+
* Offsets the position of this circle by the specified point coordinates.
|
|
153
|
+
* @param {Point} point - The point to offset the circle by.
|
|
154
|
+
* @returns {Circle} This circle instance for chaining.
|
|
150
155
|
*/
|
|
151
156
|
offsetPoint(point) {
|
|
152
157
|
return this.offset(point.x, point.y);
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
/**
|
|
156
|
-
*
|
|
157
|
-
* @returns {string}
|
|
161
|
+
* Returns a string representation of this circle.
|
|
162
|
+
* @returns {string} A string representation of the circle.
|
|
158
163
|
*/
|
|
159
164
|
toString() {
|
|
160
165
|
return `[{Circle (x=${this.x} y=${this.y} diameter=${this.diameter} radius=${this.radius})}]`;
|
|
161
166
|
}
|
|
162
167
|
|
|
163
168
|
/**
|
|
164
|
-
*
|
|
165
|
-
* @returns {number}
|
|
169
|
+
* Gets the diameter of this circle.
|
|
170
|
+
* @returns {number} The diameter of this circle.
|
|
166
171
|
*/
|
|
167
172
|
get diameter() {
|
|
168
173
|
return this._diameter;
|
|
169
174
|
}
|
|
170
175
|
|
|
171
176
|
/**
|
|
172
|
-
*
|
|
177
|
+
* Sets the diameter of this circle.
|
|
173
178
|
*/
|
|
174
179
|
set diameter(value) {
|
|
175
180
|
if (value > 0) {
|
|
@@ -179,15 +184,15 @@ export class Circle {
|
|
|
179
184
|
}
|
|
180
185
|
|
|
181
186
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @returns {number}
|
|
187
|
+
* Gets the radius of this circle.
|
|
188
|
+
* @returns {number} The radius of this circle.
|
|
184
189
|
*/
|
|
185
190
|
get radius() {
|
|
186
191
|
return this._radius;
|
|
187
192
|
}
|
|
188
193
|
|
|
189
194
|
/**
|
|
190
|
-
*
|
|
195
|
+
* Sets the radius of this circle.
|
|
191
196
|
*/
|
|
192
197
|
set radius(value) {
|
|
193
198
|
if (value > 0) {
|
|
@@ -197,15 +202,15 @@ export class Circle {
|
|
|
197
202
|
}
|
|
198
203
|
|
|
199
204
|
/**
|
|
200
|
-
*
|
|
201
|
-
* @returns {number}
|
|
205
|
+
* Gets the left coordinate of this circle.
|
|
206
|
+
* @returns {number} The left coordinate of this circle.
|
|
202
207
|
*/
|
|
203
208
|
get left() {
|
|
204
209
|
return this.x - this._radius;
|
|
205
210
|
}
|
|
206
211
|
|
|
207
212
|
/**
|
|
208
|
-
*
|
|
213
|
+
* Sets the left coordinate of this circle.
|
|
209
214
|
*/
|
|
210
215
|
set left(value) {
|
|
211
216
|
if (value > this.x) {
|
|
@@ -217,15 +222,15 @@ export class Circle {
|
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @returns {number}
|
|
225
|
+
* Gets the right coordinate of this circle.
|
|
226
|
+
* @returns {number} The right coordinate of this circle.
|
|
222
227
|
*/
|
|
223
228
|
get right() {
|
|
224
229
|
return this.x + this._radius;
|
|
225
230
|
}
|
|
226
231
|
|
|
227
232
|
/**
|
|
228
|
-
*
|
|
233
|
+
* Sets the right coordinate of this circle.
|
|
229
234
|
*/
|
|
230
235
|
set right(value) {
|
|
231
236
|
if (value < this.x) {
|
|
@@ -237,15 +242,15 @@ export class Circle {
|
|
|
237
242
|
}
|
|
238
243
|
|
|
239
244
|
/**
|
|
240
|
-
*
|
|
241
|
-
* @returns {number}
|
|
245
|
+
* Gets the top coordinate of this circle.
|
|
246
|
+
* @returns {number} The top coordinate of this circle.
|
|
242
247
|
*/
|
|
243
248
|
get top() {
|
|
244
249
|
return this.y - this._radius;
|
|
245
250
|
}
|
|
246
251
|
|
|
247
252
|
/**
|
|
248
|
-
*
|
|
253
|
+
* Sets the top coordinate of this circle.
|
|
249
254
|
*/
|
|
250
255
|
set top(value) {
|
|
251
256
|
if (value > this.y) {
|
|
@@ -257,15 +262,15 @@ export class Circle {
|
|
|
257
262
|
}
|
|
258
263
|
|
|
259
264
|
/**
|
|
260
|
-
*
|
|
261
|
-
* @returns {number}
|
|
265
|
+
* Gets the bottom coordinate of this circle.
|
|
266
|
+
* @returns {number} The bottom coordinate of this circle.
|
|
262
267
|
*/
|
|
263
268
|
get bottom() {
|
|
264
269
|
return this.y + this._radius;
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
/**
|
|
268
|
-
*
|
|
273
|
+
* Sets the bottom coordinate of this circle.
|
|
269
274
|
*/
|
|
270
275
|
set bottom(value) {
|
|
271
276
|
if (value < this.y) {
|
|
@@ -277,8 +282,8 @@ export class Circle {
|
|
|
277
282
|
}
|
|
278
283
|
|
|
279
284
|
/**
|
|
280
|
-
*
|
|
281
|
-
* @returns {number}
|
|
285
|
+
* Gets the area of this circle.
|
|
286
|
+
* @returns {number} The area of this circle.
|
|
282
287
|
*/
|
|
283
288
|
get area() {
|
|
284
289
|
if (this._radius > 0) {
|
|
@@ -288,15 +293,15 @@ export class Circle {
|
|
|
288
293
|
}
|
|
289
294
|
|
|
290
295
|
/**
|
|
291
|
-
*
|
|
292
|
-
* @returns {boolean}
|
|
296
|
+
* Checks if this circle is empty (has zero diameter).
|
|
297
|
+
* @returns {boolean} True if the circle is empty, false otherwise.
|
|
293
298
|
*/
|
|
294
299
|
get empty() {
|
|
295
300
|
return this._diameter === 0;
|
|
296
301
|
}
|
|
297
302
|
|
|
298
303
|
/**
|
|
299
|
-
*
|
|
304
|
+
* Sets whether this circle is empty (zero diameter).
|
|
300
305
|
*/
|
|
301
306
|
set empty(value) {
|
|
302
307
|
if (value === true) {
|
|
@@ -5,27 +5,32 @@ import { contains } from './util/ellipse.js';
|
|
|
5
5
|
|
|
6
6
|
export class Ellipse {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {number} x -
|
|
10
|
-
* @param {number} y -
|
|
11
|
-
* @param {number} width -
|
|
12
|
-
* @param {number} height -
|
|
8
|
+
* Creates a new Ellipse instance.
|
|
9
|
+
* @param {number} x - The x coordinate of the center point (default: 0).
|
|
10
|
+
* @param {number} y - The y coordinate of the center point (default: 0).
|
|
11
|
+
* @param {number} width - The width of the ellipse (default: 0).
|
|
12
|
+
* @param {number} height - The height of the ellipse (default: 0).
|
|
13
13
|
*/
|
|
14
14
|
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
15
|
+
/** @type {number} */
|
|
15
16
|
this.x = x;
|
|
17
|
+
/** @type {number} */
|
|
16
18
|
this.y = y;
|
|
19
|
+
/** @type {number} */
|
|
17
20
|
this.width = width;
|
|
21
|
+
/** @type {number} */
|
|
18
22
|
this.height = height;
|
|
23
|
+
/** @type {number} */
|
|
19
24
|
this.type = GEOM_ELLIPSE;
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {number} x -
|
|
25
|
-
* @param {number} y -
|
|
26
|
-
* @param {number} width -
|
|
27
|
-
* @param {number} height -
|
|
28
|
-
* @returns {Ellipse}
|
|
28
|
+
* Sets the position and size of this ellipse to new values.
|
|
29
|
+
* @param {number} x - The new x coordinate of the center point.
|
|
30
|
+
* @param {number} y - The new y coordinate of the center point.
|
|
31
|
+
* @param {number} width - The new width of the ellipse.
|
|
32
|
+
* @param {number} height - The new height of the ellipse.
|
|
33
|
+
* @returns {Ellipse} This ellipse instance for chaining.
|
|
29
34
|
*/
|
|
30
35
|
setTo(x, y, width, height) {
|
|
31
36
|
this.x = x;
|
|
@@ -36,26 +41,26 @@ export class Ellipse {
|
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @returns {Rectangle}
|
|
44
|
+
* Gets the bounding rectangle of this ellipse.
|
|
45
|
+
* @returns {Rectangle} The bounding rectangle of this ellipse.
|
|
41
46
|
*/
|
|
42
47
|
getBounds() {
|
|
43
48
|
return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {Ellipse} source -
|
|
49
|
-
* @returns {Ellipse}
|
|
52
|
+
* Copies the values from another ellipse to this ellipse.
|
|
53
|
+
* @param {Ellipse} source - The ellipse to copy values from.
|
|
54
|
+
* @returns {Ellipse} This ellipse instance for chaining.
|
|
50
55
|
*/
|
|
51
56
|
copyFrom(source) {
|
|
52
57
|
return this.setTo(source.x, source.y, source.width, source.height);
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param {Ellipse} dest -
|
|
58
|
-
* @returns {Ellipse}
|
|
61
|
+
* Copies the values of this ellipse to another ellipse.
|
|
62
|
+
* @param {Ellipse} dest - The ellipse to copy values to.
|
|
63
|
+
* @returns {Ellipse} The destination ellipse.
|
|
59
64
|
*/
|
|
60
65
|
copyTo(dest) {
|
|
61
66
|
dest.x = this.x;
|
|
@@ -66,19 +71,19 @@ export class Ellipse {
|
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @param {number} x -
|
|
71
|
-
* @param {number} y -
|
|
72
|
-
* @returns {boolean}
|
|
74
|
+
* Checks if the specified point is contained within this ellipse.
|
|
75
|
+
* @param {number} x - The x coordinate of the point to check.
|
|
76
|
+
* @param {number} y - The y coordinate of the point to check.
|
|
77
|
+
* @returns {boolean} True if the point is contained within this ellipse, false otherwise.
|
|
73
78
|
*/
|
|
74
79
|
contains(x, y) {
|
|
75
80
|
return contains(this, x, y);
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {Point} output -
|
|
81
|
-
* @returns {Point}
|
|
84
|
+
* Returns a random point within this ellipse.
|
|
85
|
+
* @param {Point} output - The point to store the result in (optional).
|
|
86
|
+
* @returns {Point} A random point within this ellipse.
|
|
82
87
|
*/
|
|
83
88
|
random(output = null) {
|
|
84
89
|
const result = output || new Point();
|
|
@@ -92,8 +97,8 @@ export class Ellipse {
|
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @returns {string}
|
|
100
|
+
* Returns a string representation of this ellipse.
|
|
101
|
+
* @returns {string} A string representation of the ellipse.
|
|
97
102
|
*/
|
|
98
103
|
toString() {
|
|
99
104
|
return `[{Ellipse (x=${this.x} y=${this.y} width=${this.width} height=${this.height})}]`;
|