@vpmedia/phaser 1.123.0 → 1.124.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 (206) hide show
  1. package/dist/index.js +339 -323
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +3 -3
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  6. package/dist/phaser/core/animation_parser.d.ts +27 -2
  7. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  8. package/dist/phaser/core/array_set.d.ts +11 -11
  9. package/dist/phaser/core/array_set.d.ts.map +1 -1
  10. package/dist/phaser/core/cache.d.ts.map +1 -1
  11. package/dist/phaser/core/callback.d.ts.map +1 -1
  12. package/dist/phaser/core/dom.d.ts +125 -19
  13. package/dist/phaser/core/dom.d.ts.map +1 -1
  14. package/dist/phaser/core/factory.d.ts +3 -2
  15. package/dist/phaser/core/factory.d.ts.map +1 -1
  16. package/dist/phaser/core/input.d.ts +3 -2
  17. package/dist/phaser/core/input.d.ts.map +1 -1
  18. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  19. package/dist/phaser/core/input_mouse.d.ts +5 -1
  20. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  21. package/dist/phaser/core/input_pointer.d.ts +3 -3
  22. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  23. package/dist/phaser/core/input_touch.d.ts +8 -8
  24. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  25. package/dist/phaser/core/loader.d.ts +11 -2
  26. package/dist/phaser/core/loader.d.ts.map +1 -1
  27. package/dist/phaser/core/loader_parser.d.ts +14 -1
  28. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  29. package/dist/phaser/core/raf.d.ts +1 -1
  30. package/dist/phaser/core/raf.d.ts.map +1 -1
  31. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  32. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  33. package/dist/phaser/core/signal.d.ts.map +1 -1
  34. package/dist/phaser/core/sound.d.ts.map +1 -1
  35. package/dist/phaser/core/sound_manager.d.ts +1 -1
  36. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  37. package/dist/phaser/core/stage.d.ts +16 -6
  38. package/dist/phaser/core/stage.d.ts.map +1 -1
  39. package/dist/phaser/core/time.d.ts.map +1 -1
  40. package/dist/phaser/core/timer.d.ts +1 -1
  41. package/dist/phaser/core/timer.d.ts.map +1 -1
  42. package/dist/phaser/core/tween.d.ts +13 -5
  43. package/dist/phaser/core/tween.d.ts.map +1 -1
  44. package/dist/phaser/core/tween_data.d.ts +9 -7
  45. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  46. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  47. package/dist/phaser/display/button.d.ts +6 -5
  48. package/dist/phaser/display/button.d.ts.map +1 -1
  49. package/dist/phaser/display/canvas/buffer.d.ts +1 -1
  50. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  51. package/dist/phaser/display/canvas/masker.d.ts +1 -1
  52. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  53. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  54. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  55. package/dist/phaser/display/canvas/renderer.d.ts +9 -8
  56. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  57. package/dist/phaser/display/display_object.d.ts +3 -1
  58. package/dist/phaser/display/display_object.d.ts.map +1 -1
  59. package/dist/phaser/display/graphics.d.ts +1 -1
  60. package/dist/phaser/display/graphics.d.ts.map +1 -1
  61. package/dist/phaser/display/group.d.ts +1 -1
  62. package/dist/phaser/display/group.d.ts.map +1 -1
  63. package/dist/phaser/display/image.d.ts +6 -5
  64. package/dist/phaser/display/image.d.ts.map +1 -1
  65. package/dist/phaser/display/sprite_util.d.ts +3 -2
  66. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  67. package/dist/phaser/display/text.d.ts +2 -16
  68. package/dist/phaser/display/text.d.ts.map +1 -1
  69. package/dist/phaser/display/webgl/abstract_filter.d.ts +14 -8
  70. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  71. package/dist/phaser/display/webgl/blend_manager.d.ts +2 -3
  72. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  73. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +11 -5
  74. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  75. package/dist/phaser/display/webgl/filter_manager.d.ts +6 -4
  76. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  77. package/dist/phaser/display/webgl/filter_texture.d.ts +4 -4
  78. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  79. package/dist/phaser/display/webgl/graphics.d.ts +2 -2
  80. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/mask_manager.d.ts +3 -2
  82. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/render_texture.d.ts +11 -8
  84. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  85. package/dist/phaser/display/webgl/renderer.d.ts +8 -4
  86. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/shader/normal.d.ts +28 -3
  88. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  89. package/dist/phaser/display/webgl/sprite_batch.d.ts +6 -5
  90. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  91. package/dist/phaser/display/webgl/stencil_manager.d.ts +3 -3
  92. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  93. package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
  94. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  95. package/dist/phaser/display/webgl/util.d.ts +1 -1
  96. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  97. package/dist/phaser/geom/circle.d.ts.map +1 -1
  98. package/dist/phaser/geom/line.d.ts +10 -1
  99. package/dist/phaser/geom/line.d.ts.map +1 -1
  100. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  101. package/dist/phaser/geom/util/circle.d.ts +2 -1
  102. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  103. package/dist/phaser/geom/util/point.d.ts +1 -1
  104. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  105. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  106. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  107. package/dist/phaser/util/math.d.ts.map +1 -1
  108. package/package.json +1 -1
  109. package/src/phaser/core/animation.ts +4 -4
  110. package/src/phaser/core/animation_manager.ts +10 -10
  111. package/src/phaser/core/animation_parser.ts +30 -24
  112. package/src/phaser/core/array_set.ts +27 -27
  113. package/src/phaser/core/cache.test.ts +33 -33
  114. package/src/phaser/core/cache.ts +3 -3
  115. package/src/phaser/core/callback.ts +1 -0
  116. package/src/phaser/core/callback_context.test.ts +8 -8
  117. package/src/phaser/core/dom.ts +15 -5
  118. package/src/phaser/core/factory.ts +9 -2
  119. package/src/phaser/core/frame_data.test.ts +23 -23
  120. package/src/phaser/core/input.ts +9 -8
  121. package/src/phaser/core/input_handler.test.ts +18 -18
  122. package/src/phaser/core/input_handler.ts +1 -1
  123. package/src/phaser/core/input_mouse.ts +9 -8
  124. package/src/phaser/core/input_pointer.test.ts +26 -26
  125. package/src/phaser/core/input_pointer.ts +3 -3
  126. package/src/phaser/core/input_touch.ts +8 -8
  127. package/src/phaser/core/loader.test.ts +26 -26
  128. package/src/phaser/core/loader.ts +25 -25
  129. package/src/phaser/core/loader_parser.test.ts +16 -16
  130. package/src/phaser/core/loader_parser.ts +16 -6
  131. package/src/phaser/core/raf.ts +1 -1
  132. package/src/phaser/core/registry.test.ts +6 -6
  133. package/src/phaser/core/scale_manager.ts +2 -2
  134. package/src/phaser/core/scene_manager.test.ts +30 -30
  135. package/src/phaser/core/scene_manager.ts +1 -1
  136. package/src/phaser/core/signal.test.ts +8 -8
  137. package/src/phaser/core/signal.ts +1 -1
  138. package/src/phaser/core/signal_dispatch.test.ts +30 -30
  139. package/src/phaser/core/sound.ts +20 -8
  140. package/src/phaser/core/sound_manager.ts +6 -6
  141. package/src/phaser/core/stage.ts +19 -9
  142. package/src/phaser/core/time.ts +1 -1
  143. package/src/phaser/core/timer.test.ts +47 -47
  144. package/src/phaser/core/timer.ts +1 -1
  145. package/src/phaser/core/tween.ts +28 -25
  146. package/src/phaser/core/tween_data.test.ts +119 -0
  147. package/src/phaser/core/tween_data.ts +54 -39
  148. package/src/phaser/core/tween_easing.test.ts +5 -5
  149. package/src/phaser/core/tween_manager.ts +2 -2
  150. package/src/phaser/display/bitmap_text.test.ts +30 -30
  151. package/src/phaser/display/button.ts +8 -6
  152. package/src/phaser/display/canvas/buffer.ts +2 -2
  153. package/src/phaser/display/canvas/masker.ts +1 -1
  154. package/src/phaser/display/canvas/pool.test.ts +20 -20
  155. package/src/phaser/display/canvas/pool.ts +3 -3
  156. package/src/phaser/display/canvas/renderer.ts +12 -11
  157. package/src/phaser/display/canvas/util.test.ts +25 -25
  158. package/src/phaser/display/display_object.ts +3 -1
  159. package/src/phaser/display/graphics.test.ts +70 -20
  160. package/src/phaser/display/graphics.ts +38 -32
  161. package/src/phaser/display/group.ts +4 -4
  162. package/src/phaser/display/image.ts +28 -25
  163. package/src/phaser/display/sprite_util.ts +3 -2
  164. package/src/phaser/display/text.test.ts +28 -25
  165. package/src/phaser/display/text.ts +21 -18
  166. package/src/phaser/display/webgl/abstract_filter.ts +20 -10
  167. package/src/phaser/display/webgl/blend_manager.ts +4 -5
  168. package/src/phaser/display/webgl/earcut.test.ts +20 -20
  169. package/src/phaser/display/webgl/fast_sprite_batch.ts +21 -16
  170. package/src/phaser/display/webgl/filter_manager.ts +7 -4
  171. package/src/phaser/display/webgl/filter_texture.ts +5 -5
  172. package/src/phaser/display/webgl/graphics.ts +2 -2
  173. package/src/phaser/display/webgl/mask_manager.ts +9 -14
  174. package/src/phaser/display/webgl/render_texture.ts +15 -14
  175. package/src/phaser/display/webgl/renderer.ts +7 -6
  176. package/src/phaser/display/webgl/shader/normal.ts +41 -31
  177. package/src/phaser/display/webgl/shader/shader.test.ts +24 -24
  178. package/src/phaser/display/webgl/shader_manager.test.ts +18 -18
  179. package/src/phaser/display/webgl/sprite_batch.ts +8 -8
  180. package/src/phaser/display/webgl/stencil_manager.ts +4 -4
  181. package/src/phaser/display/webgl/texture_util.ts +2 -2
  182. package/src/phaser/display/webgl/util.ts +1 -1
  183. package/src/phaser/geom/circle.test.ts +38 -38
  184. package/src/phaser/geom/circle.ts +7 -7
  185. package/src/phaser/geom/ellipse.test.ts +12 -12
  186. package/src/phaser/geom/line.test.ts +15 -15
  187. package/src/phaser/geom/line.ts +5 -2
  188. package/src/phaser/geom/matrix.test.ts +31 -31
  189. package/src/phaser/geom/point.test.ts +31 -31
  190. package/src/phaser/geom/polygon.test.ts +27 -27
  191. package/src/phaser/geom/rectangle.test.ts +87 -87
  192. package/src/phaser/geom/rectangle.ts +11 -11
  193. package/src/phaser/geom/rounded_rectangle.test.ts +9 -9
  194. package/src/phaser/geom/util/circle.test.ts +5 -5
  195. package/src/phaser/geom/util/circle.ts +2 -1
  196. package/src/phaser/geom/util/ellipse.test.ts +2 -2
  197. package/src/phaser/geom/util/line.test.ts +2 -2
  198. package/src/phaser/geom/util/matrix.test.ts +4 -4
  199. package/src/phaser/geom/util/point.test.ts +2 -2
  200. package/src/phaser/geom/util/point.ts +1 -1
  201. package/src/phaser/geom/util/polygon.test.ts +2 -2
  202. package/src/phaser/geom/util/rectangle.test.ts +2 -2
  203. package/src/phaser/geom/util/rectangle.ts +1 -1
  204. package/src/phaser/geom/util/rounded_rectangle.test.ts +2 -2
  205. package/src/phaser/util/math.test.ts +41 -41
  206. package/src/phaser/util/math.ts +5 -2
@@ -370,7 +370,7 @@ export class Rectangle {
370
370
  /**
371
371
  * Sets the top coordinate of this rectangle.
372
372
  */
373
- public set top(value) {
373
+ public set top(value: number) {
374
374
  if (value >= this.bottom) {
375
375
  this.height = 0;
376
376
  this.y = value;
@@ -390,7 +390,7 @@ export class Rectangle {
390
390
  /**
391
391
  * Sets the top-left point of this rectangle.
392
392
  */
393
- public set topLeft(value) {
393
+ public set topLeft(value: Point) {
394
394
  this.x = value.x;
395
395
  this.y = value.y;
396
396
  }
@@ -406,7 +406,7 @@ export class Rectangle {
406
406
  /**
407
407
  * Sets the top-right point of this rectangle.
408
408
  */
409
- public set topRight(value) {
409
+ public set topRight(value: Point) {
410
410
  this.right = value.x;
411
411
  this.y = value.y;
412
412
  }
@@ -422,7 +422,7 @@ export class Rectangle {
422
422
  /**
423
423
  * Sets the bottom coordinate of this rectangle.
424
424
  */
425
- public set bottom(value) {
425
+ public set bottom(value: number) {
426
426
  this.height = value <= this.y ? 0 : value - this.y;
427
427
  }
428
428
 
@@ -437,7 +437,7 @@ export class Rectangle {
437
437
  /**
438
438
  * Sets the bottom-left point of this rectangle.
439
439
  */
440
- public set bottomLeft(value) {
440
+ public set bottomLeft(value: Point) {
441
441
  this.x = value.x;
442
442
  this.bottom = value.y;
443
443
  }
@@ -453,7 +453,7 @@ export class Rectangle {
453
453
  /**
454
454
  * Sets the bottom-right point of this rectangle.
455
455
  */
456
- public set bottomRight(value) {
456
+ public set bottomRight(value: Point) {
457
457
  this.right = value.x;
458
458
  this.bottom = value.y;
459
459
  }
@@ -469,7 +469,7 @@ export class Rectangle {
469
469
  /**
470
470
  * Sets the left coordinate of this rectangle.
471
471
  */
472
- public set left(value) {
472
+ public set left(value: number) {
473
473
  this.width = value >= this.right ? 0 : this.right - value;
474
474
  this.x = value;
475
475
  }
@@ -485,7 +485,7 @@ export class Rectangle {
485
485
  /**
486
486
  * Sets the right coordinate of this rectangle.
487
487
  */
488
- public set right(value) {
488
+ public set right(value: number) {
489
489
  this.width = value <= this.x ? 0 : value - this.x;
490
490
  }
491
491
 
@@ -516,7 +516,7 @@ export class Rectangle {
516
516
  /**
517
517
  * Sets the x coordinate of the center of this rectangle.
518
518
  */
519
- public set centerX(value) {
519
+ public set centerX(value: number) {
520
520
  this.x = value - this.halfWidth;
521
521
  }
522
522
 
@@ -531,7 +531,7 @@ export class Rectangle {
531
531
  /**
532
532
  * Sets the y coordinate of the center of this rectangle.
533
533
  */
534
- public set centerY(value) {
534
+ public set centerY(value: number) {
535
535
  this.y = value - this.halfHeight;
536
536
  }
537
537
 
@@ -562,7 +562,7 @@ export class Rectangle {
562
562
  /**
563
563
  * Sets whether this rectangle is empty (zero width or height).
564
564
  */
565
- public set empty(value) {
565
+ public set empty(value: boolean) {
566
566
  if (value) {
567
567
  this.setTo(0, 0, 0, 0);
568
568
  }
@@ -1,8 +1,8 @@
1
1
  import { expect, describe, it } from 'vitest';
2
2
  import { RoundedRectangle } from './rounded_rectangle.js';
3
3
 
4
- describe('RoundedRectangle Constructor', () => {
5
- it('should create a new instance with correct properties', () => {
4
+ describe('RoundedRectangle Constructor', (): void => {
5
+ it('should create a new instance with correct properties', (): void => {
6
6
  const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
7
7
  expect(rectangle.x).toBe(10);
8
8
  expect(rectangle.y).toBe(20);
@@ -12,8 +12,8 @@ describe('RoundedRectangle Constructor', () => {
12
12
  });
13
13
  });
14
14
 
15
- describe('RoundedRectangle contains Method', () => {
16
- it('should return false for zero width or height', () => {
15
+ describe('RoundedRectangle contains Method', (): void => {
16
+ it('should return false for zero width or height', (): void => {
17
17
  const rectangle = new RoundedRectangle(10, 20, 0, 40, 5);
18
18
  expect(rectangle.contains(15, 25)).toBe(false);
19
19
 
@@ -21,12 +21,12 @@ describe('RoundedRectangle contains Method', () => {
21
21
  expect(rectangle2.contains(15, 25)).toBe(false);
22
22
  });
23
23
 
24
- it('should return true for a point inside the rectangle', () => {
24
+ it('should return true for a point inside the rectangle', (): void => {
25
25
  const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
26
26
  expect(rectangle.contains(15, 25)).toBe(true);
27
27
  });
28
28
 
29
- it("should return true for a point on the rectangle's edge", () => {
29
+ it("should return true for a point on the rectangle's edge", (): void => {
30
30
  const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
31
31
  expect(rectangle.contains(0, 25)).toBe(false);
32
32
  expect(rectangle.contains(30, 25)).toBe(true);
@@ -34,15 +34,15 @@ describe('RoundedRectangle contains Method', () => {
34
34
  expect(rectangle.contains(15, 40)).toBe(true);
35
35
  });
36
36
 
37
- it('should return false for a point outside the rectangle', () => {
37
+ it('should return false for a point outside the rectangle', (): void => {
38
38
  const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
39
39
  expect(rectangle.contains(-1, -1)).toBe(false);
40
40
  expect(rectangle.contains(50, 60)).toBe(false);
41
41
  });
42
42
  });
43
43
 
44
- describe('RoundedRectangle clone Method', () => {
45
- it('should create a deep copy of the original rectangle', () => {
44
+ describe('RoundedRectangle clone Method', (): void => {
45
+ it('should create a deep copy of the original rectangle', (): void => {
46
46
  const original = new RoundedRectangle(10, 20, 30, 40, 5);
47
47
  const clone = original.clone();
48
48
  expect(clone.x).toBe(original.x);
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { Circle } from '../circle.js';
3
3
  import { clone, contains, equals, intersects } from './circle.js';
4
4
 
5
- describe('circle utils', () => {
6
- it('should clone a circle', () => {
5
+ describe('circle utils', (): void => {
6
+ it('should clone a circle', (): void => {
7
7
  const circle1 = new Circle(0, 0, 10);
8
8
  const circle2 = clone(circle1);
9
9
  expect(circle1.x).toBe(circle2.x);
@@ -11,12 +11,12 @@ describe('circle utils', () => {
11
11
  expect(circle1.radius).toBe(circle2.radius);
12
12
  });
13
13
 
14
- it('should contain a point in a circle', () => {
14
+ it('should contain a point in a circle', (): void => {
15
15
  const circle = new Circle(5, 5, 10);
16
16
  expect(contains(circle, 5, 5)).toBe(true);
17
17
  });
18
18
 
19
- it('should match two circles', () => {
19
+ it('should match two circles', (): void => {
20
20
  const circle1 = new Circle(5, 5, 10);
21
21
  const circle2 = new Circle(5, 5, 10);
22
22
  expect(equals(circle1, circle2)).toBe(true);
@@ -24,7 +24,7 @@ describe('circle utils', () => {
24
24
  expect(equals(circle1, circle2)).toBe(false);
25
25
  });
26
26
 
27
- it('should intersects two circles', () => {
27
+ it('should intersects two circles', (): void => {
28
28
  const circle1 = new Circle(5, 5, 10);
29
29
  const circle2 = new Circle(5, 5, 5);
30
30
  expect(intersects(circle1, circle2)).toBe(true);
@@ -1,6 +1,7 @@
1
1
  import { degToRad, distance } from '../../util/math.js';
2
2
  import { Circle } from '../circle.js';
3
3
  import { Point } from '../point.js';
4
+ import type { Rectangle } from '../rectangle.js';
4
5
 
5
6
  /**
6
7
  * Clones a circle.
@@ -90,7 +91,7 @@ export const intersectsPoint = (a: Circle, angle: number, asDegrees = false, out
90
91
  * @param {object} r - The rectangle to check.
91
92
  * @returns {boolean} True if the circle intersects with the rectangle, false otherwise.
92
93
  */
93
- export const intersectsRectangle = (c: Circle, r: any): boolean => {
94
+ export const intersectsRectangle = (c: Circle, r: Rectangle): boolean => {
94
95
  const cx = Math.abs(c.x - r.x - r.halfWidth);
95
96
  const xDist = r.halfWidth + c.radius;
96
97
  if (cx > xDist) {
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { Ellipse } from '../ellipse.js';
3
3
  import { contains } from './ellipse.js';
4
4
 
5
- describe('ellipse utils', () => {
6
- it('should contain an ellipse the given coordinates', () => {
5
+ describe('ellipse utils', (): void => {
6
+ it('should contain an ellipse the given coordinates', (): void => {
7
7
  const ellipse = new Ellipse(0, 0, 10, 10);
8
8
  expect(contains(ellipse, 5, 5)).toBe(true);
9
9
  expect(contains(ellipse, 15, 15)).toBe(false);
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { Line } from '../line.js';
3
3
  import { clone } from './line.js';
4
4
 
5
- describe('line utils', () => {
6
- it('should clone a line', () => {
5
+ describe('line utils', (): void => {
6
+ it('should clone a line', (): void => {
7
7
  const line1 = new Line(0, 0, 10, 0);
8
8
  const line2 = clone(line1);
9
9
  expect(line1.start.x).toBe(line2.start.x);
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { Matrix } from '../matrix.js';
3
3
  import { clone, getIdentityMatrix, getTempMatrix } from './matrix.js';
4
4
 
5
- describe('matrix utils', () => {
6
- it('should clone a matrix', () => {
5
+ describe('matrix utils', (): void => {
6
+ it('should clone a matrix', (): void => {
7
7
  const matrix1 = new Matrix(2, 0, 0, 2, 0, 0);
8
8
  const matrix2 = clone(matrix1);
9
9
  expect(matrix1.a).toBe(matrix2.a);
@@ -14,12 +14,12 @@ describe('matrix utils', () => {
14
14
  expect(matrix1.ty).toBe(matrix2.ty);
15
15
  });
16
16
 
17
- it('should create an identity matrix', () => {
17
+ it('should create an identity matrix', (): void => {
18
18
  const matrix = getIdentityMatrix();
19
19
  expect(matrix.a).toBe(1);
20
20
  });
21
21
 
22
- it('should create a temporary matrix', () => {
22
+ it('should create a temporary matrix', (): void => {
23
23
  const matrix = getTempMatrix();
24
24
  expect(matrix.a).toBe(1);
25
25
  });
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { Point } from '../point.js';
3
3
  import { clone } from './point.js';
4
4
 
5
- describe('point utils', () => {
6
- it('should clone a point', () => {
5
+ describe('point utils', (): void => {
6
+ it('should clone a point', (): void => {
7
7
  const point1 = new Point(1, 2);
8
8
  const point2 = clone(point1);
9
9
  expect(point1.x).toBe(point2.x);
@@ -271,7 +271,7 @@ export const centroid = (points: Point[], output: Point | null = null): Point =>
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'): Point => {
274
+ export const parse = (obj: Record<string, unknown>, 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]));
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { Polygon } from '../polygon.js';
3
3
  import { clone } from './polygon.js';
4
4
 
5
- describe('polygon utils', () => {
6
- it('should clone a polygon', () => {
5
+ describe('polygon utils', (): void => {
6
+ it('should clone a polygon', (): void => {
7
7
  const polygon = new Polygon([0, 0, 1, 0, 1, 1]);
8
8
  const points = clone(polygon).toNumberArray();
9
9
  expect(points[0]).toBe(0);
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { Rectangle } from '../rectangle.js';
3
3
  import { clone } from './rectangle.js';
4
4
 
5
- describe('rectangle utils', () => {
6
- it('should clone a rectangle', () => {
5
+ describe('rectangle utils', (): void => {
6
+ it('should clone a rectangle', (): void => {
7
7
  const rectangle1 = new Rectangle(0, 0, 10, 10);
8
8
  const rectangle2 = clone(rectangle1);
9
9
  expect(rectangle1.x).toBe(rectangle2.x);
@@ -23,7 +23,7 @@ export const inflate = (a: Rectangle, dx: number, dy: number): Rectangle => {
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): Rectangle => inflate(a, point.x, point.y);
26
+ export const inflatePoint = (a: Rectangle, point: Point): Rectangle => inflate(a, point.x, point.y);
27
27
 
28
28
  /**
29
29
  * Gets the size of the rectangle as a point.
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
2
2
  import { RoundedRectangle } from '../rounded_rectangle.js';
3
3
  import { clone } from './rounded_rectangle.js';
4
4
 
5
- describe('rounded rectangle utils', () => {
6
- it('should clone a rounded rectangle', () => {
5
+ describe('rounded rectangle utils', (): void => {
6
+ it('should clone a rounded rectangle', (): void => {
7
7
  const rectangle1 = new RoundedRectangle(0, 0, 10, 10, 2);
8
8
  const rectangle2 = clone(rectangle1);
9
9
  expect(rectangle1.x).toBe(rectangle2.x);
@@ -17,66 +17,66 @@ import {
17
17
  wrap,
18
18
  } from './math.js';
19
19
 
20
- describe('DEG_TO_RAD', () => {
21
- it('returns the correct value', () => {
20
+ describe('DEG_TO_RAD', (): void => {
21
+ it('returns the correct value', (): void => {
22
22
  expect(DEG_TO_RAD).toBeCloseTo(Math.PI / 180);
23
23
  });
24
24
  });
25
25
 
26
- describe('RAD_TO_DEG', () => {
27
- it('returns the correct value', () => {
26
+ describe('RAD_TO_DEG', (): void => {
27
+ it('returns the correct value', (): void => {
28
28
  expect(RAD_TO_DEG).toBeCloseTo(180 / Math.PI);
29
29
  });
30
30
  });
31
31
 
32
- describe('PI_2', () => {
33
- it('returns the correct value', () => {
32
+ describe('PI_2', (): void => {
33
+ it('returns the correct value', (): void => {
34
34
  expect(PI_2).toBeCloseTo(Math.PI * 2);
35
35
  });
36
36
  });
37
37
 
38
- describe('getNextPowerOfTwo', () => {
39
- it('returns the correct power of two value for a valid input', () => {
38
+ describe('getNextPowerOfTwo', (): void => {
39
+ it('returns the correct power of two value for a valid input', (): void => {
40
40
  expect(getNextPowerOfTwo(10)).toBe(16);
41
41
  });
42
42
 
43
- it('returns the correct power of two value for an invalid input', () => {
43
+ it('returns the correct power of two value for an invalid input', (): void => {
44
44
  expect(getNextPowerOfTwo(-5)).toBe(1);
45
45
  });
46
46
  });
47
47
 
48
- describe('isPowerOfTwo', () => {
49
- it('returns true for a valid power of two value', () => {
48
+ describe('isPowerOfTwo', (): void => {
49
+ it('returns true for a valid power of two value', (): void => {
50
50
  expect(isPowerOfTwo(8, 16)).toBe(true);
51
51
  });
52
52
 
53
- it('returns false for an invalid power of two value', () => {
53
+ it('returns false for an invalid power of two value', (): void => {
54
54
  expect(isPowerOfTwo(7, 15)).toBe(false);
55
55
  });
56
56
  });
57
57
 
58
- describe('degToRad', () => {
59
- it('returns the correct radian value for a valid degree input', () => {
58
+ describe('degToRad', (): void => {
59
+ it('returns the correct radian value for a valid degree input', (): void => {
60
60
  expect(degToRad(90)).toBeCloseTo(Math.PI / 2);
61
61
  });
62
62
 
63
- it('returns the correct radian value for an invalid degree input', () => {
63
+ it('returns the correct radian value for an invalid degree input', (): void => {
64
64
  expect(degToRad(-45)).toBeCloseTo(-0.7853);
65
65
  });
66
66
  });
67
67
 
68
- describe('radToDeg', () => {
69
- it('returns the correct degree value for a valid radian input', () => {
68
+ describe('radToDeg', (): void => {
69
+ it('returns the correct degree value for a valid radian input', (): void => {
70
70
  expect(radToDeg(Math.PI / 2)).toBe(90);
71
71
  });
72
72
 
73
- it('returns the correct degree value for an invalid radian input', () => {
73
+ it('returns the correct degree value for an invalid radian input', (): void => {
74
74
  expect(radToDeg(-Math.PI / 10)).toBe(-18);
75
75
  });
76
76
  });
77
77
 
78
- describe('between', () => {
79
- it('returns a random value within the specified range', () => {
78
+ describe('between', (): void => {
79
+ it('returns a random value within the specified range', (): void => {
80
80
  const min = 1;
81
81
  const max = 100;
82
82
  const result = between(min, max);
@@ -85,18 +85,18 @@ describe('between', () => {
85
85
  });
86
86
  });
87
87
 
88
- describe('snapToCeil', () => {
89
- it('returns the correct snapped value for a valid input with a gap of 1', () => {
88
+ describe('snapToCeil', (): void => {
89
+ it('returns the correct snapped value for a valid input with a gap of 1', (): void => {
90
90
  expect(snapToCeil(3.7, 1)).toBe(4);
91
91
  });
92
92
 
93
- it('returns the correct snapped value for a valid input with a gap of 2', () => {
93
+ it('returns the correct snapped value for a valid input with a gap of 2', (): void => {
94
94
  expect(snapToCeil(5.3, 2)).toBe(6);
95
95
  });
96
96
  });
97
97
 
98
- describe('wrap', () => {
99
- it('returns the correct wrapped value for a valid input', () => {
98
+ describe('wrap', (): void => {
99
+ it('returns the correct wrapped value for a valid input', (): void => {
100
100
  const min = 0;
101
101
  const max = 100;
102
102
  const result = wrap(150, min, max);
@@ -104,7 +104,7 @@ describe('wrap', () => {
104
104
  expect(result).toBeLessThanOrEqual(max);
105
105
  });
106
106
 
107
- it('returns the correct wrapped value for an invalid input', () => {
107
+ it('returns the correct wrapped value for an invalid input', (): void => {
108
108
  const min = -1;
109
109
  const max = 10;
110
110
  const result = wrap(-20, min, max);
@@ -113,15 +113,15 @@ describe('wrap', () => {
113
113
  });
114
114
  });
115
115
 
116
- describe('linear', () => {
117
- it('returns the correct interpolated value for a valid input', () => {
116
+ describe('linear', (): void => {
117
+ it('returns the correct interpolated value for a valid input', (): void => {
118
118
  const p0 = 1;
119
119
  const p1 = 2;
120
120
  const t = 0.5;
121
121
  expect(linear(p0, p1, t)).toStrictEqual(1.5);
122
122
  });
123
123
 
124
- it('returns the correct interpolated value for an invalid input', () => {
124
+ it('returns the correct interpolated value for an invalid input', (): void => {
125
125
  const p0 = 1;
126
126
  const p1 = 2;
127
127
  const t = 2;
@@ -129,32 +129,32 @@ describe('linear', () => {
129
129
  });
130
130
  });
131
131
 
132
- describe('difference', () => {
133
- it('returns the correct difference value for a valid input', () => {
132
+ describe('difference', (): void => {
133
+ it('returns the correct difference value for a valid input', (): void => {
134
134
  expect(difference(10, 5)).toBe(5);
135
135
  });
136
136
 
137
- it('returns the correct difference value for an invalid input', () => {
137
+ it('returns the correct difference value for an invalid input', (): void => {
138
138
  expect(difference(-10, -15)).toBe(5);
139
139
  });
140
140
  });
141
141
 
142
- describe('linearInterpolation', () => {
143
- it('returns the correct interpolated value for a valid input', () => {
142
+ describe('linearInterpolation', (): void => {
143
+ it('returns the correct interpolated value for a valid input', (): void => {
144
144
  const v = [1, 2, 3];
145
145
  const k = 0.5;
146
146
  expect(linearInterpolation(v, k)).toBe(2);
147
147
  });
148
148
 
149
- it('returns the correct interpolated value for an invalid input', () => {
149
+ it('returns the correct interpolated value for an invalid input', (): void => {
150
150
  const v = [-10, -20, -30];
151
151
  const k = -1;
152
152
  expect(linearInterpolation(v, k)).toBe(10);
153
153
  });
154
154
  });
155
155
 
156
- describe('distance', () => {
157
- it('returns the correct distance value for a valid input', () => {
156
+ describe('distance', (): void => {
157
+ it('returns the correct distance value for a valid input', (): void => {
158
158
  const x1 = 0;
159
159
  const y1 = 0;
160
160
  const x2 = 3;
@@ -162,7 +162,7 @@ describe('distance', () => {
162
162
  expect(distance(x1, y1, x2, y2)).toBeCloseTo(5);
163
163
  });
164
164
 
165
- it('returns the correct distance value for an invalid input', () => {
165
+ it('returns the correct distance value for an invalid input', (): void => {
166
166
  const x1 = -10;
167
167
  const y1 = -20;
168
168
  const x2 = 100;
@@ -171,15 +171,15 @@ describe('distance', () => {
171
171
  });
172
172
  });
173
173
 
174
- describe('within', () => {
175
- it('returns true for a valid input within the specified tolerance', () => {
174
+ describe('within', (): void => {
175
+ it('returns true for a valid input within the specified tolerance', (): void => {
176
176
  const a = 6;
177
177
  const b = 5;
178
178
  const tolerance = 1;
179
179
  expect(within(a, b, tolerance)).toBe(true);
180
180
  });
181
181
 
182
- it('returns false for an invalid input outside the specified tolerance', () => {
182
+ it('returns false for an invalid input outside the specified tolerance', (): void => {
183
183
  const a = -10;
184
184
  const b = -15;
185
185
  const tolerance = 0.001;
@@ -115,8 +115,11 @@ export const getColor = (r: number, g: number, b: number): number => (r << 16) |
115
115
 
116
116
  /** Converts a hex color string to RGB components. */
117
117
  export const hexToColor = (value: string, out: ColorTarget): void => {
118
- value = value.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, (_m, r, g, b) => r + r + g + g + b + b);
119
- const result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(value);
118
+ const expanded = value.replace(
119
+ /^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,
120
+ (_match: string, r: string, g: string, b: string): string => r + r + g + g + b + b
121
+ );
122
+ const result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(expanded);
120
123
  if (result) {
121
124
  out.r = Number.parseInt(result[1]!, 16);
122
125
  out.g = Number.parseInt(result[2]!, 16);