@vpmedia/phaser 1.95.0 → 1.97.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 +51 -0
- package/package.json +10 -10
- package/src/phaser/core/animation.js +61 -56
- package/src/phaser/core/animation_manager.js +55 -55
- 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 +34 -18
- package/src/phaser/core/loader.js +170 -170
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +68 -52
- package/src/phaser/core/signal.test.js +37 -0
- 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 +30 -30
- package/src/phaser/core/timer.js +79 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +90 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +29 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +61 -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 +16 -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 +112 -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 +50 -50
- package/src/phaser/display/image.js +54 -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 +212 -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 +20 -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 +69 -69
- package/src/phaser/geom/circle.test.js +1 -0
- package/src/phaser/geom/ellipse.js +28 -28
- package/src/phaser/geom/ellipse.test.js +1 -0
- package/src/phaser/geom/line.js +93 -93
- package/src/phaser/geom/line.test.js +1 -0
- package/src/phaser/geom/matrix.js +54 -54
- package/src/phaser/geom/matrix.test.js +1 -0
- package/src/phaser/geom/point.js +96 -96
- package/src/phaser/geom/point.test.js +1 -0
- package/src/phaser/geom/polygon.js +22 -22
- package/src/phaser/geom/rectangle.js +132 -132
- package/src/phaser/geom/rectangle.test.js +1 -0
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/rounded_rectangle.test.js +1 -0
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/circle.test.js +1 -0
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/ellipse.test.js +1 -0
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/line.test.js +1 -0
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/matrix.test.js +1 -0
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/point.test.js +1 -0
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/polygon.test.js +1 -0
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rectangle.test.js +1 -0
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/geom/util/rounded_rectangle.test.js +1 -0
- package/src/phaser/util/math.js +81 -81
- package/src/phaser/util/math.test.js +1 -0
- package/types/phaser/core/animation.d.ts +61 -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/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +43 -43
- 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 +52 -19
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +170 -170
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +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 +30 -30
- package/types/phaser/core/timer.d.ts +64 -64
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +90 -90
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +29 -24
- 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 +59 -52
- 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/renderer.d.ts +16 -16
- 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 +101 -101
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +47 -47
- package/types/phaser/display/image.d.ts +42 -40
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +207 -184
- 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 +9 -9
- 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_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +20 -20
- 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/geom/circle.d.ts +69 -69
- package/types/phaser/geom/ellipse.d.ts +28 -28
- package/types/phaser/geom/line.d.ts +93 -93
- package/types/phaser/geom/matrix.d.ts +54 -54
- package/types/phaser/geom/point.d.ts +96 -96
- package/types/phaser/geom/polygon.d.ts +22 -22
- package/types/phaser/geom/rectangle.d.ts +132 -132
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/pnpm-workspace.yaml +0 -4
|
@@ -6,10 +6,10 @@ 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
15
|
/** @type {number} */
|
|
@@ -28,17 +28,17 @@ export class Circle {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @returns {number}
|
|
31
|
+
* Calculates the circumference of this circle.
|
|
32
|
+
* @returns {number} The circumference of this circle.
|
|
33
33
|
*/
|
|
34
34
|
circumference() {
|
|
35
35
|
return 2 * (Math.PI * this._radius);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @param {Point} output -
|
|
41
|
-
* @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.
|
|
42
42
|
*/
|
|
43
43
|
random(output = null) {
|
|
44
44
|
const result = output || new Point();
|
|
@@ -53,19 +53,19 @@ export class Circle {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @returns {Rectangle}
|
|
56
|
+
* Gets the bounding rectangle of this circle.
|
|
57
|
+
* @returns {Rectangle} The bounding rectangle of this circle.
|
|
58
58
|
*/
|
|
59
59
|
getBounds() {
|
|
60
60
|
return new Rectangle(this.x - this.radius, this.y - this.radius, this.diameter, this.diameter);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @param {number} x -
|
|
66
|
-
* @param {number} y -
|
|
67
|
-
* @param {number} diameter -
|
|
68
|
-
* @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.
|
|
69
69
|
*/
|
|
70
70
|
setTo(x, y, diameter) {
|
|
71
71
|
this.x = x;
|
|
@@ -76,18 +76,18 @@ export class Circle {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {Circle} source -
|
|
81
|
-
* @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.
|
|
82
82
|
*/
|
|
83
83
|
copyFrom(source) {
|
|
84
84
|
return this.setTo(source.x, source.y, source.diameter);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @param {Circle} dest -
|
|
90
|
-
* @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.
|
|
91
91
|
*/
|
|
92
92
|
copyTo(dest) {
|
|
93
93
|
dest.x = this.x;
|
|
@@ -97,10 +97,10 @@ export class Circle {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param {Circle} dest -
|
|
102
|
-
* @param {boolean} round -
|
|
103
|
-
* @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.
|
|
104
104
|
*/
|
|
105
105
|
distance(dest, round = false) {
|
|
106
106
|
const d = distance(this.x, this.y, dest.x, dest.y);
|
|
@@ -108,39 +108,39 @@ export class Circle {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @returns {Circle}
|
|
111
|
+
* Creates a clone of this circle.
|
|
112
|
+
* @returns {Circle} A new circle with the same values as this one.
|
|
113
113
|
*/
|
|
114
114
|
clone() {
|
|
115
115
|
return clone(this);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @param {number} x -
|
|
121
|
-
* @param {number} y -
|
|
122
|
-
* @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.
|
|
123
123
|
*/
|
|
124
124
|
contains(x, y) {
|
|
125
125
|
return contains(this, x, y);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
130
|
-
* @param {number} angle -
|
|
131
|
-
* @param {boolean} asDegrees -
|
|
132
|
-
* @param {Point} out -
|
|
133
|
-
* @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.
|
|
134
134
|
*/
|
|
135
135
|
circumferencePoint(angle, asDegrees, out) {
|
|
136
136
|
return circumferencePoint(this, angle, asDegrees, out);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
141
|
-
* @param {number} dx -
|
|
142
|
-
* @param {number} dy -
|
|
143
|
-
* @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.
|
|
144
144
|
*/
|
|
145
145
|
offset(dx, dy) {
|
|
146
146
|
this.x += dx;
|
|
@@ -149,32 +149,32 @@ export class Circle {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @param {Point} point -
|
|
154
|
-
* @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.
|
|
155
155
|
*/
|
|
156
156
|
offsetPoint(point) {
|
|
157
157
|
return this.offset(point.x, point.y);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @returns {string}
|
|
161
|
+
* Returns a string representation of this circle.
|
|
162
|
+
* @returns {string} A string representation of the circle.
|
|
163
163
|
*/
|
|
164
164
|
toString() {
|
|
165
165
|
return `[{Circle (x=${this.x} y=${this.y} diameter=${this.diameter} radius=${this.radius})}]`;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
|
-
*
|
|
170
|
-
* @returns {number}
|
|
169
|
+
* Gets the diameter of this circle.
|
|
170
|
+
* @returns {number} The diameter of this circle.
|
|
171
171
|
*/
|
|
172
172
|
get diameter() {
|
|
173
173
|
return this._diameter;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
177
|
+
* Sets the diameter of this circle.
|
|
178
178
|
*/
|
|
179
179
|
set diameter(value) {
|
|
180
180
|
if (value > 0) {
|
|
@@ -184,15 +184,15 @@ export class Circle {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @returns {number}
|
|
187
|
+
* Gets the radius of this circle.
|
|
188
|
+
* @returns {number} The radius of this circle.
|
|
189
189
|
*/
|
|
190
190
|
get radius() {
|
|
191
191
|
return this._radius;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
195
|
+
* Sets the radius of this circle.
|
|
196
196
|
*/
|
|
197
197
|
set radius(value) {
|
|
198
198
|
if (value > 0) {
|
|
@@ -202,15 +202,15 @@ export class Circle {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
|
-
*
|
|
206
|
-
* @returns {number}
|
|
205
|
+
* Gets the left coordinate of this circle.
|
|
206
|
+
* @returns {number} The left coordinate of this circle.
|
|
207
207
|
*/
|
|
208
208
|
get left() {
|
|
209
209
|
return this.x - this._radius;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
/**
|
|
213
|
-
*
|
|
213
|
+
* Sets the left coordinate of this circle.
|
|
214
214
|
*/
|
|
215
215
|
set left(value) {
|
|
216
216
|
if (value > this.x) {
|
|
@@ -222,15 +222,15 @@ export class Circle {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
/**
|
|
225
|
-
*
|
|
226
|
-
* @returns {number}
|
|
225
|
+
* Gets the right coordinate of this circle.
|
|
226
|
+
* @returns {number} The right coordinate of this circle.
|
|
227
227
|
*/
|
|
228
228
|
get right() {
|
|
229
229
|
return this.x + this._radius;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
/**
|
|
233
|
-
*
|
|
233
|
+
* Sets the right coordinate of this circle.
|
|
234
234
|
*/
|
|
235
235
|
set right(value) {
|
|
236
236
|
if (value < this.x) {
|
|
@@ -242,15 +242,15 @@ export class Circle {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
|
-
*
|
|
246
|
-
* @returns {number}
|
|
245
|
+
* Gets the top coordinate of this circle.
|
|
246
|
+
* @returns {number} The top coordinate of this circle.
|
|
247
247
|
*/
|
|
248
248
|
get top() {
|
|
249
249
|
return this.y - this._radius;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
|
-
*
|
|
253
|
+
* Sets the top coordinate of this circle.
|
|
254
254
|
*/
|
|
255
255
|
set top(value) {
|
|
256
256
|
if (value > this.y) {
|
|
@@ -262,15 +262,15 @@ export class Circle {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
|
-
*
|
|
266
|
-
* @returns {number}
|
|
265
|
+
* Gets the bottom coordinate of this circle.
|
|
266
|
+
* @returns {number} The bottom coordinate of this circle.
|
|
267
267
|
*/
|
|
268
268
|
get bottom() {
|
|
269
269
|
return this.y + this._radius;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
|
-
*
|
|
273
|
+
* Sets the bottom coordinate of this circle.
|
|
274
274
|
*/
|
|
275
275
|
set bottom(value) {
|
|
276
276
|
if (value < this.y) {
|
|
@@ -282,8 +282,8 @@ export class Circle {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
|
-
*
|
|
286
|
-
* @returns {number}
|
|
285
|
+
* Gets the area of this circle.
|
|
286
|
+
* @returns {number} The area of this circle.
|
|
287
287
|
*/
|
|
288
288
|
get area() {
|
|
289
289
|
if (this._radius > 0) {
|
|
@@ -293,15 +293,15 @@ export class Circle {
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
|
-
*
|
|
297
|
-
* @returns {boolean}
|
|
296
|
+
* Checks if this circle is empty (has zero diameter).
|
|
297
|
+
* @returns {boolean} True if the circle is empty, false otherwise.
|
|
298
298
|
*/
|
|
299
299
|
get empty() {
|
|
300
300
|
return this._diameter === 0;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
|
-
*
|
|
304
|
+
* Sets whether this circle is empty (zero diameter).
|
|
305
305
|
*/
|
|
306
306
|
set empty(value) {
|
|
307
307
|
if (value === true) {
|
|
@@ -5,11 +5,11 @@ 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
15
|
/** @type {number} */
|
|
@@ -25,12 +25,12 @@ export class Ellipse {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {number} x -
|
|
30
|
-
* @param {number} y -
|
|
31
|
-
* @param {number} width -
|
|
32
|
-
* @param {number} height -
|
|
33
|
-
* @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.
|
|
34
34
|
*/
|
|
35
35
|
setTo(x, y, width, height) {
|
|
36
36
|
this.x = x;
|
|
@@ -41,26 +41,26 @@ export class Ellipse {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @returns {Rectangle}
|
|
44
|
+
* Gets the bounding rectangle of this ellipse.
|
|
45
|
+
* @returns {Rectangle} The bounding rectangle of this ellipse.
|
|
46
46
|
*/
|
|
47
47
|
getBounds() {
|
|
48
48
|
return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param {Ellipse} source -
|
|
54
|
-
* @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.
|
|
55
55
|
*/
|
|
56
56
|
copyFrom(source) {
|
|
57
57
|
return this.setTo(source.x, source.y, source.width, source.height);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @param {Ellipse} dest -
|
|
63
|
-
* @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.
|
|
64
64
|
*/
|
|
65
65
|
copyTo(dest) {
|
|
66
66
|
dest.x = this.x;
|
|
@@ -71,19 +71,19 @@ export class Ellipse {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {number} x -
|
|
76
|
-
* @param {number} y -
|
|
77
|
-
* @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.
|
|
78
78
|
*/
|
|
79
79
|
contains(x, y) {
|
|
80
80
|
return contains(this, x, y);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @param {Point} output -
|
|
86
|
-
* @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.
|
|
87
87
|
*/
|
|
88
88
|
random(output = null) {
|
|
89
89
|
const result = output || new Point();
|
|
@@ -97,8 +97,8 @@ export class Ellipse {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @returns {string}
|
|
100
|
+
* Returns a string representation of this ellipse.
|
|
101
|
+
* @returns {string} A string representation of the ellipse.
|
|
102
102
|
*/
|
|
103
103
|
toString() {
|
|
104
104
|
return `[{Ellipse (x=${this.x} y=${this.y} width=${this.width} height=${this.height})}]`;
|