@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
@@ -7,7 +7,7 @@ import { Point } from '../point.js';
7
7
  * @param {Point} output - The point to store the result in (optional).
8
8
  * @returns {Point} A new point containing the sum of the two points.
9
9
  */
10
- export const add = (a: Point, b: Point, output: Point | null = null) => {
10
+ export const add = (a: Point, b: Point, output: Point | null = null): Point => {
11
11
  const result = output ?? new Point();
12
12
  result.x = a.x + b.x;
13
13
  result.y = a.y + b.y;
@@ -21,7 +21,7 @@ export const add = (a: Point, b: Point, output: Point | null = null) => {
21
21
  * @param {Point} output - The point to store the result in (optional).
22
22
  * @returns {Point} A new point containing the difference of the two points.
23
23
  */
24
- export const subtract = (a: Point, b: Point, output: Point | null = null) => {
24
+ export const subtract = (a: Point, b: Point, output: Point | null = null): Point => {
25
25
  const result = output ?? new Point();
26
26
  result.x = a.x - b.x;
27
27
  result.y = a.y - b.y;
@@ -35,7 +35,7 @@ export const subtract = (a: Point, b: Point, output: Point | null = null) => {
35
35
  * @param {Point} output - The point to store the result in (optional).
36
36
  * @returns {Point} A new point containing the product of the two points.
37
37
  */
38
- export const multiply = (a: Point, b: Point, output: Point | null = null) => {
38
+ export const multiply = (a: Point, b: Point, output: Point | null = null): Point => {
39
39
  const result = output ?? new Point();
40
40
  result.x = a.x * b.x;
41
41
  result.y = a.y * b.y;
@@ -49,7 +49,7 @@ export const multiply = (a: Point, b: Point, output: Point | null = null) => {
49
49
  * @param {Point} output - The point to store the result in (optional).
50
50
  * @returns {Point} A new point containing the quotient of the two points.
51
51
  */
52
- export const divide = (a: Point, b: Point, output: Point | null = null) => {
52
+ export const divide = (a: Point, b: Point, output: Point | null = null): Point => {
53
53
  const result = output ?? new Point();
54
54
  result.x = a.x / b.x;
55
55
  result.y = a.y / b.y;
@@ -62,7 +62,7 @@ export const divide = (a: Point, b: Point, output: Point | null = null) => {
62
62
  * @param {Point} b - The second point to compare.
63
63
  * @returns {boolean} True if the points are equal, false otherwise.
64
64
  */
65
- export const equals = (a: Point, b: Point) => a.x === b.x && a.y === b.y;
65
+ export const equals = (a: Point, b: Point): boolean => a.x === b.x && a.y === b.y;
66
66
 
67
67
  /**
68
68
  * Calculates the angle between two points.
@@ -70,7 +70,7 @@ export const equals = (a: Point, b: Point) => a.x === b.x && a.y === b.y;
70
70
  * @param {Point} b - The second point to calculate the angle to.
71
71
  * @returns {number} The angle between the two points in radians.
72
72
  */
73
- export const angle = (a: Point, b: Point) => Math.atan2(a.y - b.y, a.x - b.x);
73
+ export const angle = (a: Point, b: Point): number => Math.atan2(a.y - b.y, a.x - b.x);
74
74
 
75
75
  /**
76
76
  * Creates a new point with the same coordinates as the input point but with inverted signs.
@@ -78,7 +78,7 @@ export const angle = (a: Point, b: Point) => Math.atan2(a.y - b.y, a.x - b.x);
78
78
  * @param {Point} output - The point to store the result in (optional).
79
79
  * @returns {Point} A new point with negated coordinates.
80
80
  */
81
- export const negative = (a: Point, output: Point | null = null) => {
81
+ export const negative = (a: Point, output: Point | null = null): Point => {
82
82
  const result = output ?? new Point();
83
83
  return result.setTo(-a.x, -a.y);
84
84
  };
@@ -91,7 +91,7 @@ export const negative = (a: Point, output: Point | null = null) => {
91
91
  * @param {Point} output - The point to store the result in (optional).
92
92
  * @returns {Point} A new point with the result of the operation.
93
93
  */
94
- export const multiplyAdd = (a: Point, b: Point, s: number, output: Point | null = null) => {
94
+ export const multiplyAdd = (a: Point, b: Point, s: number, output: Point | null = null): Point => {
95
95
  const result = output ?? new Point();
96
96
  return result.setTo(a.x + b.x * s, a.y + b.y * s);
97
97
  };
@@ -104,7 +104,7 @@ export const multiplyAdd = (a: Point, b: Point, s: number, output: Point | null
104
104
  * @param {Point} output - The point to store the result in (optional).
105
105
  * @returns {Point} A new point interpolated between the two points.
106
106
  */
107
- export const interpolate = (a: Point, b: Point, f: number, output: Point | null = null) => {
107
+ export const interpolate = (a: Point, b: Point, f: number, output: Point | null = null): Point => {
108
108
  const result = output ?? new Point();
109
109
  return result.setTo(a.x + (b.x - a.x) * f, a.y + (b.y - a.y) * f);
110
110
  };
@@ -115,7 +115,7 @@ export const interpolate = (a: Point, b: Point, f: number, output: Point | null
115
115
  * @param {Point} output - The point to store the result in (optional).
116
116
  * @returns {Point} A new point that is perpendicular to the input point.
117
117
  */
118
- export const perp = (a: Point, output: Point | null = null) => {
118
+ export const perp = (a: Point, output: Point | null = null): Point => {
119
119
  const result = output ?? new Point();
120
120
  return result.setTo(-a.y, a.x);
121
121
  };
@@ -126,7 +126,7 @@ export const perp = (a: Point, output: Point | null = null) => {
126
126
  * @param {Point} output - The point to store the result in (optional).
127
127
  * @returns {Point} A new point that is perpendicular to the input point (rotated clockwise).
128
128
  */
129
- export const rperp = (a: Point, output: Point | null = null) => {
129
+ export const rperp = (a: Point, output: Point | null = null): Point => {
130
130
  const result = output ?? new Point();
131
131
  return result.setTo(a.y, -a.x);
132
132
  };
@@ -138,7 +138,7 @@ export const rperp = (a: Point, output: Point | null = null) => {
138
138
  * @param {boolean} round - Whether to round the result (default: false).
139
139
  * @returns {number} The distance between the two points.
140
140
  */
141
- export const distance = (a: Point, b: Point, round = false) => {
141
+ export const distance = (a: Point, b: Point, round = false): number => {
142
142
  const dx = a.x - b.x;
143
143
  const dy = a.y - b.y;
144
144
  const abDistance = Math.sqrt(dx * dx + dy * dy);
@@ -152,7 +152,7 @@ export const distance = (a: Point, b: Point, round = false) => {
152
152
  * @param {Point} output - The point to store the result in (optional).
153
153
  * @returns {Point} A new point with the projected result.
154
154
  */
155
- export const project = (a: Point, b: Point, output: Point | null = null) => {
155
+ export const project = (a: Point, b: Point, output: Point | null = null): Point => {
156
156
  const result = output ?? new Point();
157
157
  const amt = a.dot(b) / b.getMagnitudeSq();
158
158
  if (amt !== 0) {
@@ -168,7 +168,7 @@ export const project = (a: Point, b: Point, output: Point | null = null) => {
168
168
  * @param {Point} output - The point to store the result in (optional).
169
169
  * @returns {Point} A new point with the projected result.
170
170
  */
171
- export const projectUnit = (a: Point, b: Point, output: Point | null = null) => {
171
+ export const projectUnit = (a: Point, b: Point, output: Point | null = null): Point => {
172
172
  const result = output ?? new Point();
173
173
  const amt = a.dot(b);
174
174
  if (amt !== 0) {
@@ -183,7 +183,7 @@ export const projectUnit = (a: Point, b: Point, output: Point | null = null) =>
183
183
  * @param {Point} output - The point to store the result in (optional).
184
184
  * @returns {Point} A new point with the same x coordinate but negated y coordinate.
185
185
  */
186
- export const normalRightHand = (a: Point, output: Point | null = null) => {
186
+ export const normalRightHand = (a: Point, output: Point | null = null): Point => {
187
187
  const result = output ?? new Point();
188
188
  return result.setTo(a.y * -1, a.x);
189
189
  };
@@ -194,7 +194,7 @@ export const normalRightHand = (a: Point, output: Point | null = null) => {
194
194
  * @param {Point} output - The point to store the result in (optional).
195
195
  * @returns {Point} A new normalized point.
196
196
  */
197
- export const normalize = (a: Point, output: Point | null = null) => {
197
+ export const normalize = (a: Point, output: Point | null = null): Point => {
198
198
  const result = output ?? new Point();
199
199
  const m = a.getMagnitude();
200
200
  if (m !== 0) {
@@ -220,7 +220,7 @@ export const rotate = (
220
220
  ang: number,
221
221
  asDegrees: boolean,
222
222
  dist: number | null | undefined
223
- ) => {
223
+ ): Point => {
224
224
  if (asDegrees) {
225
225
  ang *= Math.PI / 180;
226
226
  }
@@ -247,7 +247,7 @@ export const rotate = (
247
247
  * @returns {Point} A new point representing the centroid of the input points.
248
248
  * @throws {Error} If the points array is empty.
249
249
  */
250
- export const centroid = (points: Point[], output: Point | null = null) => {
250
+ export const centroid = (points: Point[], output: Point | null = null): Point => {
251
251
  const result = output ?? new Point();
252
252
  const pointsLen = points.length;
253
253
  if (pointsLen < 1) {
@@ -271,7 +271,7 @@ export const centroid = (points: Point[], output: Point | null = null) => {
271
271
  * @param {string} yProp - The name of the property containing the y value (default: 'y').
272
272
  * @returns {Point} A new point with parsed x and y values.
273
273
  */
274
- export const parse = (obj: any, xProp = 'x', yProp = 'y') => {
274
+ export const parse = (obj: any, xProp = 'x', yProp = 'y'): Point => {
275
275
  const point = new Point();
276
276
  if (obj[xProp]) {
277
277
  point.x = Math.trunc(Number(obj[xProp]));
@@ -288,7 +288,7 @@ export const parse = (obj: any, xProp = 'x', yProp = 'y') => {
288
288
  * @param {Point} output - The point to store the result in (optional).
289
289
  * @returns {Point} A new point with the same coordinates as the input.
290
290
  */
291
- export const clone = (input: Point, output: Point | null = null) => {
291
+ export const clone = (input: Point, output: Point | null = null): Point => {
292
292
  const result = output ?? new Point();
293
293
  result.setTo(input.x, input.y);
294
294
  return result;
@@ -6,7 +6,7 @@ import { Polygon } from '../polygon.js';
6
6
  * @param {Polygon} output - Optional polygon to store the result in.
7
7
  * @returns {Polygon} The cloned polygon.
8
8
  */
9
- export const clone = (input: Polygon, output: Polygon | null = null) => {
9
+ export const clone = (input: Polygon, output: Polygon | null = null): Polygon => {
10
10
  const result = output ?? new Polygon();
11
11
  result.setTo([...input._points]);
12
12
  return result;
@@ -9,7 +9,7 @@ import { getRegistry } from '../../core/registry.js';
9
9
  * @param {number} dy - The amount to inflate the rectangle vertically.
10
10
  * @returns {Rectangle} The inflated rectangle.
11
11
  */
12
- export const inflate = (a: Rectangle, dx: number, dy: number) => {
12
+ export const inflate = (a: Rectangle, dx: number, dy: number): Rectangle => {
13
13
  a.x -= dx;
14
14
  a.width += 2 * dx;
15
15
  a.y -= dy;
@@ -23,7 +23,7 @@ export const inflate = (a: Rectangle, dx: number, dy: number) => {
23
23
  * @param {object} point - The point containing x and y values to inflate the rectangle by.
24
24
  * @returns {Rectangle} The inflated rectangle.
25
25
  */
26
- export const inflatePoint = (a: Rectangle, point: any) => inflate(a, point.x, point.y);
26
+ export const inflatePoint = (a: Rectangle, point: any): Rectangle => inflate(a, point.x, point.y);
27
27
 
28
28
  /**
29
29
  * Gets the size of the rectangle as a point.
@@ -31,7 +31,7 @@ export const inflatePoint = (a: Rectangle, point: any) => inflate(a, point.x, po
31
31
  * @param {Point} output - Optional point to store the result in.
32
32
  * @returns {Point} The size of the rectangle as a point (width, height).
33
33
  */
34
- export const size = (a: Rectangle, output: Point | null = null) => {
34
+ export const size = (a: Rectangle, output: Point | null = null): Point => {
35
35
  const result = output ?? new Point();
36
36
  result.setTo(a.width, a.height);
37
37
  return result;
@@ -43,7 +43,7 @@ export const size = (a: Rectangle, output: Point | null = null) => {
43
43
  * @param {Rectangle} output - Optional rectangle to store the result in.
44
44
  * @returns {Rectangle} The cloned rectangle.
45
45
  */
46
- export const clone = (input: Rectangle, output: Rectangle | null = null) => {
46
+ export const clone = (input: Rectangle, output: Rectangle | null = null): Rectangle => {
47
47
  const result = output ?? new Rectangle();
48
48
  result.setTo(input.x, input.y, input.width, input.height);
49
49
  return result;
@@ -56,7 +56,7 @@ export const clone = (input: Rectangle, output: Rectangle | null = null) => {
56
56
  * @param {number} y - The y coordinate of the point.
57
57
  * @returns {boolean} True if the point is contained within the rectangle, false otherwise.
58
58
  */
59
- export const contains = (a: Rectangle, x: number, y: number) => {
59
+ export const contains = (a: Rectangle, x: number, y: number): boolean => {
60
60
  if (a.width <= 0 || a.height <= 0) {
61
61
  return false;
62
62
  }
@@ -73,7 +73,7 @@ export const contains = (a: Rectangle, x: number, y: number) => {
73
73
  * @param {number} y - The y coordinate of the point.
74
74
  * @returns {boolean} True if the point is contained within the rectangle, false otherwise.
75
75
  */
76
- export const containsRaw = (rx: number, ry: number, rw: number, rh: number, x: number, y: number) =>
76
+ export const containsRaw = (rx: number, ry: number, rw: number, rh: number, x: number, y: number): boolean =>
77
77
  x >= rx && x < rx + rw && y >= ry && y < ry + rh;
78
78
 
79
79
  /**
@@ -82,7 +82,7 @@ export const containsRaw = (rx: number, ry: number, rw: number, rh: number, x: n
82
82
  * @param {Point} point - The point to check.
83
83
  * @returns {boolean} True if the point is contained within the rectangle, false otherwise.
84
84
  */
85
- export const containsPoint = (a: Rectangle, point: Point) => contains(a, point.x, point.y);
85
+ export const containsPoint = (a: Rectangle, point: Point): boolean => contains(a, point.x, point.y);
86
86
 
87
87
  /**
88
88
  * Checks if rectangle a contains rectangle b.
@@ -90,7 +90,7 @@ export const containsPoint = (a: Rectangle, point: Point) => contains(a, point.x
90
90
  * @param {Rectangle} b - The second rectangle to check.
91
91
  * @returns {boolean} True if rectangle a contains rectangle b, false otherwise.
92
92
  */
93
- export const containsRect = (a: Rectangle, b: Rectangle) => {
93
+ export const containsRect = (a: Rectangle, b: Rectangle): boolean => {
94
94
  if (a.volume > b.volume) {
95
95
  return false;
96
96
  }
@@ -103,7 +103,7 @@ export const containsRect = (a: Rectangle, b: Rectangle) => {
103
103
  * @param {Rectangle} b - The second rectangle to compare.
104
104
  * @returns {boolean} True if the rectangles are equal, false otherwise.
105
105
  */
106
- export const equals = (a: Rectangle, b: Rectangle) =>
106
+ export const equals = (a: Rectangle, b: Rectangle): boolean =>
107
107
  a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
108
108
 
109
109
  /**
@@ -112,7 +112,7 @@ export const equals = (a: Rectangle, b: Rectangle) =>
112
112
  * @param {Rectangle} b - The second rectangle to compare.
113
113
  * @returns {boolean} True if the rectangles have the same dimensions, false otherwise.
114
114
  */
115
- export const sameDimensions = (a: Rectangle, b: Rectangle) => a.width === b.width && a.height === b.height;
115
+ export const sameDimensions = (a: Rectangle, b: Rectangle): boolean => a.width === b.width && a.height === b.height;
116
116
 
117
117
  /**
118
118
  * Checks if two rectangles intersect.
@@ -120,7 +120,17 @@ export const sameDimensions = (a: Rectangle, b: Rectangle) => a.width === b.widt
120
120
  * @param {Rectangle} b - The second rectangle to check.
121
121
  * @returns {boolean} True if the rectangles intersect, false otherwise.
122
122
  */
123
- export const intersects = (a: Rectangle, b: Rectangle) => {
123
+ /** Anything with an axis-aligned extent, which Line exposes as well as Rectangle. */
124
+ export type Bounds = {
125
+ x: number;
126
+ y: number;
127
+ width: number;
128
+ height: number;
129
+ right: number;
130
+ bottom: number;
131
+ };
132
+
133
+ export const intersects = (a: Bounds, b: Bounds): boolean => {
124
134
  if (a.width <= 0 || a.height <= 0 || b.width <= 0 || b.height <= 0) {
125
135
  return false;
126
136
  }
@@ -134,7 +144,7 @@ export const intersects = (a: Rectangle, b: Rectangle) => {
134
144
  * @param {Rectangle} output - Optional rectangle to store the result in.
135
145
  * @returns {Rectangle} The intersection of the rectangles, or an empty rectangle if they don't intersect.
136
146
  */
137
- export const intersection = (a: Rectangle, b: Rectangle, output: Rectangle | null = null) => {
147
+ export const intersection = (a: Rectangle, b: Rectangle, output: Rectangle | null = null): Rectangle => {
138
148
  const result = output ?? new Rectangle();
139
149
  if (intersects(a, b)) {
140
150
  result.x = Math.max(a.x, b.x);
@@ -155,7 +165,14 @@ export const intersection = (a: Rectangle, b: Rectangle, output: Rectangle | nul
155
165
  * @param {number} tolerance - Optional tolerance value for intersection.
156
166
  * @returns {boolean} True if the rectangle intersects with the area, false otherwise.
157
167
  */
158
- export const intersectsRaw = (a: Rectangle, left: number, right: number, top: number, bottom: number, tolerance = 0) =>
168
+ export const intersectsRaw = (
169
+ a: Rectangle,
170
+ left: number,
171
+ right: number,
172
+ top: number,
173
+ bottom: number,
174
+ tolerance = 0
175
+ ): boolean =>
159
176
  !(
160
177
  left > a.right + tolerance ||
161
178
  right < a.left - tolerance ||
@@ -170,7 +187,7 @@ export const intersectsRaw = (a: Rectangle, left: number, right: number, top: nu
170
187
  * @param {Rectangle} output - Optional rectangle to store the result in.
171
188
  * @returns {Rectangle} The union of the rectangles.
172
189
  */
173
- export const union = (a: Rectangle, b: Rectangle, output: Rectangle | null = null) => {
190
+ export const union = (a: Rectangle, b: Rectangle, output: Rectangle | null = null): Rectangle => {
174
191
  const result = output ?? new Rectangle();
175
192
  return result.setTo(
176
193
  Math.min(a.x, b.x),
@@ -186,13 +203,13 @@ export const union = (a: Rectangle, b: Rectangle, output: Rectangle | null = nul
186
203
  * @param {Rectangle} output - Optional rectangle to store the result in.
187
204
  * @returns {Rectangle} The AABB of the points.
188
205
  */
189
- export const aabb = (points: Point[], output: Rectangle | null = null) => {
206
+ export const aabb = (points: Point[], output: Rectangle | null = null): Rectangle => {
190
207
  const result = output ?? new Rectangle();
191
208
  let xMax = Number.NEGATIVE_INFINITY;
192
209
  let xMin = Number.POSITIVE_INFINITY;
193
210
  let yMax = Number.NEGATIVE_INFINITY;
194
211
  let yMin = Number.POSITIVE_INFINITY;
195
- points.forEach((point) => {
212
+ points.forEach((point): void => {
196
213
  if (point.x > xMax) {
197
214
  xMax = point.x;
198
215
  }
@@ -214,7 +231,7 @@ export const aabb = (points: Point[], output: Rectangle | null = null) => {
214
231
  * Gets an empty rectangle instance.
215
232
  * @returns {Rectangle} An empty rectangle.
216
233
  */
217
- export const getEmptyRectangle = () => {
234
+ export const getEmptyRectangle = (): Rectangle => {
218
235
  getRegistry();
219
236
  globalThis.PhaserRegistry.EMPTY_RECTANGLE ??= new Rectangle();
220
237
  return globalThis.PhaserRegistry.EMPTY_RECTANGLE;
@@ -6,7 +6,7 @@ import { RoundedRectangle } from '../rounded_rectangle.js';
6
6
  * @param {RoundedRectangle} output - Optional rounded rectangle to store the result in.
7
7
  * @returns {RoundedRectangle} The cloned rounded rectangle.
8
8
  */
9
- export const clone = (input: RoundedRectangle, output: RoundedRectangle | null = null) => {
9
+ export const clone = (input: RoundedRectangle, output: RoundedRectangle | null = null): RoundedRectangle => {
10
10
  const result = output ?? new RoundedRectangle();
11
11
  result.x = input.x;
12
12
  result.y = input.y;