@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
@@ -32,7 +32,7 @@ export class Line {
32
32
  * @param {number} y2 - The new y coordinate of the end point.
33
33
  * @returns {Line} This line instance for chaining.
34
34
  */
35
- public setTo(x1: number, y1: number, x2: number, y2: number) {
35
+ public setTo(x1: number, y1: number, x2: number, y2: number): this {
36
36
  this.start.setTo(x1, y1);
37
37
  this.end.setTo(x2, y2);
38
38
  return this;
@@ -45,7 +45,7 @@ export class Line {
45
45
  * @param {boolean} useCenter - Whether to use the center of the sprites (default: false).
46
46
  * @returns {Line} This line instance for chaining.
47
47
  */
48
- public fromSprite(startSprite: any, endSprite: any, useCenter = false) {
48
+ public fromSprite(startSprite: any, endSprite: any, useCenter = false): this {
49
49
  if (useCenter) {
50
50
  return this.setTo(startSprite.center.x, startSprite.center.y, endSprite.center.x, endSprite.center.y);
51
51
  }
@@ -60,7 +60,7 @@ export class Line {
60
60
  * @param {number} length - The length of the line.
61
61
  * @returns {Line} This line instance for chaining.
62
62
  */
63
- public fromAngle(x: number, y: number, angle: number, length: number) {
63
+ public fromAngle(x: number, y: number, angle: number, length: number): this {
64
64
  this.start.setTo(x, y);
65
65
  this.end.setTo(x + Math.cos(angle) * length, y + Math.sin(angle) * length);
66
66
  return this;
@@ -72,7 +72,7 @@ export class Line {
72
72
  * @param {boolean} asDegrees - Whether the angle is provided in degrees (default: false).
73
73
  * @returns {Line} This line instance for chaining.
74
74
  */
75
- public rotate(angle: number, asDegrees = false) {
75
+ public rotate(angle: number, asDegrees = false): this {
76
76
  const cx = (this.start.x + this.end.x) / 2;
77
77
  const cy = (this.start.y + this.end.y) / 2;
78
78
  this.start.rotate(cx, cy, angle, asDegrees);
@@ -88,7 +88,7 @@ export class Line {
88
88
  * @param {boolean} asDegrees - Whether the angle is provided in degrees (default: false).
89
89
  * @returns {Line} This line instance for chaining.
90
90
  */
91
- public rotateAround(x: number, y: number, angle: number, asDegrees = false) {
91
+ public rotateAround(x: number, y: number, angle: number, asDegrees = false): this {
92
92
  this.start.rotate(x, y, angle, asDegrees);
93
93
  this.end.rotate(x, y, angle, asDegrees);
94
94
  return this;
@@ -101,7 +101,7 @@ export class Line {
101
101
  * @param {Point} result - The point to store the intersection in (optional).
102
102
  * @returns {Point} The intersection point, or null if no intersection occurs.
103
103
  */
104
- public intersects(line: Line, asSegment = true, result: Point | null = null) {
104
+ public intersects(line: Line, asSegment = true, result: Point | null = null): Point | null {
105
105
  return intersectsPoints(this.start, this.end, line.start, line.end, asSegment, result);
106
106
  }
107
107
 
@@ -110,7 +110,7 @@ export class Line {
110
110
  * @param {Line} line - The line to reflect off.
111
111
  * @returns {number} The angle of reflection in radians.
112
112
  */
113
- public reflect(line: Line) {
113
+ public reflect(line: Line): number {
114
114
  return reflect(this, line);
115
115
  }
116
116
 
@@ -119,7 +119,7 @@ export class Line {
119
119
  * @param {Point} output - The point to store the result in (optional).
120
120
  * @returns {Point} The midpoint of this line.
121
121
  */
122
- public midPoint(output: Point | null = null) {
122
+ public midPoint(output: Point | null = null): Point {
123
123
  const result = output ?? new Point();
124
124
  result.x = (this.start.x + this.end.x) / 2;
125
125
  result.y = (this.start.y + this.end.y) / 2;
@@ -131,7 +131,7 @@ export class Line {
131
131
  * @param {number} x - The x coordinate to center the line on.
132
132
  * @param {number} y - The y coordinate to center the line on.
133
133
  */
134
- public centerOn(x: number, y: number) {
134
+ public centerOn(x: number, y: number): void {
135
135
  const cx = (this.start.x + this.end.x) / 2;
136
136
  const cy = (this.start.y + this.end.y) / 2;
137
137
  const tx = x - cx;
@@ -146,7 +146,7 @@ export class Line {
146
146
  * @param {number} y - The y coordinate of the point to check.
147
147
  * @returns {boolean} True if the point lies on this line, false otherwise.
148
148
  */
149
- public pointOnLine(x: number, y: number) {
149
+ public pointOnLine(x: number, y: number): boolean {
150
150
  return (x - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (y - this.start.y);
151
151
  }
152
152
 
@@ -156,7 +156,7 @@ export class Line {
156
156
  * @param {number} y - The y coordinate of the point to check.
157
157
  * @returns {boolean} True if the point lies on this line segment, false otherwise.
158
158
  */
159
- public pointOnSegment(x: number, y: number) {
159
+ public pointOnSegment(x: number, y: number): boolean {
160
160
  const xMin = Math.min(this.start.x, this.end.x);
161
161
  const xMax = Math.max(this.start.x, this.end.x);
162
162
  const yMin = Math.min(this.start.y, this.end.y);
@@ -169,7 +169,7 @@ export class Line {
169
169
  * @param {Point} output - The point to store the result in (optional).
170
170
  * @returns {Point} A random point on this line.
171
171
  */
172
- public random(output: Point | null = null) {
172
+ public random(output: Point | null = null): Point {
173
173
  const result = output ?? new Point();
174
174
  const t = Math.random();
175
175
  result.x = this.start.x + t * (this.end.x - this.start.x);
@@ -183,7 +183,7 @@ export class Line {
183
183
  * @param {number[][]} results - The array to store the results in (optional).
184
184
  * @returns {number[][]} An array of coordinate pairs representing points along this line.
185
185
  */
186
- public coordinatesOnLine(stepRate = 1, results: number[][] = []) {
186
+ public coordinatesOnLine(stepRate = 1, results: number[][] = []): number[][] {
187
187
  let x1 = Math.round(this.start.x);
188
188
  let y1 = Math.round(this.start.y);
189
189
  const x2 = Math.round(this.end.x);
@@ -217,7 +217,7 @@ export class Line {
217
217
  * Creates a clone of this line.
218
218
  * @returns {Line} A new line with the same values as this one.
219
219
  */
220
- public clone() {
220
+ public clone(): Line {
221
221
  return clone(this);
222
222
  }
223
223
 
@@ -225,7 +225,7 @@ export class Line {
225
225
  * Gets the length of this line.
226
226
  * @returns {number} The length of this line.
227
227
  */
228
- public get length() {
228
+ public get length(): number {
229
229
  return Math.sqrt(
230
230
  (this.end.x - this.start.x) * (this.end.x - this.start.x) +
231
231
  (this.end.y - this.start.y) * (this.end.y - this.start.y)
@@ -236,7 +236,7 @@ export class Line {
236
236
  * Gets the angle of this line in radians.
237
237
  * @returns {number} The angle of this line in radians.
238
238
  */
239
- public get angle() {
239
+ public get angle(): number {
240
240
  return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x);
241
241
  }
242
242
 
@@ -244,7 +244,7 @@ export class Line {
244
244
  * Gets the slope of this line.
245
245
  * @returns {number} The slope of this line.
246
246
  */
247
- public get slope() {
247
+ public get slope(): number {
248
248
  return (this.end.y - this.start.y) / (this.end.x - this.start.x);
249
249
  }
250
250
 
@@ -252,7 +252,7 @@ export class Line {
252
252
  * Gets the perpendicular slope of this line.
253
253
  * @returns {number} The perpendicular slope of this line.
254
254
  */
255
- public get perpSlope() {
255
+ public get perpSlope(): number {
256
256
  return -((this.end.x - this.start.x) / (this.end.y - this.start.y));
257
257
  }
258
258
 
@@ -260,7 +260,7 @@ export class Line {
260
260
  * Gets the x coordinate of the leftmost point on this line.
261
261
  * @returns {number} The x coordinate of the leftmost point on this line.
262
262
  */
263
- public get x() {
263
+ public get x(): number {
264
264
  return Math.min(this.start.x, this.end.x);
265
265
  }
266
266
 
@@ -268,7 +268,7 @@ export class Line {
268
268
  * Gets the y coordinate of the topmost point on this line.
269
269
  * @returns {number} The y coordinate of the topmost point on this line.
270
270
  */
271
- public get y() {
271
+ public get y(): number {
272
272
  return Math.min(this.start.y, this.end.y);
273
273
  }
274
274
 
@@ -276,7 +276,7 @@ export class Line {
276
276
  * Gets the x coordinate of the leftmost point on this line.
277
277
  * @returns {number} The x coordinate of the leftmost point on this line.
278
278
  */
279
- public get left() {
279
+ public get left(): number {
280
280
  return Math.min(this.start.x, this.end.x);
281
281
  }
282
282
 
@@ -284,7 +284,7 @@ export class Line {
284
284
  * Gets the x coordinate of the rightmost point on this line.
285
285
  * @returns {number} The x coordinate of the rightmost point on this line.
286
286
  */
287
- public get right() {
287
+ public get right(): number {
288
288
  return Math.max(this.start.x, this.end.x);
289
289
  }
290
290
 
@@ -292,7 +292,7 @@ export class Line {
292
292
  * Gets the y coordinate of the topmost point on this line.
293
293
  * @returns {number} The y coordinate of the topmost point on this line.
294
294
  */
295
- public get top() {
295
+ public get top(): number {
296
296
  return Math.min(this.start.y, this.end.y);
297
297
  }
298
298
 
@@ -300,7 +300,7 @@ export class Line {
300
300
  * Gets the y coordinate of the bottommost point on this line.
301
301
  * @returns {number} The y coordinate of the bottommost point on this line.
302
302
  */
303
- public get bottom() {
303
+ public get bottom(): number {
304
304
  return Math.max(this.start.y, this.end.y);
305
305
  }
306
306
 
@@ -308,7 +308,7 @@ export class Line {
308
308
  * Gets the width of this line (absolute difference between x coordinates).
309
309
  * @returns {number} The width of this line.
310
310
  */
311
- public get width() {
311
+ public get width(): number {
312
312
  return Math.abs(this.start.x - this.end.x);
313
313
  }
314
314
 
@@ -316,7 +316,7 @@ export class Line {
316
316
  * Gets the height of this line (absolute difference between y coordinates).
317
317
  * @returns {number} The height of this line.
318
318
  */
319
- public get height() {
319
+ public get height(): number {
320
320
  return Math.abs(this.start.y - this.end.y);
321
321
  }
322
322
 
@@ -324,7 +324,7 @@ export class Line {
324
324
  * Gets the normal vector x component of this line (perpendicular to the line).
325
325
  * @returns {number} The normal vector x component of this line.
326
326
  */
327
- public get normalX() {
327
+ public get normalX(): number {
328
328
  return Math.cos(this.angle - 1.5707963267948966);
329
329
  }
330
330
 
@@ -332,7 +332,7 @@ export class Line {
332
332
  * Gets the normal vector y component of this line (perpendicular to the line).
333
333
  * @returns {number} The normal vector y component of this line.
334
334
  */
335
- public get normalY() {
335
+ public get normalY(): number {
336
336
  return Math.sin(this.angle - 1.5707963267948966);
337
337
  }
338
338
 
@@ -340,7 +340,7 @@ export class Line {
340
340
  * Gets the angle of the normal vector of this line in radians.
341
341
  * @returns {number} The angle of the normal vector of this line in radians.
342
342
  */
343
- public get normalAngle() {
343
+ public get normalAngle(): number {
344
344
  return wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI);
345
345
  }
346
346
  }
@@ -42,7 +42,7 @@ export class Matrix {
42
42
  * @param {number[]} array - The array to read the matrix components from (should have 6 elements).
43
43
  * @returns {Matrix} This matrix instance for chaining.
44
44
  */
45
- public fromArray(array: number[]) {
45
+ public fromArray(array: number[]): this {
46
46
  return this.setTo(array[0]!, array[1]!, array[3]!, array[4]!, array[2]!, array[5]!);
47
47
  }
48
48
 
@@ -56,7 +56,7 @@ export class Matrix {
56
56
  * @param {number} ty - The new ty component of the matrix.
57
57
  * @returns {Matrix} This matrix instance for chaining.
58
58
  */
59
- public setTo(a: number, b: number, c: number, d: number, tx: number, ty: number) {
59
+ public setTo(a: number, b: number, c: number, d: number, tx: number, ty: number): this {
60
60
  this.a = a;
61
61
  this.b = b;
62
62
  this.c = c;
@@ -70,7 +70,7 @@ export class Matrix {
70
70
  * Creates a clone of this matrix.
71
71
  * @returns {Matrix} A new matrix with the same values as this one.
72
72
  */
73
- public clone() {
73
+ public clone(): Matrix {
74
74
  return clone(this);
75
75
  }
76
76
 
@@ -79,7 +79,7 @@ export class Matrix {
79
79
  * @param {Matrix} matrix - The matrix to copy values to.
80
80
  * @returns {Matrix} The destination matrix.
81
81
  */
82
- public copyTo(matrix: Matrix) {
82
+ public copyTo(matrix: Matrix): Matrix {
83
83
  matrix.copyFrom(this);
84
84
  return matrix;
85
85
  }
@@ -89,7 +89,7 @@ export class Matrix {
89
89
  * @param {Matrix} matrix - The matrix to copy values from.
90
90
  * @returns {Matrix} This matrix instance for chaining.
91
91
  */
92
- public copyFrom(matrix: Matrix) {
92
+ public copyFrom(matrix: Matrix): this {
93
93
  this.a = matrix.a;
94
94
  this.b = matrix.b;
95
95
  this.c = matrix.c;
@@ -105,7 +105,7 @@ export class Matrix {
105
105
  * @param {Float32Array} output - The array to store the result in (optional).
106
106
  * @returns {Float32Array} A Float32Array containing the matrix elements.
107
107
  */
108
- public toArray(transpose = false, output: Float32Array | null = null) {
108
+ public toArray(transpose = false, output: Float32Array | null = null): Float32Array {
109
109
  const result = output ?? new Float32Array(9);
110
110
  if (transpose) {
111
111
  result[0] = this.a;
@@ -137,7 +137,7 @@ export class Matrix {
137
137
  * @param {Point} output - The point to store the result in (optional).
138
138
  * @returns {Point} The transformed point.
139
139
  */
140
- public apply(pos: Point, output: Point | null = null) {
140
+ public apply(pos: Point, output: Point | null = null): Point {
141
141
  const result = output ?? new Point();
142
142
  result.x = this.a * pos.x + this.c * pos.y + this.tx;
143
143
  result.y = this.b * pos.x + this.d * pos.y + this.ty;
@@ -150,7 +150,7 @@ export class Matrix {
150
150
  * @param {Point} output - The point to store the result in (optional).
151
151
  * @returns {Point} The transformed point.
152
152
  */
153
- public applyInverse(pos: Point, output: Point | null = null) {
153
+ public applyInverse(pos: Point, output: Point | null = null): Point {
154
154
  const result = output ?? new Point();
155
155
  const id = 1 / (this.a * this.d + this.c * -this.b);
156
156
  const { x } = pos;
@@ -166,7 +166,7 @@ export class Matrix {
166
166
  * @param {number} y - The amount to translate in the y direction.
167
167
  * @returns {Matrix} This matrix instance for chaining.
168
168
  */
169
- public translate(x: number, y: number) {
169
+ public translate(x: number, y: number): this {
170
170
  this.tx += x;
171
171
  this.ty += y;
172
172
  return this;
@@ -178,7 +178,7 @@ export class Matrix {
178
178
  * @param {number} y - The amount to scale in the y direction.
179
179
  * @returns {Matrix} This matrix instance for chaining.
180
180
  */
181
- public scale(x: number, y: number) {
181
+ public scale(x: number, y: number): this {
182
182
  this.a *= x;
183
183
  this.d *= y;
184
184
  this.c *= x;
@@ -193,7 +193,7 @@ export class Matrix {
193
193
  * @param {number} angle - The angle in radians to rotate by.
194
194
  * @returns {Matrix} This matrix instance for chaining.
195
195
  */
196
- public rotate(angle: number) {
196
+ public rotate(angle: number): this {
197
197
  const cos = Math.cos(angle);
198
198
  const sin = Math.sin(angle);
199
199
  const a1 = this.a;
@@ -213,7 +213,7 @@ export class Matrix {
213
213
  * @param {Matrix} matrix - The matrix to append.
214
214
  * @returns {Matrix} This matrix instance for chaining.
215
215
  */
216
- public append(matrix: Matrix) {
216
+ public append(matrix: Matrix): this {
217
217
  const a1 = this.a;
218
218
  const b1 = this.b;
219
219
  const c1 = this.c;
@@ -231,7 +231,7 @@ export class Matrix {
231
231
  * Sets this matrix to an identity matrix (no transformation).
232
232
  * @returns {Matrix} This matrix instance for chaining.
233
233
  */
234
- public identity() {
234
+ public identity(): this {
235
235
  return this.setTo(1, 0, 0, 1, 0, 0);
236
236
  }
237
237
  }
@@ -25,7 +25,7 @@ export class Point {
25
25
  * @param {Point} source - The point to copy coordinates from.
26
26
  * @returns {Point} This point instance for chaining.
27
27
  */
28
- public copyFrom(source: Point) {
28
+ public copyFrom(source: Point): this {
29
29
  return this.setTo(source.x, source.y);
30
30
  }
31
31
 
@@ -33,7 +33,7 @@ export class Point {
33
33
  * Returns a new point with the x and y coordinates swapped.
34
34
  * @returns {Point} A new point instance with swapped coordinates.
35
35
  */
36
- public invert() {
36
+ public invert(): this {
37
37
  return this.setTo(this.y, this.x);
38
38
  }
39
39
 
@@ -43,7 +43,7 @@ export class Point {
43
43
  * @param {number} y - The new y coordinate for the point.
44
44
  * @returns {Point} This point instance for chaining.
45
45
  */
46
- public setTo(x: number, y?: number) {
46
+ public setTo(x: number, y?: number): this {
47
47
  this.x = x || 0;
48
48
  this.y = y ?? (y !== 0 ? this.x : 0);
49
49
  return this;
@@ -56,7 +56,7 @@ export class Point {
56
56
  * @returns {Point} This point instance for chaining.
57
57
  * @deprecated Use setTo instead.
58
58
  */
59
- public set(x: number, y: number) {
59
+ public set(x: number, y: number): this {
60
60
  this.x = x || 0;
61
61
  this.y = y || (y !== 0 ? this.x : 0);
62
62
  return this;
@@ -68,7 +68,7 @@ export class Point {
68
68
  * @param {number} y - The amount to add to the y coordinate.
69
69
  * @returns {Point} This point instance for chaining.
70
70
  */
71
- public add(x: number, y: number) {
71
+ public add(x: number, y: number): this {
72
72
  this.x += x;
73
73
  this.y += y;
74
74
  return this;
@@ -80,7 +80,7 @@ export class Point {
80
80
  * @param {number} y - The amount to subtract from the y coordinate.
81
81
  * @returns {Point} This point instance for chaining.
82
82
  */
83
- public subtract(x: number, y: number) {
83
+ public subtract(x: number, y: number): this {
84
84
  this.x -= x;
85
85
  this.y -= y;
86
86
  return this;
@@ -92,7 +92,7 @@ export class Point {
92
92
  * @param {number} y - The amount to multiply the y coordinate by.
93
93
  * @returns {Point} This point instance for chaining.
94
94
  */
95
- public multiply(x: number, y: number) {
95
+ public multiply(x: number, y: number): this {
96
96
  this.x *= x;
97
97
  this.y *= y;
98
98
  return this;
@@ -104,7 +104,7 @@ export class Point {
104
104
  * @param {number} y - The amount to divide the y coordinate by.
105
105
  * @returns {Point} This point instance for chaining.
106
106
  */
107
- public divide(x: number, y: number) {
107
+ public divide(x: number, y: number): this {
108
108
  this.x /= x;
109
109
  this.y /= y;
110
110
  return this;
@@ -116,7 +116,7 @@ export class Point {
116
116
  * @param {number} max - The maximum value for the x coordinate.
117
117
  * @returns {Point} This point instance for chaining.
118
118
  */
119
- public clampX(min: number, max: number) {
119
+ public clampX(min: number, max: number): this {
120
120
  this.x = Math.max(min, Math.min(max, this.x));
121
121
  return this;
122
122
  }
@@ -127,7 +127,7 @@ export class Point {
127
127
  * @param {number} max - The maximum value for the y coordinate.
128
128
  * @returns {Point} This point instance for chaining.
129
129
  */
130
- public clampY(min: number, max: number) {
130
+ public clampY(min: number, max: number): this {
131
131
  this.y = Math.max(min, Math.min(max, this.y));
132
132
  return this;
133
133
  }
@@ -138,7 +138,7 @@ export class Point {
138
138
  * @param {number} max - The maximum value for both coordinates.
139
139
  * @returns {Point} This point instance for chaining.
140
140
  */
141
- public clamp(min: number, max: number) {
141
+ public clamp(min: number, max: number): this {
142
142
  this.x = Math.max(min, Math.min(max, this.x));
143
143
  this.y = Math.max(min, Math.min(max, this.y));
144
144
  return this;
@@ -148,7 +148,7 @@ export class Point {
148
148
  * Creates a clone of this point.
149
149
  * @returns {Point} A new point with the same coordinates as this one.
150
150
  */
151
- public clone() {
151
+ public clone(): Point {
152
152
  return clone(this);
153
153
  }
154
154
 
@@ -157,7 +157,7 @@ export class Point {
157
157
  * @param {Point} dest - The point to copy coordinates to.
158
158
  * @returns {Point} The destination point.
159
159
  */
160
- public copyTo(dest: Point) {
160
+ public copyTo(dest: Point): Point {
161
161
  dest.x = this.x;
162
162
  dest.y = this.y;
163
163
  return dest;
@@ -168,7 +168,7 @@ export class Point {
168
168
  * @param {Point} b - The other point to calculate the distance to.
169
169
  * @returns {number} The distance between the two points.
170
170
  */
171
- public distance(b: Point) {
171
+ public distance(b: Point): number {
172
172
  return distance(this, b);
173
173
  }
174
174
 
@@ -177,7 +177,7 @@ export class Point {
177
177
  * @param {Point} a - The other point to compare with.
178
178
  * @returns {boolean} True if the points have the same coordinates, false otherwise.
179
179
  */
180
- public equals(a: Point) {
180
+ public equals(a: Point): boolean {
181
181
  return a.x === this.x && a.y === this.y;
182
182
  }
183
183
 
@@ -187,7 +187,7 @@ export class Point {
187
187
  * @param {boolean} asDegrees - Whether to return the result in degrees (default: false).
188
188
  * @returns {number} The angle between the two points in radians or degrees.
189
189
  */
190
- public angle(a: Point, asDegrees = false) {
190
+ public angle(a: Point, asDegrees = false): number {
191
191
  if (asDegrees) {
192
192
  return (180 / Math.PI) * Math.atan2(a.y - this.y, a.x - this.x);
193
193
  }
@@ -203,7 +203,13 @@ export class Point {
203
203
  * @param {number | null | undefined} dist - The distance to rotate from (default: null).
204
204
  * @returns {Point} This point instance for chaining.
205
205
  */
206
- public rotate(x: number, y: number, angle: number, asDegrees: boolean, dist: number | null | undefined = null) {
206
+ public rotate(
207
+ x: number,
208
+ y: number,
209
+ angle: number,
210
+ asDegrees: boolean,
211
+ dist: number | null | undefined = null
212
+ ): Point {
207
213
  return rotate(this, x, y, angle, asDegrees, dist);
208
214
  }
209
215
 
@@ -211,7 +217,7 @@ export class Point {
211
217
  * Calculates the magnitude (length) of this point from the origin.
212
218
  * @returns {number} The magnitude of the point.
213
219
  */
214
- public getMagnitude() {
220
+ public getMagnitude(): number {
215
221
  return Math.sqrt(this.x * this.x + this.y * this.y);
216
222
  }
217
223
 
@@ -219,7 +225,7 @@ export class Point {
219
225
  * Calculates the square of the magnitude (length) of this point from the origin.
220
226
  * @returns {number} The square of the magnitude of the point.
221
227
  */
222
- public getMagnitudeSq() {
228
+ public getMagnitudeSq(): number {
223
229
  return this.x * this.x + this.y * this.y;
224
230
  }
225
231
 
@@ -228,7 +234,7 @@ export class Point {
228
234
  * @param {number} magnitude - The new magnitude for the point.
229
235
  * @returns {Point} This point instance for chaining.
230
236
  */
231
- public setMagnitude(magnitude: number) {
237
+ public setMagnitude(magnitude: number): this {
232
238
  return this.normalize().multiply(magnitude, magnitude);
233
239
  }
234
240
 
@@ -236,7 +242,7 @@ export class Point {
236
242
  * Normalizes this point to have a magnitude of 1 while preserving its direction.
237
243
  * @returns {Point} This point instance for chaining.
238
244
  */
239
- public normalize() {
245
+ public normalize(): this {
240
246
  if (!this.isZero()) {
241
247
  const m = this.getMagnitude();
242
248
  this.x /= m;
@@ -249,7 +255,7 @@ export class Point {
249
255
  * Checks if this point has zero magnitude (is at the origin).
250
256
  * @returns {boolean} True if both x and y coordinates are zero, false otherwise.
251
257
  */
252
- public isZero() {
258
+ public isZero(): boolean {
253
259
  return this.x === 0 && this.y === 0;
254
260
  }
255
261
 
@@ -258,7 +264,7 @@ export class Point {
258
264
  * @param {Point} a - The other point to calculate the dot product with.
259
265
  * @returns {number} The dot product of the two points.
260
266
  */
261
- public dot(a: Point) {
267
+ public dot(a: Point): number {
262
268
  return this.x * a.x + this.y * a.y;
263
269
  }
264
270
 
@@ -267,7 +273,7 @@ export class Point {
267
273
  * @param {Point} a - The other point to calculate the cross product with.
268
274
  * @returns {number} The cross product of the two points.
269
275
  */
270
- public cross(a: Point) {
276
+ public cross(a: Point): number {
271
277
  return this.x * a.y - this.y * a.x;
272
278
  }
273
279
 
@@ -275,7 +281,7 @@ export class Point {
275
281
  * Returns a perpendicular point (rotated 90 degrees counter-clockwise).
276
282
  * @returns {Point} A new point that is perpendicular to this one.
277
283
  */
278
- public perp() {
284
+ public perp(): this {
279
285
  return this.setTo(-this.y, this.x);
280
286
  }
281
287
 
@@ -283,7 +289,7 @@ export class Point {
283
289
  * Returns a perpendicular point (rotated 90 degrees clockwise).
284
290
  * @returns {Point} A new point that is perpendicular to this one (rotated clockwise).
285
291
  */
286
- public rperp() {
292
+ public rperp(): this {
287
293
  return this.setTo(this.y, -this.x);
288
294
  }
289
295
 
@@ -291,7 +297,7 @@ export class Point {
291
297
  * Returns a point with the same direction as this one but with y coordinate negated.
292
298
  * @returns {Point} A new point with the same x coordinate but negated y coordinate.
293
299
  */
294
- public normalRightHand() {
300
+ public normalRightHand(): this {
295
301
  return this.setTo(this.y * -1, this.x);
296
302
  }
297
303
 
@@ -299,7 +305,7 @@ export class Point {
299
305
  * Returns a new point with the x and y coordinates rounded down to the nearest integer.
300
306
  * @returns {Point} A new point with floored coordinates.
301
307
  */
302
- public floor() {
308
+ public floor(): this {
303
309
  return this.setTo(Math.floor(this.x), Math.floor(this.y));
304
310
  }
305
311
 
@@ -307,7 +313,7 @@ export class Point {
307
313
  * Returns a new point with the x and y coordinates rounded up to the nearest integer.
308
314
  * @returns {Point} A new point with ceiled coordinates.
309
315
  */
310
- public ceil() {
316
+ public ceil(): this {
311
317
  return this.setTo(Math.ceil(this.x), Math.ceil(this.y));
312
318
  }
313
319
 
@@ -315,7 +321,7 @@ export class Point {
315
321
  * Returns a string representation of this point.
316
322
  * @returns {string} A string representation of the point in the format "[Point (x=value y=value)]".
317
323
  */
318
- public toString() {
324
+ public toString(): string {
319
325
  return `[{Point (x=${this.x} y=${this.y})}]`;
320
326
  }
321
327
  }
@@ -34,7 +34,7 @@ export class Polygon {
34
34
  * @param {number[]} output - The array to store the result in (optional).
35
35
  * @returns {number[]} An array of numbers representing the polygon's points.
36
36
  */
37
- public toNumberArray(output: number[] = []) {
37
+ public toNumberArray(output: number[] = []): number[] {
38
38
  for (let i = 0; i < this._points.length; i += 1) {
39
39
  if (typeof this._points[i] === 'number') {
40
40
  output.push(this._points[i]);
@@ -52,7 +52,7 @@ export class Polygon {
52
52
  * Flattens the polygon's point array to a simple numeric array.
53
53
  * @returns {Polygon} This polygon instance for chaining.
54
54
  */
55
- public flatten() {
55
+ public flatten(): this {
56
56
  this._points = this.toNumberArray();
57
57
  this.flattened = true;
58
58
  return this;
@@ -62,7 +62,7 @@ export class Polygon {
62
62
  * Creates a clone of this polygon.
63
63
  * @returns {Polygon} A new polygon with the same values as this one.
64
64
  */
65
- public clone() {
65
+ public clone(): Polygon {
66
66
  return clone(this);
67
67
  }
68
68
 
@@ -72,7 +72,7 @@ export class Polygon {
72
72
  * @param {number} y - The y coordinate of the point to check.
73
73
  * @returns {boolean} True if the point is contained within this polygon, false otherwise.
74
74
  */
75
- public contains(x: number, y: number) {
75
+ public contains(x: number, y: number): boolean {
76
76
  // Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva
77
77
  let inside = false;
78
78
  if (this.flattened) {
@@ -104,7 +104,7 @@ export class Polygon {
104
104
  * @param {object[]} points - The array of points to define the polygon.
105
105
  * @returns {Polygon} This polygon instance for chaining.
106
106
  */
107
- public setTo(points: any[]) {
107
+ public setTo(points: any[]): this {
108
108
  this.area = 0;
109
109
  this._points = [];
110
110
  if (points) {
@@ -143,7 +143,7 @@ export class Polygon {
143
143
  * @param {number} y0 - The y coordinate of the lowest boundary (internal use).
144
144
  * @returns {number} The area of this polygon.
145
145
  */
146
- public calculateArea(y0: number) {
146
+ public calculateArea(y0: number): number {
147
147
  let p1;
148
148
  let p2;
149
149
  let avgHeight;