@vpmedia/phaser 1.95.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 +29 -0
- package/package.json +9 -9
- 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 +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 +30 -30
- package/src/phaser/core/timer.js +64 -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/ellipse.js +28 -28
- package/src/phaser/geom/line.js +93 -93
- package/src/phaser/geom/matrix.js +54 -54
- package/src/phaser/geom/point.js +96 -96
- package/src/phaser/geom/polygon.js +22 -22
- package/src/phaser/geom/rectangle.js +132 -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 +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
|
@@ -26,11 +26,11 @@ import {
|
|
|
26
26
|
|
|
27
27
|
export class Rectangle {
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {number} x -
|
|
31
|
-
* @param {number} y -
|
|
32
|
-
* @param {number} width -
|
|
33
|
-
* @param {number} height -
|
|
29
|
+
* Creates a new Rectangle instance.
|
|
30
|
+
* @param {number} x - The x coordinate of the top-left corner of the rectangle (default: 0).
|
|
31
|
+
* @param {number} y - The y coordinate of the top-left corner of the rectangle (default: 0).
|
|
32
|
+
* @param {number} width - The width of the rectangle (default: 0).
|
|
33
|
+
* @param {number} height - The height of the rectangle (default: 0).
|
|
34
34
|
*/
|
|
35
35
|
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
36
36
|
/** @type {number} */
|
|
@@ -46,10 +46,10 @@ export class Rectangle {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {number} dx -
|
|
51
|
-
* @param {number} dy -
|
|
52
|
-
* @returns {Rectangle}
|
|
49
|
+
* Offsets the rectangle's position by the specified amounts.
|
|
50
|
+
* @param {number} dx - The amount to offset the x coordinate by.
|
|
51
|
+
* @param {number} dy - The amount to offset the y coordinate by.
|
|
52
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
53
53
|
*/
|
|
54
54
|
offset(dx, dy) {
|
|
55
55
|
this.x += dx;
|
|
@@ -58,21 +58,21 @@ export class Rectangle {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @param {Point} point -
|
|
63
|
-
* @returns {Rectangle}
|
|
61
|
+
* Offsets the rectangle's position by the specified point coordinates.
|
|
62
|
+
* @param {Point} point - The point to offset the rectangle by.
|
|
63
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
64
64
|
*/
|
|
65
65
|
offsetPoint(point) {
|
|
66
66
|
return this.offset(point.x, point.y);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @param {number} x -
|
|
72
|
-
* @param {number} y -
|
|
73
|
-
* @param {number} width -
|
|
74
|
-
* @param {number} height -
|
|
75
|
-
* @returns {Rectangle}
|
|
70
|
+
* Sets the rectangle's position and size to new values.
|
|
71
|
+
* @param {number} x - The new x coordinate of the top-left corner of the rectangle.
|
|
72
|
+
* @param {number} y - The new y coordinate of the top-left corner of the rectangle.
|
|
73
|
+
* @param {number} width - The new width of the rectangle.
|
|
74
|
+
* @param {number} height - The new height of the rectangle.
|
|
75
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
76
76
|
*/
|
|
77
77
|
setTo(x, y, width, height) {
|
|
78
78
|
this.x = x;
|
|
@@ -83,10 +83,10 @@ export class Rectangle {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @param {number} x -
|
|
88
|
-
* @param {number} y -
|
|
89
|
-
* @returns {Rectangle}
|
|
86
|
+
* Scales the rectangle's size by the specified amounts.
|
|
87
|
+
* @param {number} x - The amount to scale the width by.
|
|
88
|
+
* @param {number} y - The amount to scale the height by (default: x).
|
|
89
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
90
90
|
*/
|
|
91
91
|
scale(x, y) {
|
|
92
92
|
if (y === undefined) {
|
|
@@ -98,10 +98,10 @@ export class Rectangle {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @param {number} x -
|
|
103
|
-
* @param {number} y -
|
|
104
|
-
* @returns {Rectangle}
|
|
101
|
+
* Centers the rectangle on the specified point.
|
|
102
|
+
* @param {number} x - The x coordinate to center the rectangle on.
|
|
103
|
+
* @param {number} y - The y coordinate to center the rectangle on.
|
|
104
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
105
105
|
*/
|
|
106
106
|
centerOn(x, y) {
|
|
107
107
|
this.centerX = x;
|
|
@@ -110,7 +110,7 @@ export class Rectangle {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* Floors the x and y coordinates of the rectangle (rounds down to nearest integer).
|
|
114
114
|
*/
|
|
115
115
|
floor() {
|
|
116
116
|
this.x = Math.floor(this.x);
|
|
@@ -118,7 +118,7 @@ export class Rectangle {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
121
|
+
* Floors all coordinates of the rectangle (rounds down to nearest integer).
|
|
122
122
|
*/
|
|
123
123
|
floorAll() {
|
|
124
124
|
this.x = Math.floor(this.x);
|
|
@@ -128,7 +128,7 @@ export class Rectangle {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
131
|
+
* Ceils the x and y coordinates of the rectangle (rounds up to nearest integer).
|
|
132
132
|
*/
|
|
133
133
|
ceil() {
|
|
134
134
|
this.x = Math.ceil(this.x);
|
|
@@ -136,7 +136,7 @@ export class Rectangle {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* Ceils all coordinates of the rectangle (rounds up to nearest integer).
|
|
140
140
|
*/
|
|
141
141
|
ceilAll() {
|
|
142
142
|
this.x = Math.ceil(this.x);
|
|
@@ -146,18 +146,18 @@ export class Rectangle {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
150
|
-
* @param {Rectangle} source -
|
|
151
|
-
* @returns {Rectangle}
|
|
149
|
+
* Copies the values from another rectangle to this rectangle.
|
|
150
|
+
* @param {Rectangle} source - The rectangle to copy values from.
|
|
151
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
152
152
|
*/
|
|
153
153
|
copyFrom(source) {
|
|
154
154
|
return this.setTo(source.x, source.y, source.width, source.height);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
|
-
*
|
|
159
|
-
* @param {Rectangle} dest -
|
|
160
|
-
* @returns {Rectangle}
|
|
158
|
+
* Copies the values of this rectangle to another rectangle.
|
|
159
|
+
* @param {Rectangle} dest - The rectangle to copy values to.
|
|
160
|
+
* @returns {Rectangle} The destination rectangle.
|
|
161
161
|
*/
|
|
162
162
|
copyTo(dest) {
|
|
163
163
|
dest.x = this.x;
|
|
@@ -168,29 +168,29 @@ export class Rectangle {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
172
|
-
* @param {number} dx -
|
|
173
|
-
* @param {number} dy -
|
|
174
|
-
* @returns {Rectangle}
|
|
171
|
+
* Increases the size of the rectangle by the specified amounts.
|
|
172
|
+
* @param {number} dx - The amount to increase the width by.
|
|
173
|
+
* @param {number} dy - The amount to increase the height by.
|
|
174
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
175
175
|
*/
|
|
176
176
|
inflate(dx, dy) {
|
|
177
177
|
return inflate(this, dx, dy);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
182
|
-
* @param {Point} output -
|
|
183
|
-
* @returns {Point}
|
|
181
|
+
* Gets the size of the rectangle as a point.
|
|
182
|
+
* @param {Point} output - The point to store the size in (optional).
|
|
183
|
+
* @returns {Point} The size of the rectangle as a point.
|
|
184
184
|
*/
|
|
185
185
|
size(output) {
|
|
186
186
|
return size(this, output);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
|
-
*
|
|
191
|
-
* @param {number} width -
|
|
192
|
-
* @param {number} height -
|
|
193
|
-
* @returns {Rectangle}
|
|
190
|
+
* Resizes the rectangle to the specified dimensions.
|
|
191
|
+
* @param {number} width - The new width of the rectangle.
|
|
192
|
+
* @param {number} height - The new height of the rectangle.
|
|
193
|
+
* @returns {Rectangle} This rectangle instance for chaining.
|
|
194
194
|
*/
|
|
195
195
|
resize(width, height) {
|
|
196
196
|
this.width = width;
|
|
@@ -199,88 +199,88 @@ export class Rectangle {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
|
-
*
|
|
203
|
-
* @param {Rectangle} output -
|
|
204
|
-
* @returns {Rectangle}
|
|
202
|
+
* Creates a clone of this rectangle.
|
|
203
|
+
* @param {Rectangle} output - The rectangle to store the clone in (optional).
|
|
204
|
+
* @returns {Rectangle} A new rectangle with the same values as this one.
|
|
205
205
|
*/
|
|
206
206
|
clone(output) {
|
|
207
207
|
return clone(this, output);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
|
-
*
|
|
212
|
-
* @param {number} x -
|
|
213
|
-
* @param {number} y -
|
|
214
|
-
* @returns {boolean}
|
|
211
|
+
* Checks if the specified point is contained within this rectangle.
|
|
212
|
+
* @param {number} x - The x coordinate of the point to check.
|
|
213
|
+
* @param {number} y - The y coordinate of the point to check.
|
|
214
|
+
* @returns {boolean} True if the point is contained within this rectangle, false otherwise.
|
|
215
215
|
*/
|
|
216
216
|
contains(x, y) {
|
|
217
217
|
return contains(this, x, y);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
*
|
|
222
|
-
* @param {Rectangle} b -
|
|
223
|
-
* @returns {boolean}
|
|
221
|
+
* Checks if the specified rectangle is fully contained within this rectangle.
|
|
222
|
+
* @param {Rectangle} b - The rectangle to check if it's contained.
|
|
223
|
+
* @returns {boolean} True if the rectangle is contained within this rectangle, false otherwise.
|
|
224
224
|
*/
|
|
225
225
|
containsRect(b) {
|
|
226
226
|
return containsRect(b, this);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
|
-
*
|
|
231
|
-
* @param {Rectangle} b -
|
|
232
|
-
* @returns {boolean}
|
|
230
|
+
* Checks if this rectangle is equal to another rectangle.
|
|
231
|
+
* @param {Rectangle} b - The rectangle to compare with.
|
|
232
|
+
* @returns {boolean} True if the rectangles have the same values, false otherwise.
|
|
233
233
|
*/
|
|
234
234
|
equals(b) {
|
|
235
235
|
return equals(this, b);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
*
|
|
240
|
-
* @param {Rectangle} b -
|
|
241
|
-
* @param {Rectangle} out -
|
|
242
|
-
* @returns {Rectangle}
|
|
239
|
+
* Gets the intersection of this rectangle and another rectangle.
|
|
240
|
+
* @param {Rectangle} b - The rectangle to intersect with.
|
|
241
|
+
* @param {Rectangle} out - The rectangle to store the result in (optional).
|
|
242
|
+
* @returns {Rectangle} The intersection of the two rectangles.
|
|
243
243
|
*/
|
|
244
244
|
intersection(b, out) {
|
|
245
245
|
return intersection(this, b, out);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
*
|
|
250
|
-
* @param {Rectangle} b -
|
|
251
|
-
* @returns {boolean}
|
|
249
|
+
* Checks if this rectangle intersects with another rectangle.
|
|
250
|
+
* @param {Rectangle} b - The rectangle to check for intersection with.
|
|
251
|
+
* @returns {boolean} True if the rectangles intersect, false otherwise.
|
|
252
252
|
*/
|
|
253
253
|
intersects(b) {
|
|
254
254
|
return intersects(this, b);
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
|
-
*
|
|
259
|
-
* @param {number} left -
|
|
260
|
-
* @param {number} right -
|
|
261
|
-
* @param {number} top -
|
|
262
|
-
* @param {number} bottom -
|
|
263
|
-
* @param {number} tolerance -
|
|
264
|
-
* @returns {boolean}
|
|
258
|
+
* Checks if this rectangle intersects with the specified bounds.
|
|
259
|
+
* @param {number} left - The left boundary of the area to check for intersection.
|
|
260
|
+
* @param {number} right - The right boundary of the area to check for intersection.
|
|
261
|
+
* @param {number} top - The top boundary of the area to check for intersection.
|
|
262
|
+
* @param {number} bottom - The bottom boundary of the area to check for intersection.
|
|
263
|
+
* @param {number} tolerance - A tolerance value to use when checking (default: 0).
|
|
264
|
+
* @returns {boolean} True if the rectangle intersects with the bounds, false otherwise.
|
|
265
265
|
*/
|
|
266
266
|
intersectsRaw(left, right, top, bottom, tolerance) {
|
|
267
267
|
return intersectsRaw(this, left, right, top, bottom, tolerance);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
|
-
*
|
|
272
|
-
* @param {Rectangle} b -
|
|
273
|
-
* @param {Rectangle} out -
|
|
274
|
-
* @returns {Rectangle}
|
|
271
|
+
* Gets the union of this rectangle and another rectangle.
|
|
272
|
+
* @param {Rectangle} b - The rectangle to union with.
|
|
273
|
+
* @param {Rectangle} out - The rectangle to store the result in (optional).
|
|
274
|
+
* @returns {Rectangle} The union of the two rectangles.
|
|
275
275
|
*/
|
|
276
276
|
union(b, out) {
|
|
277
277
|
return union(this, b, out);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
/**
|
|
281
|
-
*
|
|
282
|
-
* @param {Point} output -
|
|
283
|
-
* @returns {Point}
|
|
281
|
+
* Gets a random point within this rectangle.
|
|
282
|
+
* @param {Point} output - The point to store the result in (optional).
|
|
283
|
+
* @returns {Point} A random point within this rectangle.
|
|
284
284
|
*/
|
|
285
285
|
random(output = null) {
|
|
286
286
|
const result = output || new Point();
|
|
@@ -290,10 +290,10 @@ export class Rectangle {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
|
-
*
|
|
294
|
-
* @param {number} position -
|
|
295
|
-
* @param {Point} output -
|
|
296
|
-
* @returns {Point}
|
|
293
|
+
* Gets a point at a specific position on the rectangle.
|
|
294
|
+
* @param {number} position - The position to get the point for (TOP_LEFT, TOP_CENTER, etc.).
|
|
295
|
+
* @param {Point} output - The point to store the result in (optional).
|
|
296
|
+
* @returns {Point} A point at the specified position on the rectangle.
|
|
297
297
|
*/
|
|
298
298
|
getPoint(position, output = null) {
|
|
299
299
|
const result = output || new Point();
|
|
@@ -322,39 +322,39 @@ export class Rectangle {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
|
-
*
|
|
326
|
-
* @returns {string}
|
|
325
|
+
* Returns a string representation of this rectangle.
|
|
326
|
+
* @returns {string} A string representation of the rectangle.
|
|
327
327
|
*/
|
|
328
328
|
toString() {
|
|
329
329
|
return `[{Rectangle (x=${this.x} y=${this.y} width=${this.width} height=${this.height} empty=${this.empty})}]`;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
|
-
*
|
|
334
|
-
* @returns {number}
|
|
333
|
+
* Gets half the width of this rectangle.
|
|
334
|
+
* @returns {number} Half the width of this rectangle.
|
|
335
335
|
*/
|
|
336
336
|
get halfWidth() {
|
|
337
337
|
return Math.round(this.width / 2);
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
/**
|
|
341
|
-
*
|
|
342
|
-
* @returns {number}
|
|
341
|
+
* Gets half the height of this rectangle.
|
|
342
|
+
* @returns {number} Half the height of this rectangle.
|
|
343
343
|
*/
|
|
344
344
|
get halfHeight() {
|
|
345
345
|
return Math.round(this.height / 2);
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
/**
|
|
349
|
-
*
|
|
350
|
-
* @returns {number}
|
|
349
|
+
* Gets the top coordinate of this rectangle.
|
|
350
|
+
* @returns {number} The top coordinate of this rectangle.
|
|
351
351
|
*/
|
|
352
352
|
get top() {
|
|
353
353
|
return this.y;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
357
|
+
* Sets the top coordinate of this rectangle.
|
|
358
358
|
*/
|
|
359
359
|
set top(value) {
|
|
360
360
|
if (value >= this.bottom) {
|
|
@@ -366,15 +366,15 @@ export class Rectangle {
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/**
|
|
369
|
-
*
|
|
370
|
-
* @returns {Point}
|
|
369
|
+
* Gets the top-left point of this rectangle.
|
|
370
|
+
* @returns {Point} The top-left point of this rectangle.
|
|
371
371
|
*/
|
|
372
372
|
get topLeft() {
|
|
373
373
|
return new Point(this.x, this.y);
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
/**
|
|
377
|
-
*
|
|
377
|
+
* Sets the top-left point of this rectangle.
|
|
378
378
|
*/
|
|
379
379
|
set topLeft(value) {
|
|
380
380
|
this.x = value.x;
|
|
@@ -382,15 +382,15 @@ export class Rectangle {
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
/**
|
|
385
|
-
*
|
|
386
|
-
* @returns {Point}
|
|
385
|
+
* Gets the top-right point of this rectangle.
|
|
386
|
+
* @returns {Point} The top-right point of this rectangle.
|
|
387
387
|
*/
|
|
388
388
|
get topRight() {
|
|
389
389
|
return new Point(this.x + this.width, this.y);
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
/**
|
|
393
|
-
*
|
|
393
|
+
* Sets the top-right point of this rectangle.
|
|
394
394
|
*/
|
|
395
395
|
set topRight(value) {
|
|
396
396
|
this.right = value.x;
|
|
@@ -398,15 +398,15 @@ export class Rectangle {
|
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
/**
|
|
401
|
-
*
|
|
402
|
-
* @returns {number}
|
|
401
|
+
* Gets the bottom coordinate of this rectangle.
|
|
402
|
+
* @returns {number} The bottom coordinate of this rectangle.
|
|
403
403
|
*/
|
|
404
404
|
get bottom() {
|
|
405
405
|
return this.y + this.height;
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
/**
|
|
409
|
-
*
|
|
409
|
+
* Sets the bottom coordinate of this rectangle.
|
|
410
410
|
*/
|
|
411
411
|
set bottom(value) {
|
|
412
412
|
if (value <= this.y) {
|
|
@@ -417,15 +417,15 @@ export class Rectangle {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
/**
|
|
420
|
-
*
|
|
421
|
-
* @returns {Point}
|
|
420
|
+
* Gets the bottom-left point of this rectangle.
|
|
421
|
+
* @returns {Point} The bottom-left point of this rectangle.
|
|
422
422
|
*/
|
|
423
423
|
get bottomLeft() {
|
|
424
424
|
return new Point(this.x, this.bottom);
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
/**
|
|
428
|
-
*
|
|
428
|
+
* Sets the bottom-left point of this rectangle.
|
|
429
429
|
*/
|
|
430
430
|
set bottomLeft(value) {
|
|
431
431
|
this.x = value.x;
|
|
@@ -433,15 +433,15 @@ export class Rectangle {
|
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
/**
|
|
436
|
-
*
|
|
437
|
-
* @returns {Point}
|
|
436
|
+
* Gets the bottom-right point of this rectangle.
|
|
437
|
+
* @returns {Point} The bottom-right point of this rectangle.
|
|
438
438
|
*/
|
|
439
439
|
get bottomRight() {
|
|
440
440
|
return new Point(this.right, this.bottom);
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
/**
|
|
444
|
-
*
|
|
444
|
+
* Sets the bottom-right point of this rectangle.
|
|
445
445
|
*/
|
|
446
446
|
set bottomRight(value) {
|
|
447
447
|
this.right = value.x;
|
|
@@ -449,15 +449,15 @@ export class Rectangle {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
/**
|
|
452
|
-
*
|
|
453
|
-
* @returns {number}
|
|
452
|
+
* Gets the left coordinate of this rectangle.
|
|
453
|
+
* @returns {number} The left coordinate of this rectangle.
|
|
454
454
|
*/
|
|
455
455
|
get left() {
|
|
456
456
|
return this.x;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
/**
|
|
460
|
-
*
|
|
460
|
+
* Sets the left coordinate of this rectangle.
|
|
461
461
|
*/
|
|
462
462
|
set left(value) {
|
|
463
463
|
if (value >= this.right) {
|
|
@@ -469,15 +469,15 @@ export class Rectangle {
|
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
/**
|
|
472
|
-
*
|
|
473
|
-
* @returns {number}
|
|
472
|
+
* Gets the right coordinate of this rectangle.
|
|
473
|
+
* @returns {number} The right coordinate of this rectangle.
|
|
474
474
|
*/
|
|
475
475
|
get right() {
|
|
476
476
|
return this.x + this.width;
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
/**
|
|
480
|
-
*
|
|
480
|
+
* Sets the right coordinate of this rectangle.
|
|
481
481
|
*/
|
|
482
482
|
set right(value) {
|
|
483
483
|
if (value <= this.x) {
|
|
@@ -488,77 +488,77 @@ export class Rectangle {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
/**
|
|
491
|
-
*
|
|
492
|
-
* @returns {number}
|
|
491
|
+
* Gets the volume (area) of this rectangle.
|
|
492
|
+
* @returns {number} The volume (area) of this rectangle.
|
|
493
493
|
*/
|
|
494
494
|
get volume() {
|
|
495
495
|
return this.width * this.height;
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
/**
|
|
499
|
-
*
|
|
500
|
-
* @returns {number}
|
|
499
|
+
* Gets the perimeter of this rectangle.
|
|
500
|
+
* @returns {number} The perimeter of this rectangle.
|
|
501
501
|
*/
|
|
502
502
|
get perimeter() {
|
|
503
503
|
return this.width * 2 + this.height * 2;
|
|
504
504
|
}
|
|
505
505
|
|
|
506
506
|
/**
|
|
507
|
-
*
|
|
508
|
-
* @returns {number}
|
|
507
|
+
* Gets the x coordinate of the center of this rectangle.
|
|
508
|
+
* @returns {number} The x coordinate of the center of this rectangle.
|
|
509
509
|
*/
|
|
510
510
|
get centerX() {
|
|
511
511
|
return this.x + this.halfWidth;
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
/**
|
|
515
|
-
*
|
|
515
|
+
* Sets the x coordinate of the center of this rectangle.
|
|
516
516
|
*/
|
|
517
517
|
set centerX(value) {
|
|
518
518
|
this.x = value - this.halfWidth;
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
/**
|
|
522
|
-
*
|
|
523
|
-
* @returns {number}
|
|
522
|
+
* Gets the y coordinate of the center of this rectangle.
|
|
523
|
+
* @returns {number} The y coordinate of the center of this rectangle.
|
|
524
524
|
*/
|
|
525
525
|
get centerY() {
|
|
526
526
|
return this.y + this.halfHeight;
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
/**
|
|
530
|
-
*
|
|
530
|
+
* Sets the y coordinate of the center of this rectangle.
|
|
531
531
|
*/
|
|
532
532
|
set centerY(value) {
|
|
533
533
|
this.y = value - this.halfHeight;
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
/**
|
|
537
|
-
*
|
|
538
|
-
* @returns {number}
|
|
537
|
+
* Gets a random x coordinate within this rectangle.
|
|
538
|
+
* @returns {number} A random x coordinate within this rectangle.
|
|
539
539
|
*/
|
|
540
540
|
get randomX() {
|
|
541
541
|
return this.x + Math.random() * this.width;
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
/**
|
|
545
|
-
*
|
|
546
|
-
* @returns {number}
|
|
545
|
+
* Gets a random y coordinate within this rectangle.
|
|
546
|
+
* @returns {number} A random y coordinate within this rectangle.
|
|
547
547
|
*/
|
|
548
548
|
get randomY() {
|
|
549
549
|
return this.y + Math.random() * this.height;
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
/**
|
|
553
|
-
*
|
|
554
|
-
* @returns {boolean}
|
|
553
|
+
* Checks if this rectangle is empty (has zero width or height).
|
|
554
|
+
* @returns {boolean} True if the rectangle is empty, false otherwise.
|
|
555
555
|
*/
|
|
556
556
|
get empty() {
|
|
557
557
|
return !this.width || !this.height;
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
|
-
*
|
|
561
|
+
* Sets whether this rectangle is empty (zero width or height).
|
|
562
562
|
*/
|
|
563
563
|
set empty(value) {
|
|
564
564
|
if (value === true) {
|
|
@@ -3,12 +3,12 @@ import { GEOM_ROUNDED_RECTANGLE } from '../core/const.js';
|
|
|
3
3
|
|
|
4
4
|
export class RoundedRectangle {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {number} x -
|
|
8
|
-
* @param {number} y -
|
|
9
|
-
* @param {number} width -
|
|
10
|
-
* @param {number} height -
|
|
11
|
-
* @param {number} radius -
|
|
6
|
+
* Creates a new RoundedRectangle instance.
|
|
7
|
+
* @param {number} x - The x coordinate of the top-left corner of the rectangle (default: 0).
|
|
8
|
+
* @param {number} y - The y coordinate of the top-left corner of the rectangle (default: 0).
|
|
9
|
+
* @param {number} width - The width of the rectangle (default: 0).
|
|
10
|
+
* @param {number} height - The height of the rectangle (default: 0).
|
|
11
|
+
* @param {number} radius - The corner radius (default: 20).
|
|
12
12
|
*/
|
|
13
13
|
constructor(x = 0, y = 0, width = 0, height = 0, radius = 20) {
|
|
14
14
|
this.x = x;
|
|
@@ -20,10 +20,10 @@ export class RoundedRectangle {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {number} x -
|
|
25
|
-
* @param {number} y -
|
|
26
|
-
* @returns {boolean}
|
|
23
|
+
* Checks if the specified point is contained within this rounded rectangle.
|
|
24
|
+
* @param {number} x - The x coordinate of the point to check.
|
|
25
|
+
* @param {number} y - The y coordinate of the point to check.
|
|
26
|
+
* @returns {boolean} True if the point is contained within this rounded rectangle, false otherwise.
|
|
27
27
|
*/
|
|
28
28
|
contains(x, y) {
|
|
29
29
|
if (this.width <= 0 || this.height <= 0) {
|
|
@@ -38,8 +38,8 @@ export class RoundedRectangle {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @returns {RoundedRectangle}
|
|
41
|
+
* Creates a clone of this rounded rectangle.
|
|
42
|
+
* @returns {RoundedRectangle} A new rounded rectangle with the same values as this one.
|
|
43
43
|
*/
|
|
44
44
|
clone() {
|
|
45
45
|
return clone(this);
|