@vpmedia/phaser 1.115.0 → 1.117.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.
Files changed (193) hide show
  1. package/dist/index.js +56 -96
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts.map +1 -1
  4. package/dist/phaser/core/animation_manager.d.ts +15 -14
  5. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  6. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  7. package/dist/phaser/core/array_set.d.ts.map +1 -1
  8. package/dist/phaser/core/cache.d.ts +10 -9
  9. package/dist/phaser/core/cache.d.ts.map +1 -1
  10. package/dist/phaser/core/device_util.d.ts.map +1 -1
  11. package/dist/phaser/core/dom.d.ts.map +1 -1
  12. package/dist/phaser/core/factory.d.ts.map +1 -1
  13. package/dist/phaser/core/game.d.ts.map +1 -1
  14. package/dist/phaser/core/input.d.ts +20 -20
  15. package/dist/phaser/core/input.d.ts.map +1 -1
  16. package/dist/phaser/core/input_handler.d.ts +11 -13
  17. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  18. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  19. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  20. package/dist/phaser/core/input_pointer.d.ts +19 -8
  21. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  22. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  23. package/dist/phaser/core/loader.d.ts.map +1 -1
  24. package/dist/phaser/core/raf.d.ts.map +1 -1
  25. package/dist/phaser/core/scale_manager.d.ts +38 -13
  26. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  27. package/dist/phaser/core/scene.d.ts.map +1 -1
  28. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  29. package/dist/phaser/core/signal.d.ts.map +1 -1
  30. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  31. package/dist/phaser/core/sound.d.ts +2 -2
  32. package/dist/phaser/core/sound.d.ts.map +1 -1
  33. package/dist/phaser/core/sound_manager.d.ts +24 -22
  34. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  35. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  36. package/dist/phaser/core/stage.d.ts.map +1 -1
  37. package/dist/phaser/core/time.d.ts.map +1 -1
  38. package/dist/phaser/core/timer.d.ts +1 -1
  39. package/dist/phaser/core/timer.d.ts.map +1 -1
  40. package/dist/phaser/core/tween.d.ts.map +1 -1
  41. package/dist/phaser/core/tween_data.d.ts +26 -26
  42. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  43. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  44. package/dist/phaser/core/world.d.ts.map +1 -1
  45. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  46. package/dist/phaser/display/button.d.ts.map +1 -1
  47. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  48. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  49. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  50. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  51. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  52. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  53. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  54. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  55. package/dist/phaser/display/display_object.d.ts.map +1 -1
  56. package/dist/phaser/display/graphics.d.ts.map +1 -1
  57. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  58. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  59. package/dist/phaser/display/group.d.ts.map +1 -1
  60. package/dist/phaser/display/image.d.ts +2 -2
  61. package/dist/phaser/display/image.d.ts.map +1 -1
  62. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  63. package/dist/phaser/display/text.d.ts.map +1 -1
  64. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  65. package/dist/phaser/display/webgl/base_texture.d.ts +12 -10
  66. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  67. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  68. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  69. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +13 -12
  70. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  71. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  72. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  73. package/dist/phaser/display/webgl/graphics.d.ts +9 -7
  74. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  75. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  76. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  77. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  78. package/dist/phaser/display/webgl/renderer.d.ts +12 -10
  79. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  80. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  82. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  84. package/dist/phaser/display/webgl/texture.d.ts +18 -33
  85. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  86. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  88. package/dist/phaser/geom/circle.d.ts.map +1 -1
  89. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  90. package/dist/phaser/geom/line.d.ts.map +1 -1
  91. package/dist/phaser/geom/matrix.d.ts +1 -1
  92. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  93. package/dist/phaser/geom/point.d.ts.map +1 -1
  94. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  95. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  96. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  97. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  98. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  99. package/dist/phaser/geom/util/line.d.ts +5 -4
  100. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  101. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  102. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  103. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  104. package/dist/phaser/geom/util/rectangle.d.ts +10 -1
  105. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  106. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  107. package/package.json +1 -1
  108. package/src/phaser/core/animation.ts +20 -20
  109. package/src/phaser/core/animation_manager.ts +27 -24
  110. package/src/phaser/core/animation_parser.ts +2 -2
  111. package/src/phaser/core/array_set.ts +7 -7
  112. package/src/phaser/core/cache.ts +55 -51
  113. package/src/phaser/core/callback_context.test.ts +70 -0
  114. package/src/phaser/core/device_util.ts +13 -13
  115. package/src/phaser/core/dom.ts +26 -22
  116. package/src/phaser/core/factory.ts +6 -6
  117. package/src/phaser/core/game.ts +10 -10
  118. package/src/phaser/core/input.ts +37 -39
  119. package/src/phaser/core/input_handler.ts +90 -93
  120. package/src/phaser/core/input_mouse.ts +19 -19
  121. package/src/phaser/core/input_mspointer.ts +15 -15
  122. package/src/phaser/core/input_pointer.ts +37 -28
  123. package/src/phaser/core/input_touch.ts +17 -17
  124. package/src/phaser/core/loader.ts +52 -52
  125. package/src/phaser/core/loader_parser.ts +3 -3
  126. package/src/phaser/core/raf.ts +3 -3
  127. package/src/phaser/core/scale_manager.ts +86 -67
  128. package/src/phaser/core/scene.ts +7 -7
  129. package/src/phaser/core/scene_manager.ts +16 -16
  130. package/src/phaser/core/signal.ts +29 -19
  131. package/src/phaser/core/signal_binding.ts +4 -4
  132. package/src/phaser/core/sound.ts +17 -17
  133. package/src/phaser/core/sound_manager.ts +71 -72
  134. package/src/phaser/core/sound_sprite.ts +1 -1
  135. package/src/phaser/core/stage.ts +7 -7
  136. package/src/phaser/core/time.ts +16 -16
  137. package/src/phaser/core/timer.ts +36 -26
  138. package/src/phaser/core/tween.ts +23 -23
  139. package/src/phaser/core/tween_data.ts +41 -37
  140. package/src/phaser/core/tween_manager.ts +11 -11
  141. package/src/phaser/core/world.ts +1 -1
  142. package/src/phaser/display/bitmap_text.ts +13 -13
  143. package/src/phaser/display/button.ts +13 -13
  144. package/src/phaser/display/canvas/buffer.ts +3 -3
  145. package/src/phaser/display/canvas/graphics.ts +3 -3
  146. package/src/phaser/display/canvas/masker.ts +2 -2
  147. package/src/phaser/display/canvas/pool.ts +6 -6
  148. package/src/phaser/display/canvas/renderer.ts +6 -6
  149. package/src/phaser/display/canvas/tinter.ts +39 -8
  150. package/src/phaser/display/canvas/util.ts +15 -9
  151. package/src/phaser/display/display_object.ts +38 -38
  152. package/src/phaser/display/graphics.ts +30 -30
  153. package/src/phaser/display/graphics_data.ts +1 -1
  154. package/src/phaser/display/graphics_data_util.ts +1 -1
  155. package/src/phaser/display/group.ts +16 -16
  156. package/src/phaser/display/image.ts +30 -26
  157. package/src/phaser/display/sprite_util.ts +12 -4
  158. package/src/phaser/display/text.ts +55 -55
  159. package/src/phaser/display/webgl/abstract_filter.ts +1 -1
  160. package/src/phaser/display/webgl/base_texture.ts +22 -18
  161. package/src/phaser/display/webgl/blend_manager.ts +3 -3
  162. package/src/phaser/display/webgl/earcut.ts +3 -3
  163. package/src/phaser/display/webgl/fast_sprite_batch.ts +26 -24
  164. package/src/phaser/display/webgl/filter_manager.ts +7 -7
  165. package/src/phaser/display/webgl/filter_texture.ts +3 -3
  166. package/src/phaser/display/webgl/graphics.ts +43 -41
  167. package/src/phaser/display/webgl/graphics_data.ts +2 -2
  168. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  169. package/src/phaser/display/webgl/render_texture.ts +6 -6
  170. package/src/phaser/display/webgl/renderer.ts +20 -25
  171. package/src/phaser/display/webgl/shader/normal.ts +3 -3
  172. package/src/phaser/display/webgl/shader_manager.ts +2 -2
  173. package/src/phaser/display/webgl/sprite_batch.ts +9 -9
  174. package/src/phaser/display/webgl/stencil_manager.ts +4 -4
  175. package/src/phaser/display/webgl/texture.ts +23 -42
  176. package/src/phaser/display/webgl/texture_util.ts +2 -2
  177. package/src/phaser/display/webgl/util.ts +11 -7
  178. package/src/phaser/geom/circle.ts +21 -21
  179. package/src/phaser/geom/ellipse.ts +7 -7
  180. package/src/phaser/geom/line.ts +29 -29
  181. package/src/phaser/geom/matrix.ts +13 -13
  182. package/src/phaser/geom/point.ts +36 -30
  183. package/src/phaser/geom/polygon.ts +6 -6
  184. package/src/phaser/geom/rectangle.ts +42 -42
  185. package/src/phaser/geom/rounded_rectangle.ts +2 -2
  186. package/src/phaser/geom/util/circle.ts +7 -7
  187. package/src/phaser/geom/util/ellipse.ts +1 -1
  188. package/src/phaser/geom/util/line.ts +13 -5
  189. package/src/phaser/geom/util/matrix.ts +3 -3
  190. package/src/phaser/geom/util/point.ts +20 -20
  191. package/src/phaser/geom/util/polygon.ts +1 -1
  192. package/src/phaser/geom/util/rectangle.ts +34 -17
  193. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
@@ -57,7 +57,7 @@ export class Rectangle {
57
57
  * @param {number} dy - The amount to offset the y coordinate by.
58
58
  * @returns {Rectangle} This rectangle instance for chaining.
59
59
  */
60
- public offset(dx: number, dy: number) {
60
+ public offset(dx: number, dy: number): this {
61
61
  this.x += dx;
62
62
  this.y += dy;
63
63
  return this;
@@ -68,7 +68,7 @@ export class Rectangle {
68
68
  * @param {Point} point - The point to offset the rectangle by.
69
69
  * @returns {Rectangle} This rectangle instance for chaining.
70
70
  */
71
- public offsetPoint(point: Point) {
71
+ public offsetPoint(point: Point): this {
72
72
  return this.offset(point.x, point.y);
73
73
  }
74
74
 
@@ -80,7 +80,7 @@ export class Rectangle {
80
80
  * @param {number} height - The new height of the rectangle.
81
81
  * @returns {Rectangle} This rectangle instance for chaining.
82
82
  */
83
- public setTo(x: number, y: number, width: number, height: number) {
83
+ public setTo(x: number, y: number, width: number, height: number): this {
84
84
  this.x = x;
85
85
  this.y = y;
86
86
  this.width = width;
@@ -94,7 +94,7 @@ export class Rectangle {
94
94
  * @param {number} y - The amount to scale the height by (default: x).
95
95
  * @returns {Rectangle} This rectangle instance for chaining.
96
96
  */
97
- public scale(x: number, y?: number) {
97
+ public scale(x: number, y?: number): this {
98
98
  y ??= x;
99
99
  this.width *= x;
100
100
  this.height *= y;
@@ -107,7 +107,7 @@ export class Rectangle {
107
107
  * @param {number} y - The y coordinate to center the rectangle on.
108
108
  * @returns {Rectangle} This rectangle instance for chaining.
109
109
  */
110
- public centerOn(x: number, y: number) {
110
+ public centerOn(x: number, y: number): this {
111
111
  this.centerX = x;
112
112
  this.centerY = y;
113
113
  return this;
@@ -116,7 +116,7 @@ export class Rectangle {
116
116
  /**
117
117
  * Floors the x and y coordinates of the rectangle (rounds down to nearest integer).
118
118
  */
119
- public floor() {
119
+ public floor(): void {
120
120
  this.x = Math.floor(this.x);
121
121
  this.y = Math.floor(this.y);
122
122
  }
@@ -124,7 +124,7 @@ export class Rectangle {
124
124
  /**
125
125
  * Floors all coordinates of the rectangle (rounds down to nearest integer).
126
126
  */
127
- public floorAll() {
127
+ public floorAll(): void {
128
128
  this.x = Math.floor(this.x);
129
129
  this.y = Math.floor(this.y);
130
130
  this.width = Math.floor(this.width);
@@ -134,7 +134,7 @@ export class Rectangle {
134
134
  /**
135
135
  * Ceils the x and y coordinates of the rectangle (rounds up to nearest integer).
136
136
  */
137
- public ceil() {
137
+ public ceil(): void {
138
138
  this.x = Math.ceil(this.x);
139
139
  this.y = Math.ceil(this.y);
140
140
  }
@@ -142,7 +142,7 @@ export class Rectangle {
142
142
  /**
143
143
  * Ceils all coordinates of the rectangle (rounds up to nearest integer).
144
144
  */
145
- public ceilAll() {
145
+ public ceilAll(): void {
146
146
  this.x = Math.ceil(this.x);
147
147
  this.y = Math.ceil(this.y);
148
148
  this.width = Math.ceil(this.width);
@@ -154,7 +154,7 @@ export class Rectangle {
154
154
  * @param {Rectangle} source - The rectangle to copy values from.
155
155
  * @returns {Rectangle} This rectangle instance for chaining.
156
156
  */
157
- public copyFrom(source: Rectangle) {
157
+ public copyFrom(source: Rectangle): this {
158
158
  return this.setTo(source.x, source.y, source.width, source.height);
159
159
  }
160
160
 
@@ -163,7 +163,7 @@ export class Rectangle {
163
163
  * @param {Rectangle} dest - The rectangle to copy values to.
164
164
  * @returns {Rectangle} The destination rectangle.
165
165
  */
166
- public copyTo(dest: Rectangle) {
166
+ public copyTo(dest: Rectangle): Rectangle {
167
167
  dest.x = this.x;
168
168
  dest.y = this.y;
169
169
  dest.width = this.width;
@@ -177,7 +177,7 @@ export class Rectangle {
177
177
  * @param {number} dy - The amount to increase the height by.
178
178
  * @returns {Rectangle} This rectangle instance for chaining.
179
179
  */
180
- public inflate(dx: number, dy: number) {
180
+ public inflate(dx: number, dy: number): Rectangle {
181
181
  return inflate(this, dx, dy);
182
182
  }
183
183
 
@@ -186,7 +186,7 @@ export class Rectangle {
186
186
  * @param {Point} output - The point to store the size in (optional).
187
187
  * @returns {Point} The size of the rectangle as a point.
188
188
  */
189
- public size(output: Point) {
189
+ public size(output: Point): Point {
190
190
  return size(this, output);
191
191
  }
192
192
 
@@ -196,7 +196,7 @@ export class Rectangle {
196
196
  * @param {number} height - The new height of the rectangle.
197
197
  * @returns {Rectangle} This rectangle instance for chaining.
198
198
  */
199
- public resize(width: number, height: number) {
199
+ public resize(width: number, height: number): this {
200
200
  this.width = width;
201
201
  this.height = height;
202
202
  return this;
@@ -207,7 +207,7 @@ export class Rectangle {
207
207
  * @param {Rectangle} output - The rectangle to store the clone in (optional).
208
208
  * @returns {Rectangle} A new rectangle with the same values as this one.
209
209
  */
210
- public clone(output?: Rectangle) {
210
+ public clone(output?: Rectangle): Rectangle {
211
211
  return clone(this, output);
212
212
  }
213
213
 
@@ -217,7 +217,7 @@ export class Rectangle {
217
217
  * @param {number} y - The y coordinate of the point to check.
218
218
  * @returns {boolean} True if the point is contained within this rectangle, false otherwise.
219
219
  */
220
- public contains(x: number, y: number) {
220
+ public contains(x: number, y: number): boolean {
221
221
  return contains(this, x, y);
222
222
  }
223
223
 
@@ -226,7 +226,7 @@ export class Rectangle {
226
226
  * @param {Rectangle} b - The rectangle to check if it's contained.
227
227
  * @returns {boolean} True if the rectangle is contained within this rectangle, false otherwise.
228
228
  */
229
- public containsRect(b: Rectangle) {
229
+ public containsRect(b: Rectangle): boolean {
230
230
  return containsRect(b, this);
231
231
  }
232
232
 
@@ -235,7 +235,7 @@ export class Rectangle {
235
235
  * @param {Rectangle} b - The rectangle to compare with.
236
236
  * @returns {boolean} True if the rectangles have the same values, false otherwise.
237
237
  */
238
- public equals(b: Rectangle) {
238
+ public equals(b: Rectangle): boolean {
239
239
  return equals(this, b);
240
240
  }
241
241
 
@@ -245,7 +245,7 @@ export class Rectangle {
245
245
  * @param {Rectangle} out - The rectangle to store the result in (optional).
246
246
  * @returns {Rectangle} The intersection of the two rectangles.
247
247
  */
248
- public intersection(b: Rectangle, out?: Rectangle) {
248
+ public intersection(b: Rectangle, out?: Rectangle): Rectangle {
249
249
  return intersection(this, b, out);
250
250
  }
251
251
 
@@ -254,7 +254,7 @@ export class Rectangle {
254
254
  * @param {Rectangle} b - The rectangle to check for intersection with.
255
255
  * @returns {boolean} True if the rectangles intersect, false otherwise.
256
256
  */
257
- public intersects(b: Rectangle) {
257
+ public intersects(b: Rectangle): boolean {
258
258
  return intersects(this, b);
259
259
  }
260
260
 
@@ -267,7 +267,7 @@ export class Rectangle {
267
267
  * @param {number} tolerance - A tolerance value to use when checking (default: 0).
268
268
  * @returns {boolean} True if the rectangle intersects with the bounds, false otherwise.
269
269
  */
270
- public intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number) {
270
+ public intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number): boolean {
271
271
  return intersectsRaw(this, left, right, top, bottom, tolerance);
272
272
  }
273
273
 
@@ -277,7 +277,7 @@ export class Rectangle {
277
277
  * @param {Rectangle} out - The rectangle to store the result in (optional).
278
278
  * @returns {Rectangle} The union of the two rectangles.
279
279
  */
280
- public union(b: Rectangle, out?: Rectangle) {
280
+ public union(b: Rectangle, out?: Rectangle): Rectangle {
281
281
  return union(this, b, out);
282
282
  }
283
283
 
@@ -286,7 +286,7 @@ export class Rectangle {
286
286
  * @param {Point} output - The point to store the result in (optional).
287
287
  * @returns {Point} A random point within this rectangle.
288
288
  */
289
- public random(output: Point | null = null) {
289
+ public random(output: Point | null = null): Point {
290
290
  const result = output ?? new Point();
291
291
  result.x = this.randomX;
292
292
  result.y = this.randomY;
@@ -299,7 +299,7 @@ export class Rectangle {
299
299
  * @param {Point} output - The point to store the result in (optional).
300
300
  * @returns {Point} A point at the specified position on the rectangle.
301
301
  */
302
- public getPoint(position: number, output: Point | null = null) {
302
+ public getPoint(position: number, output: Point | null = null): Point {
303
303
  const result = output ?? new Point();
304
304
  switch (position) {
305
305
  case TOP_LEFT: {
@@ -339,7 +339,7 @@ export class Rectangle {
339
339
  * Returns a string representation of this rectangle.
340
340
  * @returns {string} A string representation of the rectangle.
341
341
  */
342
- public toString() {
342
+ public toString(): string {
343
343
  return `[{Rectangle (x=${this.x} y=${this.y} width=${this.width} height=${this.height} empty=${this.empty})}]`;
344
344
  }
345
345
 
@@ -347,7 +347,7 @@ export class Rectangle {
347
347
  * Gets half the width of this rectangle.
348
348
  * @returns {number} Half the width of this rectangle.
349
349
  */
350
- public get halfWidth() {
350
+ public get halfWidth(): number {
351
351
  return Math.round(this.width / 2);
352
352
  }
353
353
 
@@ -355,7 +355,7 @@ export class Rectangle {
355
355
  * Gets half the height of this rectangle.
356
356
  * @returns {number} Half the height of this rectangle.
357
357
  */
358
- public get halfHeight() {
358
+ public get halfHeight(): number {
359
359
  return Math.round(this.height / 2);
360
360
  }
361
361
 
@@ -363,7 +363,7 @@ export class Rectangle {
363
363
  * Gets the top coordinate of this rectangle.
364
364
  * @returns {number} The top coordinate of this rectangle.
365
365
  */
366
- public get top() {
366
+ public get top(): number {
367
367
  return this.y;
368
368
  }
369
369
 
@@ -383,7 +383,7 @@ export class Rectangle {
383
383
  * Gets the top-left point of this rectangle.
384
384
  * @returns {Point} The top-left point of this rectangle.
385
385
  */
386
- public get topLeft() {
386
+ public get topLeft(): Point {
387
387
  return new Point(this.x, this.y);
388
388
  }
389
389
 
@@ -399,7 +399,7 @@ export class Rectangle {
399
399
  * Gets the top-right point of this rectangle.
400
400
  * @returns {Point} The top-right point of this rectangle.
401
401
  */
402
- public get topRight() {
402
+ public get topRight(): Point {
403
403
  return new Point(this.x + this.width, this.y);
404
404
  }
405
405
 
@@ -415,7 +415,7 @@ export class Rectangle {
415
415
  * Gets the bottom coordinate of this rectangle.
416
416
  * @returns {number} The bottom coordinate of this rectangle.
417
417
  */
418
- public get bottom() {
418
+ public get bottom(): number {
419
419
  return this.y + this.height;
420
420
  }
421
421
 
@@ -434,7 +434,7 @@ export class Rectangle {
434
434
  * Gets the bottom-left point of this rectangle.
435
435
  * @returns {Point} The bottom-left point of this rectangle.
436
436
  */
437
- public get bottomLeft() {
437
+ public get bottomLeft(): Point {
438
438
  return new Point(this.x, this.bottom);
439
439
  }
440
440
 
@@ -450,7 +450,7 @@ export class Rectangle {
450
450
  * Gets the bottom-right point of this rectangle.
451
451
  * @returns {Point} The bottom-right point of this rectangle.
452
452
  */
453
- public get bottomRight() {
453
+ public get bottomRight(): Point {
454
454
  return new Point(this.right, this.bottom);
455
455
  }
456
456
 
@@ -466,7 +466,7 @@ export class Rectangle {
466
466
  * Gets the left coordinate of this rectangle.
467
467
  * @returns {number} The left coordinate of this rectangle.
468
468
  */
469
- public get left() {
469
+ public get left(): number {
470
470
  return this.x;
471
471
  }
472
472
 
@@ -486,7 +486,7 @@ export class Rectangle {
486
486
  * Gets the right coordinate of this rectangle.
487
487
  * @returns {number} The right coordinate of this rectangle.
488
488
  */
489
- public get right() {
489
+ public get right(): number {
490
490
  return this.x + this.width;
491
491
  }
492
492
 
@@ -505,7 +505,7 @@ export class Rectangle {
505
505
  * Gets the volume (area) of this rectangle.
506
506
  * @returns {number} The volume (area) of this rectangle.
507
507
  */
508
- public get volume() {
508
+ public get volume(): number {
509
509
  return this.width * this.height;
510
510
  }
511
511
 
@@ -513,7 +513,7 @@ export class Rectangle {
513
513
  * Gets the perimeter of this rectangle.
514
514
  * @returns {number} The perimeter of this rectangle.
515
515
  */
516
- public get perimeter() {
516
+ public get perimeter(): number {
517
517
  return this.width * 2 + this.height * 2;
518
518
  }
519
519
 
@@ -521,7 +521,7 @@ export class Rectangle {
521
521
  * Gets the x coordinate of the center of this rectangle.
522
522
  * @returns {number} The x coordinate of the center of this rectangle.
523
523
  */
524
- public get centerX() {
524
+ public get centerX(): number {
525
525
  return this.x + this.halfWidth;
526
526
  }
527
527
 
@@ -536,7 +536,7 @@ export class Rectangle {
536
536
  * Gets the y coordinate of the center of this rectangle.
537
537
  * @returns {number} The y coordinate of the center of this rectangle.
538
538
  */
539
- public get centerY() {
539
+ public get centerY(): number {
540
540
  return this.y + this.halfHeight;
541
541
  }
542
542
 
@@ -551,7 +551,7 @@ export class Rectangle {
551
551
  * Gets a random x coordinate within this rectangle.
552
552
  * @returns {number} A random x coordinate within this rectangle.
553
553
  */
554
- public get randomX() {
554
+ public get randomX(): number {
555
555
  return this.x + Math.random() * this.width;
556
556
  }
557
557
 
@@ -559,7 +559,7 @@ export class Rectangle {
559
559
  * Gets a random y coordinate within this rectangle.
560
560
  * @returns {number} A random y coordinate within this rectangle.
561
561
  */
562
- public get randomY() {
562
+ public get randomY(): number {
563
563
  return this.y + Math.random() * this.height;
564
564
  }
565
565
 
@@ -567,7 +567,7 @@ export class Rectangle {
567
567
  * Checks if this rectangle is empty (has zero width or height).
568
568
  * @returns {boolean} True if the rectangle is empty, false otherwise.
569
569
  */
570
- public get empty() {
570
+ public get empty(): boolean {
571
571
  return !this.width || !this.height;
572
572
  }
573
573
 
@@ -32,7 +32,7 @@ export class RoundedRectangle {
32
32
  * @param {number} y - The y coordinate of the point to check.
33
33
  * @returns {boolean} True if the point is contained within this rounded rectangle, false otherwise.
34
34
  */
35
- public contains(x: number, y: number) {
35
+ public contains(x: number, y: number): boolean {
36
36
  if (this.width <= 0 || this.height <= 0) {
37
37
  return false;
38
38
  }
@@ -48,7 +48,7 @@ export class RoundedRectangle {
48
48
  * Creates a clone of this rounded rectangle.
49
49
  * @returns {RoundedRectangle} A new rounded rectangle with the same values as this one.
50
50
  */
51
- public clone() {
51
+ public clone(): RoundedRectangle {
52
52
  return clone(this);
53
53
  }
54
54
  }
@@ -8,7 +8,7 @@ import { Point } from '../point.js';
8
8
  * @param {Circle} output - Optional circle to store the result in.
9
9
  * @returns {Circle} The cloned circle.
10
10
  */
11
- export const clone = (input: Circle, output: Circle | null = null) => {
11
+ export const clone = (input: Circle, output: Circle | null = null): Circle => {
12
12
  const result = output ?? new Circle();
13
13
  result.x = input.x;
14
14
  result.y = input.y;
@@ -23,7 +23,7 @@ export const clone = (input: Circle, output: Circle | null = null) => {
23
23
  * @param {number} y - The y coordinate of the point.
24
24
  * @returns {boolean} True if the point is contained within the circle, false otherwise.
25
25
  */
26
- export const contains = (a: Circle, x: number, y: number) => {
26
+ export const contains = (a: Circle, x: number, y: number): boolean => {
27
27
  if (a.radius > 0 && x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) {
28
28
  const dx = (a.x - x) * (a.x - x);
29
29
  const dy = (a.y - y) * (a.y - y);
@@ -38,7 +38,7 @@ export const contains = (a: Circle, x: number, y: number) => {
38
38
  * @param {Circle} b - The second circle to compare.
39
39
  * @returns {boolean} True if the circles are equal, false otherwise.
40
40
  */
41
- export const equals = (a: Circle, b: Circle) => a.x === b.x && a.y === b.y && a.diameter === b.diameter;
41
+ export const equals = (a: Circle, b: Circle): boolean => a.x === b.x && a.y === b.y && a.diameter === b.diameter;
42
42
 
43
43
  /**
44
44
  * Checks if two circles intersect.
@@ -46,7 +46,7 @@ export const equals = (a: Circle, b: Circle) => a.x === b.x && a.y === b.y && a.
46
46
  * @param {Circle} b - The second circle to check.
47
47
  * @returns {boolean} True if the circles intersect, false otherwise.
48
48
  */
49
- export const intersects = (a: Circle, b: Circle) => distance(a.x, a.y, b.x, b.y) <= a.radius + b.radius;
49
+ export const intersects = (a: Circle, b: Circle): boolean => distance(a.x, a.y, b.x, b.y) <= a.radius + b.radius;
50
50
 
51
51
  /**
52
52
  * Gets a point on the circumference of the circle at the specified angle.
@@ -56,7 +56,7 @@ export const intersects = (a: Circle, b: Circle) => distance(a.x, a.y, b.x, b.y)
56
56
  * @param {Point} output - Optional point to store the result in.
57
57
  * @returns {Point} The point on the circumference of the circle.
58
58
  */
59
- export const circumferencePoint = (a: Circle, angle: number, asDegrees = false, output: Point | null = null) => {
59
+ export const circumferencePoint = (a: Circle, angle: number, asDegrees = false, output: Point | null = null): Point => {
60
60
  const result = output ?? new Point();
61
61
  if (asDegrees) {
62
62
  angle = degToRad(angle);
@@ -74,7 +74,7 @@ export const circumferencePoint = (a: Circle, angle: number, asDegrees = false,
74
74
  * @param {Point} output - Optional point to store the result in.
75
75
  * @returns {Point} The point on the circumference of the circle.
76
76
  */
77
- export const intersectsPoint = (a: Circle, angle: number, asDegrees = false, output: Point | null = null) => {
77
+ export const intersectsPoint = (a: Circle, angle: number, asDegrees = false, output: Point | null = null): Point => {
78
78
  const result = output ?? new Point();
79
79
  if (asDegrees) {
80
80
  angle = degToRad(angle);
@@ -90,7 +90,7 @@ export const intersectsPoint = (a: Circle, angle: number, asDegrees = false, out
90
90
  * @param {object} r - The rectangle to check.
91
91
  * @returns {boolean} True if the circle intersects with the rectangle, false otherwise.
92
92
  */
93
- export const intersectsRectangle = (c: Circle, r: any) => {
93
+ export const intersectsRectangle = (c: Circle, r: any): boolean => {
94
94
  const cx = Math.abs(c.x - r.x - r.halfWidth);
95
95
  const xDist = r.halfWidth + c.radius;
96
96
  if (cx > xDist) {
@@ -6,7 +6,7 @@ import type { Ellipse } from '../ellipse.js';
6
6
  * @param {number} y - The y coordinate of the point.
7
7
  * @returns {boolean} True if the point is contained within the ellipse, false otherwise.
8
8
  */
9
- export const contains = (a: Ellipse, x: number, y: number) => {
9
+ export const contains = (a: Ellipse, x: number, y: number): boolean => {
10
10
  if (a.width <= 0 || a.height <= 0) {
11
11
  return false;
12
12
  }
@@ -1,3 +1,4 @@
1
+ import type { Rectangle } from '../rectangle.js';
1
2
  import { Line } from '../line.js';
2
3
  import { Point } from '../point.js';
3
4
  import { intersects as intersectsRect } from './rectangle.js';
@@ -8,7 +9,7 @@ import { intersects as intersectsRect } from './rectangle.js';
8
9
  * @param {Line} output - Optional line to store the result in.
9
10
  * @returns {Line} The cloned line.
10
11
  */
11
- export const clone = (input: Line, output: Line | null = null) => {
12
+ export const clone = (input: Line, output: Line | null = null): Line => {
12
13
  const result = output ?? new Line();
13
14
  result.start.x = input.start.x;
14
15
  result.start.y = input.start.y;
@@ -27,7 +28,14 @@ export const clone = (input: Line, output: Line | null = null) => {
27
28
  * @param {Point} output - Optional point to store the result in.
28
29
  * @returns {Point} The intersection point, or null if there is no intersection.
29
30
  */
30
- export const intersectsPoints = (a: any, b: any, e: any, f: any, asSegment = true, output: Point | null = null) => {
31
+ export const intersectsPoints = (
32
+ a: Point,
33
+ b: Point,
34
+ e: Point,
35
+ f: Point,
36
+ asSegment = true,
37
+ output: Point | null = null
38
+ ): Point | null => {
31
39
  const result = output ?? new Point();
32
40
  const a1 = b.y - a.y;
33
41
  const a2 = f.y - e.y;
@@ -61,7 +69,7 @@ export const intersectsPoints = (a: any, b: any, e: any, f: any, asSegment = tru
61
69
  * @param {Point} result - Optional point to store the result in.
62
70
  * @returns {Point} The intersection point, or null if there is no intersection.
63
71
  */
64
- export const intersects = (a: any, b: any, asSegment: boolean, result: Point) =>
72
+ export const intersects = (a: Line, b: Line, asSegment: boolean, result: Point): Point | null =>
65
73
  intersectsPoints(a.start, a.end, b.start, b.end, asSegment, result);
66
74
 
67
75
  /**
@@ -70,7 +78,7 @@ export const intersects = (a: any, b: any, asSegment: boolean, result: Point) =>
70
78
  * @param {object} rect - The rectangle to check (with x, y, width, height properties).
71
79
  * @returns {boolean} True if the line intersects with the rectangle, false otherwise.
72
80
  */
73
- export const intersectsRectangle = (line: any, rect: any) => {
81
+ export const intersectsRectangle = (line: Line, rect: Rectangle): boolean => {
74
82
  // Quick bail out of the Line and Rect bounds don't intersect
75
83
  if (!intersectsRect(line, rect)) {
76
84
  return false;
@@ -124,4 +132,4 @@ export const intersectsRectangle = (line: any, rect: any) => {
124
132
  * @param {object} b - The second point (with x, y properties).
125
133
  * @returns {number} The distance between the points.
126
134
  */
127
- export const reflect = (a: any, b: any) => 2 * b.normalAngle - Math.PI - a.angle;
135
+ export const reflect = (a: Line, b: Line): number => 2 * b.normalAngle - Math.PI - a.angle;
@@ -7,7 +7,7 @@ import { getRegistry } from '../../core/registry.js';
7
7
  * @param {Matrix} output - Optional matrix to store the result in.
8
8
  * @returns {Matrix} The cloned matrix.
9
9
  */
10
- export const clone = (input: Matrix, output: Matrix | null = null) => {
10
+ export const clone = (input: Matrix, output: Matrix | null = null): Matrix => {
11
11
  const result = output ?? new Matrix();
12
12
  result.a = input.a;
13
13
  result.b = input.b;
@@ -22,7 +22,7 @@ export const clone = (input: Matrix, output: Matrix | null = null) => {
22
22
  * Creates a new identity matrix.
23
23
  * @returns {Matrix} A new identity matrix.
24
24
  */
25
- export const getIdentityMatrix = () => {
25
+ export const getIdentityMatrix = (): Matrix => {
26
26
  getRegistry();
27
27
  globalThis.PhaserRegistry.IDENTITY_MATRIX ??= new Matrix();
28
28
  return globalThis.PhaserRegistry.IDENTITY_MATRIX;
@@ -32,7 +32,7 @@ export const getIdentityMatrix = () => {
32
32
  * Creates a new matrix with the specified values.
33
33
  * @returns {Matrix} A new matrix.
34
34
  */
35
- export const getTempMatrix = () => {
35
+ export const getTempMatrix = (): Matrix => {
36
36
  getRegistry();
37
37
  globalThis.PhaserRegistry.TEMP_MATRIX ??= new Matrix();
38
38
  return globalThis.PhaserRegistry.TEMP_MATRIX;