@vpmedia/phaser 1.123.0 → 1.125.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 (221) hide show
  1. package/dist/index.js +635 -623
  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/frame_data.d.ts.map +1 -1
  17. package/dist/phaser/core/input.d.ts +3 -2
  18. package/dist/phaser/core/input.d.ts.map +1 -1
  19. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  20. package/dist/phaser/core/input_mouse.d.ts +5 -1
  21. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  22. package/dist/phaser/core/input_pointer.d.ts +3 -3
  23. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  24. package/dist/phaser/core/input_touch.d.ts +8 -8
  25. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  26. package/dist/phaser/core/loader.d.ts +11 -2
  27. package/dist/phaser/core/loader.d.ts.map +1 -1
  28. package/dist/phaser/core/loader_parser.d.ts +14 -1
  29. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  30. package/dist/phaser/core/raf.d.ts +1 -1
  31. package/dist/phaser/core/raf.d.ts.map +1 -1
  32. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  33. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  34. package/dist/phaser/core/signal.d.ts.map +1 -1
  35. package/dist/phaser/core/sound.d.ts.map +1 -1
  36. package/dist/phaser/core/sound_manager.d.ts +1 -1
  37. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  38. package/dist/phaser/core/stage.d.ts +16 -6
  39. package/dist/phaser/core/stage.d.ts.map +1 -1
  40. package/dist/phaser/core/time.d.ts.map +1 -1
  41. package/dist/phaser/core/timer.d.ts +1 -1
  42. package/dist/phaser/core/timer.d.ts.map +1 -1
  43. package/dist/phaser/core/tween.d.ts +13 -5
  44. package/dist/phaser/core/tween.d.ts.map +1 -1
  45. package/dist/phaser/core/tween_data.d.ts +9 -7
  46. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  47. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  48. package/dist/phaser/display/button.d.ts +6 -5
  49. package/dist/phaser/display/button.d.ts.map +1 -1
  50. package/dist/phaser/display/canvas/buffer.d.ts +1 -1
  51. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  52. package/dist/phaser/display/canvas/masker.d.ts +1 -1
  53. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  54. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  55. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  56. package/dist/phaser/display/canvas/renderer.d.ts +9 -8
  57. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  58. package/dist/phaser/display/display_object.d.ts +5 -3
  59. package/dist/phaser/display/display_object.d.ts.map +1 -1
  60. package/dist/phaser/display/graphics.d.ts +1 -1
  61. package/dist/phaser/display/graphics.d.ts.map +1 -1
  62. package/dist/phaser/display/group.d.ts +1 -1
  63. package/dist/phaser/display/group.d.ts.map +1 -1
  64. package/dist/phaser/display/image.d.ts +6 -5
  65. package/dist/phaser/display/image.d.ts.map +1 -1
  66. package/dist/phaser/display/sprite_util.d.ts +3 -2
  67. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  68. package/dist/phaser/display/text.d.ts +2 -16
  69. package/dist/phaser/display/text.d.ts.map +1 -1
  70. package/dist/phaser/display/webgl/abstract_filter.d.ts +14 -8
  71. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  72. package/dist/phaser/display/webgl/blend_manager.d.ts +2 -3
  73. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  74. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  75. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +11 -5
  76. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  77. package/dist/phaser/display/webgl/filter_manager.d.ts +6 -4
  78. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  79. package/dist/phaser/display/webgl/filter_texture.d.ts +4 -4
  80. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/graphics.d.ts +2 -2
  82. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/mask_manager.d.ts +3 -2
  84. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  85. package/dist/phaser/display/webgl/render_texture.d.ts +11 -8
  86. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/renderer.d.ts +8 -4
  88. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  89. package/dist/phaser/display/webgl/shader/normal.d.ts +28 -3
  90. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  91. package/dist/phaser/display/webgl/sprite_batch.d.ts +6 -5
  92. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  93. package/dist/phaser/display/webgl/stencil_manager.d.ts +3 -3
  94. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  95. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  96. package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
  97. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  98. package/dist/phaser/display/webgl/util.d.ts +1 -1
  99. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  100. package/dist/phaser/geom/circle.d.ts.map +1 -1
  101. package/dist/phaser/geom/line.d.ts +10 -1
  102. package/dist/phaser/geom/line.d.ts.map +1 -1
  103. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  104. package/dist/phaser/geom/util/circle.d.ts +2 -1
  105. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  106. package/dist/phaser/geom/util/point.d.ts +1 -1
  107. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  108. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  109. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  110. package/dist/phaser/util/math.d.ts.map +1 -1
  111. package/package.json +1 -1
  112. package/src/phaser/core/animation.ts +11 -11
  113. package/src/phaser/core/animation_manager.ts +12 -12
  114. package/src/phaser/core/animation_parser.ts +39 -37
  115. package/src/phaser/core/array_set.ts +28 -28
  116. package/src/phaser/core/cache.test.ts +33 -33
  117. package/src/phaser/core/cache.ts +7 -7
  118. package/src/phaser/core/callback.ts +1 -0
  119. package/src/phaser/core/callback_context.test.ts +8 -8
  120. package/src/phaser/core/device_util.ts +4 -4
  121. package/src/phaser/core/dom.ts +38 -24
  122. package/src/phaser/core/factory.ts +9 -2
  123. package/src/phaser/core/frame_data.test.ts +23 -23
  124. package/src/phaser/core/frame_data.ts +2 -5
  125. package/src/phaser/core/game.ts +12 -12
  126. package/src/phaser/core/input.ts +11 -10
  127. package/src/phaser/core/input_handler.test.ts +18 -18
  128. package/src/phaser/core/input_handler.ts +14 -14
  129. package/src/phaser/core/input_mouse.ts +13 -12
  130. package/src/phaser/core/input_pointer.test.ts +26 -26
  131. package/src/phaser/core/input_pointer.ts +4 -4
  132. package/src/phaser/core/input_touch.ts +8 -8
  133. package/src/phaser/core/loader.test.ts +26 -26
  134. package/src/phaser/core/loader.ts +63 -75
  135. package/src/phaser/core/loader_parser.test.ts +16 -16
  136. package/src/phaser/core/loader_parser.ts +16 -6
  137. package/src/phaser/core/raf.ts +1 -1
  138. package/src/phaser/core/registry.test.ts +6 -6
  139. package/src/phaser/core/scale_manager.ts +12 -11
  140. package/src/phaser/core/scene_manager.test.ts +30 -30
  141. package/src/phaser/core/scene_manager.ts +3 -3
  142. package/src/phaser/core/signal.test.ts +8 -8
  143. package/src/phaser/core/signal.ts +3 -3
  144. package/src/phaser/core/signal_dispatch.test.ts +30 -30
  145. package/src/phaser/core/sound.ts +45 -40
  146. package/src/phaser/core/sound_manager.ts +18 -22
  147. package/src/phaser/core/sound_sprite.ts +1 -1
  148. package/src/phaser/core/stage.ts +22 -12
  149. package/src/phaser/core/time.ts +1 -1
  150. package/src/phaser/core/timer.test.ts +47 -47
  151. package/src/phaser/core/timer.ts +2 -2
  152. package/src/phaser/core/tween.ts +34 -36
  153. package/src/phaser/core/tween_data.test.ts +119 -0
  154. package/src/phaser/core/tween_data.ts +54 -39
  155. package/src/phaser/core/tween_easing.test.ts +5 -5
  156. package/src/phaser/core/tween_manager.ts +2 -2
  157. package/src/phaser/display/bitmap_text.test.ts +30 -30
  158. package/src/phaser/display/bitmap_text.ts +3 -3
  159. package/src/phaser/display/button.ts +20 -18
  160. package/src/phaser/display/canvas/buffer.ts +2 -2
  161. package/src/phaser/display/canvas/graphics.ts +2 -2
  162. package/src/phaser/display/canvas/masker.ts +1 -1
  163. package/src/phaser/display/canvas/pool.test.ts +20 -20
  164. package/src/phaser/display/canvas/pool.ts +6 -6
  165. package/src/phaser/display/canvas/renderer.ts +18 -16
  166. package/src/phaser/display/canvas/tinter.ts +1 -1
  167. package/src/phaser/display/canvas/util.test.ts +25 -25
  168. package/src/phaser/display/canvas/util.ts +2 -2
  169. package/src/phaser/display/display_object.ts +16 -15
  170. package/src/phaser/display/graphics.test.ts +70 -20
  171. package/src/phaser/display/graphics.ts +46 -42
  172. package/src/phaser/display/group.ts +13 -12
  173. package/src/phaser/display/image.ts +35 -31
  174. package/src/phaser/display/sprite_util.ts +4 -3
  175. package/src/phaser/display/text.test.ts +28 -25
  176. package/src/phaser/display/text.ts +56 -62
  177. package/src/phaser/display/webgl/abstract_filter.ts +21 -11
  178. package/src/phaser/display/webgl/blend_manager.ts +4 -5
  179. package/src/phaser/display/webgl/earcut.test.ts +20 -20
  180. package/src/phaser/display/webgl/earcut.ts +46 -42
  181. package/src/phaser/display/webgl/fast_sprite_batch.ts +21 -16
  182. package/src/phaser/display/webgl/filter_manager.ts +7 -4
  183. package/src/phaser/display/webgl/filter_texture.ts +5 -5
  184. package/src/phaser/display/webgl/graphics.ts +3 -3
  185. package/src/phaser/display/webgl/mask_manager.ts +9 -14
  186. package/src/phaser/display/webgl/render_texture.ts +15 -14
  187. package/src/phaser/display/webgl/renderer.ts +10 -9
  188. package/src/phaser/display/webgl/shader/normal.ts +45 -35
  189. package/src/phaser/display/webgl/shader/shader.test.ts +24 -24
  190. package/src/phaser/display/webgl/shader_manager.test.ts +18 -18
  191. package/src/phaser/display/webgl/shader_manager.ts +1 -1
  192. package/src/phaser/display/webgl/sprite_batch.ts +10 -10
  193. package/src/phaser/display/webgl/stencil_manager.ts +4 -4
  194. package/src/phaser/display/webgl/texture.ts +2 -1
  195. package/src/phaser/display/webgl/texture_util.ts +2 -2
  196. package/src/phaser/display/webgl/util.ts +4 -4
  197. package/src/phaser/geom/circle.test.ts +38 -38
  198. package/src/phaser/geom/circle.ts +7 -7
  199. package/src/phaser/geom/ellipse.test.ts +12 -12
  200. package/src/phaser/geom/line.test.ts +15 -15
  201. package/src/phaser/geom/line.ts +5 -2
  202. package/src/phaser/geom/matrix.test.ts +31 -31
  203. package/src/phaser/geom/point.test.ts +31 -31
  204. package/src/phaser/geom/polygon.test.ts +27 -27
  205. package/src/phaser/geom/polygon.ts +2 -2
  206. package/src/phaser/geom/rectangle.test.ts +87 -87
  207. package/src/phaser/geom/rectangle.ts +12 -13
  208. package/src/phaser/geom/rounded_rectangle.test.ts +9 -9
  209. package/src/phaser/geom/util/circle.test.ts +5 -5
  210. package/src/phaser/geom/util/circle.ts +8 -11
  211. package/src/phaser/geom/util/ellipse.test.ts +2 -2
  212. package/src/phaser/geom/util/line.test.ts +2 -2
  213. package/src/phaser/geom/util/matrix.test.ts +4 -4
  214. package/src/phaser/geom/util/point.test.ts +2 -2
  215. package/src/phaser/geom/util/point.ts +6 -8
  216. package/src/phaser/geom/util/polygon.test.ts +2 -2
  217. package/src/phaser/geom/util/rectangle.test.ts +2 -2
  218. package/src/phaser/geom/util/rectangle.ts +1 -1
  219. package/src/phaser/geom/util/rounded_rectangle.test.ts +2 -2
  220. package/src/phaser/util/math.test.ts +41 -41
  221. package/src/phaser/util/math.ts +7 -5
@@ -2,8 +2,8 @@ import { expect, describe, it } from 'vitest';
2
2
  import { Matrix } from './matrix.js';
3
3
  import { Point } from './point.js';
4
4
 
5
- describe('Constructor', () => {
6
- it('should set default values when no arguments are passed', () => {
5
+ describe('Constructor', (): void => {
6
+ it('should set default values when no arguments are passed', (): void => {
7
7
  const matrix = new Matrix();
8
8
  expect(matrix.a).toBe(1);
9
9
  expect(matrix.b).toBe(0);
@@ -13,7 +13,7 @@ describe('Constructor', () => {
13
13
  expect(matrix.ty).toBe(0);
14
14
  });
15
15
 
16
- it('should set values when arguments are passed', () => {
16
+ it('should set values when arguments are passed', (): void => {
17
17
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
18
18
  expect(matrix.a).toBe(2);
19
19
  expect(matrix.b).toBe(3);
@@ -24,8 +24,8 @@ describe('Constructor', () => {
24
24
  });
25
25
  });
26
26
 
27
- describe('fromArray', () => {
28
- it('should set values from an array', () => {
27
+ describe('fromArray', (): void => {
28
+ it('should set values from an array', (): void => {
29
29
  const matrix = new Matrix();
30
30
  const array = [2, 3, 4, 5, 6, 7];
31
31
  matrix.fromArray(array);
@@ -38,8 +38,8 @@ describe('fromArray', () => {
38
38
  });
39
39
  });
40
40
 
41
- describe('setTo', () => {
42
- it('should set values when arguments are passed', () => {
41
+ describe('setTo', (): void => {
42
+ it('should set values when arguments are passed', (): void => {
43
43
  const matrix = new Matrix();
44
44
  const a = 2;
45
45
  const b = 3;
@@ -56,7 +56,7 @@ describe('setTo', () => {
56
56
  expect(matrix.ty).toBe(ty);
57
57
  });
58
58
 
59
- it('should return the matrix instance', () => {
59
+ it('should return the matrix instance', (): void => {
60
60
  const matrix = new Matrix();
61
61
  const a = 2;
62
62
  const b = 3;
@@ -68,8 +68,8 @@ describe('setTo', () => {
68
68
  });
69
69
  });
70
70
 
71
- describe('clone', () => {
72
- it('should return a copy of the matrix instance', () => {
71
+ describe('clone', (): void => {
72
+ it('should return a copy of the matrix instance', (): void => {
73
73
  const matrix1 = new Matrix(2, 3, 4, 5, 6, 7);
74
74
  const matrix2 = matrix1.clone();
75
75
  expect(matrix2.a).toBe(matrix1.a);
@@ -81,8 +81,8 @@ describe('clone', () => {
81
81
  });
82
82
  });
83
83
 
84
- describe('copyTo', () => {
85
- it('should copy values to another matrix instance', () => {
84
+ describe('copyTo', (): void => {
85
+ it('should copy values to another matrix instance', (): void => {
86
86
  const matrix1 = new Matrix(2, 3, 4, 5, 6, 7);
87
87
  const matrix2 = new Matrix();
88
88
  matrix1.copyTo(matrix2);
@@ -95,8 +95,8 @@ describe('copyTo', () => {
95
95
  });
96
96
  });
97
97
 
98
- describe('copyFrom', () => {
99
- it('should copy values from another matrix instance', () => {
98
+ describe('copyFrom', (): void => {
99
+ it('should copy values from another matrix instance', (): void => {
100
100
  const matrix1 = new Matrix(2, 3, 4, 5, 6, 7);
101
101
  const matrix2 = new Matrix();
102
102
  matrix2.copyFrom(matrix1);
@@ -109,8 +109,8 @@ describe('copyFrom', () => {
109
109
  });
110
110
  });
111
111
 
112
- describe('apply', () => {
113
- it('should apply the matrix to a point', () => {
112
+ describe('apply', (): void => {
113
+ it('should apply the matrix to a point', (): void => {
114
114
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
115
115
  const point = new Point(1, 2);
116
116
  const result = new Point();
@@ -125,8 +125,8 @@ describe('apply', () => {
125
125
  });
126
126
  });
127
127
 
128
- describe('applyInverse', () => {
129
- it('should apply the inverse of the matrix to a point', () => {
128
+ describe('applyInverse', (): void => {
129
+ it('should apply the inverse of the matrix to a point', (): void => {
130
130
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
131
131
  const point = new Point(1, 2);
132
132
  const result = new Point();
@@ -136,8 +136,8 @@ describe('applyInverse', () => {
136
136
  });
137
137
  });
138
138
 
139
- describe('translate', () => {
140
- it('should add the translation values to the matrix', () => {
139
+ describe('translate', (): void => {
140
+ it('should add the translation values to the matrix', (): void => {
141
141
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
142
142
  const x = 1;
143
143
  const y = 2;
@@ -147,8 +147,8 @@ describe('translate', () => {
147
147
  });
148
148
  });
149
149
 
150
- describe('scale', () => {
151
- it('should multiply the scaling values with the matrix', () => {
150
+ describe('scale', (): void => {
151
+ it('should multiply the scaling values with the matrix', (): void => {
152
152
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
153
153
  const x = 1;
154
154
  const y = 2;
@@ -162,8 +162,8 @@ describe('scale', () => {
162
162
  });
163
163
  });
164
164
 
165
- describe('rotate', () => {
166
- it('should multiply the rotation values with the matrix', () => {
165
+ describe('rotate', (): void => {
166
+ it('should multiply the rotation values with the matrix', (): void => {
167
167
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
168
168
  const angle = Math.PI / 2;
169
169
  matrix.rotate(angle);
@@ -173,8 +173,8 @@ describe('rotate', () => {
173
173
  });
174
174
  });
175
175
 
176
- describe('append', () => {
177
- it('should add the second matrix to the first one', () => {
176
+ describe('append', (): void => {
177
+ it('should add the second matrix to the first one', (): void => {
178
178
  const matrix1 = new Matrix(2, 3, 4, 5, 6, 7);
179
179
  const matrix2 = new Matrix(8, 9, 10, 11, 12, 13);
180
180
  matrix1.append(matrix2);
@@ -184,8 +184,8 @@ describe('append', () => {
184
184
  });
185
185
  });
186
186
 
187
- describe('identity', () => {
188
- it('should set the values to the identity matrix', () => {
187
+ describe('identity', (): void => {
188
+ it('should set the values to the identity matrix', (): void => {
189
189
  const matrix = new Matrix();
190
190
  matrix.identity();
191
191
  expect(matrix.a).toBe(1);
@@ -200,8 +200,8 @@ describe('identity', () => {
200
200
  });
201
201
  });
202
202
 
203
- describe('toArray', () => {
204
- it('should return the values as an array', () => {
203
+ describe('toArray', (): void => {
204
+ it('should return the values as an array', (): void => {
205
205
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
206
206
  const result = matrix.toArray();
207
207
  expect(result[0]).toBe(matrix.a);
@@ -221,7 +221,7 @@ describe('toArray', () => {
221
221
  expect(result2[5]).toBe(matrix.ty);
222
222
  });
223
223
 
224
- it('should return the values as an array with transposed coordinates', () => {
224
+ it('should return the values as an array with transposed coordinates', (): void => {
225
225
  const matrix = new Matrix(2, 3, 4, 5, 6, 7);
226
226
  const result = matrix.toArray(true);
227
227
  expect(result[0]).toBe(matrix.a);
@@ -1,20 +1,20 @@
1
1
  import { expect, describe, it } from 'vitest';
2
2
  import { Point } from './point.js';
3
3
 
4
- describe('Point', () => {
5
- it('should create a point with default values', () => {
4
+ describe('Point', (): void => {
5
+ it('should create a point with default values', (): void => {
6
6
  const point = new Point();
7
7
  expect(point.x).toBe(0);
8
8
  expect(point.y).toBe(0);
9
9
  });
10
10
 
11
- it('should create a point with custom x and y values', () => {
11
+ it('should create a point with custom x and y values', (): void => {
12
12
  const point = new Point(10, 20);
13
13
  expect(point.x).toBe(10);
14
14
  expect(point.y).toBe(20);
15
15
  });
16
16
 
17
- it('should copy from another point', () => {
17
+ it('should copy from another point', (): void => {
18
18
  const point1 = new Point(10, 20);
19
19
  const point2 = new Point();
20
20
  point2.copyFrom(point1);
@@ -22,28 +22,28 @@ describe('Point', () => {
22
22
  expect(point2.y).toBe(20);
23
23
  });
24
24
 
25
- it('should invert a point', () => {
25
+ it('should invert a point', (): void => {
26
26
  const point = new Point(10, 20);
27
27
  const invertedPoint = point.invert();
28
28
  expect(invertedPoint.x).toBe(20);
29
29
  expect(invertedPoint.y).toBe(10);
30
30
  });
31
31
 
32
- it('should set to x and y values', () => {
32
+ it('should set to x and y values', (): void => {
33
33
  const point = new Point();
34
34
  point.setTo(10, 20);
35
35
  expect(point.x).toBe(10);
36
36
  expect(point.y).toBe(20);
37
37
  });
38
38
 
39
- it('should set to y value as x value', () => {
39
+ it('should set to y value as x value', (): void => {
40
40
  const point = new Point();
41
41
  point.setTo(10);
42
42
  expect(point.x).toBe(10);
43
43
  expect(point.y).toBe(10);
44
44
  });
45
45
 
46
- it('should add points', () => {
46
+ it('should add points', (): void => {
47
47
  const point1 = new Point(10, 20);
48
48
  const point2 = new Point(30, 40);
49
49
  const sum = point1.add(point2.x, point2.y);
@@ -51,7 +51,7 @@ describe('Point', () => {
51
51
  expect(sum.y).toBe(60);
52
52
  });
53
53
 
54
- it('should subtract points', () => {
54
+ it('should subtract points', (): void => {
55
55
  const point1 = new Point(10, 20);
56
56
  const point2 = new Point(30, 40);
57
57
  const difference = point1.subtract(point2.x, point2.y);
@@ -59,49 +59,49 @@ describe('Point', () => {
59
59
  expect(difference.y).toBe(-20);
60
60
  });
61
61
 
62
- it('should multiply points', () => {
62
+ it('should multiply points', (): void => {
63
63
  const point = new Point(10, 20);
64
64
  const multipliedPoint = point.multiply(2, 3);
65
65
  expect(multipliedPoint.x).toBe(20);
66
66
  expect(multipliedPoint.y).toBe(60);
67
67
  });
68
68
 
69
- it('should divide points', () => {
69
+ it('should divide points', (): void => {
70
70
  const point1 = new Point(10, 20);
71
71
  const quotient = point1.divide(2, 3);
72
72
  expect(quotient.x).toBe(5);
73
73
  expect(quotient.y).toBeCloseTo(6.67);
74
74
  });
75
75
 
76
- it('should clamp x value', () => {
76
+ it('should clamp x value', (): void => {
77
77
  const point = new Point(-10, 20);
78
78
  const clampedPoint = point.clampX(-5, 10);
79
79
  expect(clampedPoint.x).toBe(-5);
80
80
  expect(clampedPoint.y).toBe(20);
81
81
  });
82
82
 
83
- it('should clamp y value', () => {
83
+ it('should clamp y value', (): void => {
84
84
  const point = new Point(10, -20);
85
85
  const clampedPoint = point.clampY(-5, 10);
86
86
  expect(clampedPoint.x).toBe(10);
87
87
  expect(clampedPoint.y).toBe(-5);
88
88
  });
89
89
 
90
- it('should clamp x and y values', () => {
90
+ it('should clamp x and y values', (): void => {
91
91
  const point = new Point(-10, -20);
92
92
  const clampedPoint = point.clamp(-5, 10);
93
93
  expect(clampedPoint.x).toBe(-5);
94
94
  expect(clampedPoint.y).toBe(-5);
95
95
  });
96
96
 
97
- it('should clone a point', () => {
97
+ it('should clone a point', (): void => {
98
98
  const point1 = new Point(10, 20);
99
99
  const clonedPoint = point1.clone();
100
100
  expect(clonedPoint.x).toBe(10);
101
101
  expect(clonedPoint.y).toBe(20);
102
102
  });
103
103
 
104
- it('should copy to another point', () => {
104
+ it('should copy to another point', (): void => {
105
105
  const point1 = new Point(10, 20);
106
106
  const point2 = new Point();
107
107
  point1.copyTo(point2);
@@ -109,98 +109,98 @@ describe('Point', () => {
109
109
  expect(point2.y).toBe(20);
110
110
  });
111
111
 
112
- it('should calculate distance between two points', () => {
112
+ it('should calculate distance between two points', (): void => {
113
113
  const point1 = new Point(0, 0);
114
114
  const point2 = new Point(3, 4);
115
115
  const distance = point1.distance(point2);
116
116
  expect(distance).toBeCloseTo(5);
117
117
  });
118
118
 
119
- it('should check if two points are equal', () => {
119
+ it('should check if two points are equal', (): void => {
120
120
  const point1 = new Point(10, 20);
121
121
  const point2 = new Point(10, 20);
122
122
  expect(point1.equals(point2)).toBe(true);
123
123
  });
124
124
 
125
- it('should calculate angle between two points', () => {
125
+ it('should calculate angle between two points', (): void => {
126
126
  const point1 = new Point(0, 0);
127
127
  const point2 = new Point(3, 4);
128
128
  const angle = point1.angle(point2, true);
129
129
  expect(angle).toBeCloseTo(53.13);
130
130
  });
131
131
 
132
- it('should rotate a point around another point', () => {
132
+ it('should rotate a point around another point', (): void => {
133
133
  const point1 = new Point(10, 20);
134
134
  const rotatedPoint = point1.rotate(0, 0, Math.PI / 2, true);
135
135
  expect(rotatedPoint.x).toBeCloseTo(9.447);
136
136
  expect(rotatedPoint.y).toBeCloseTo(20.266);
137
137
  });
138
138
 
139
- it('should get magnitude of a point', () => {
139
+ it('should get magnitude of a point', (): void => {
140
140
  const point = new Point(3, 4);
141
141
  expect(point.getMagnitude()).toBeCloseTo(5);
142
142
  });
143
143
 
144
- it('should get magnitude squared of a point', () => {
144
+ it('should get magnitude squared of a point', (): void => {
145
145
  const point = new Point(3, 4);
146
146
  expect(point.getMagnitudeSq()).toBeCloseTo(25);
147
147
  });
148
148
 
149
- it('should set magnitude of a point', () => {
149
+ it('should set magnitude of a point', (): void => {
150
150
  const point = new Point(3, 4);
151
151
  const newPoint = point.setMagnitude(10);
152
152
  expect(newPoint.x).toBe(6);
153
153
  expect(newPoint.y).toBe(8);
154
154
  });
155
155
 
156
- it('should normalize a point', () => {
156
+ it('should normalize a point', (): void => {
157
157
  const point = new Point(3, 4);
158
158
  const normalizedPoint = point.normalize();
159
159
  expect(normalizedPoint.x).toBeCloseTo(0.6);
160
160
  expect(normalizedPoint.y).toBeCloseTo(0.8);
161
161
  });
162
162
 
163
- it('should check if a point is zero', () => {
163
+ it('should check if a point is zero', (): void => {
164
164
  const point1 = new Point(0, 0);
165
165
  const point2 = new Point(10, 20);
166
166
  expect(point1.isZero()).toBe(true);
167
167
  expect(point2.isZero()).toBe(false);
168
168
  });
169
169
 
170
- it('should calculate dot product of two points', () => {
170
+ it('should calculate dot product of two points', (): void => {
171
171
  const point1 = new Point(1, 1);
172
172
  const point2 = new Point(2, 2);
173
173
  expect(point1.dot(point2)).toBe(4);
174
174
  });
175
175
 
176
- it('should calculate cross product of two points', () => {
176
+ it('should calculate cross product of two points', (): void => {
177
177
  const point1 = new Point(1, 1);
178
178
  const point2 = new Point(1, 2);
179
179
  expect(point1.cross(point2)).toBe(1);
180
180
  });
181
181
 
182
- it('should get perpendicular point', () => {
182
+ it('should get perpendicular point', (): void => {
183
183
  const point = new Point(10, 20);
184
184
  const perpPoint = point.perp();
185
185
  expect(perpPoint.x).toBe(-20);
186
186
  expect(perpPoint.y).toBe(10);
187
187
  });
188
188
 
189
- it('should get right-hand normal point', () => {
189
+ it('should get right-hand normal point', (): void => {
190
190
  const point = new Point(10, 20);
191
191
  const normalPoint = point.normalRightHand();
192
192
  expect(normalPoint.x).toBe(-20);
193
193
  expect(normalPoint.y).toBe(10);
194
194
  });
195
195
 
196
- it('should floor a point', () => {
196
+ it('should floor a point', (): void => {
197
197
  const point = new Point(3.14, 4.23);
198
198
  const flooredPoint = point.floor();
199
199
  expect(flooredPoint.x).toBe(3);
200
200
  expect(flooredPoint.y).toBe(4);
201
201
  });
202
202
 
203
- it('should ceil a point', () => {
203
+ it('should ceil a point', (): void => {
204
204
  const point = new Point(3.14, 4.23);
205
205
  const ceiledPoint = point.ceil();
206
206
  expect(ceiledPoint.x).toBe(4);
@@ -6,13 +6,13 @@ const square = (): Polygon => new Polygon([new Point(0, 0), new Point(10, 0), ne
6
6
 
7
7
  const triangle = (): Polygon => new Polygon([new Point(0, 0), new Point(10, 0), new Point(0, 10)]);
8
8
 
9
- describe('Polygon', () => {
10
- describe('contains', () => {
11
- it('accepts a point well inside a square', () => {
9
+ describe('Polygon', (): void => {
10
+ describe('contains', (): void => {
11
+ it('accepts a point well inside a square', (): void => {
12
12
  expect(square().contains(5, 5)).toBe(true);
13
13
  });
14
14
 
15
- it('rejects points outside a square on every side', () => {
15
+ it('rejects points outside a square on every side', (): void => {
16
16
  const polygon = square();
17
17
  expect(polygon.contains(-1, 5)).toBe(false);
18
18
  expect(polygon.contains(11, 5)).toBe(false);
@@ -20,13 +20,13 @@ describe('Polygon', () => {
20
20
  expect(polygon.contains(5, 11)).toBe(false);
21
21
  });
22
22
 
23
- it('accepts a point inside a triangle and rejects one in the cut corner', () => {
23
+ it('accepts a point inside a triangle and rejects one in the cut corner', (): void => {
24
24
  const polygon = triangle();
25
25
  expect(polygon.contains(2, 2)).toBe(true);
26
26
  expect(polygon.contains(8, 8)).toBe(false);
27
27
  });
28
28
 
29
- it('agrees with itself once flattened', () => {
29
+ it('agrees with itself once flattened', (): void => {
30
30
  const probes: [number, number][] = [
31
31
  [5, 5],
32
32
  [-1, 5],
@@ -42,7 +42,7 @@ describe('Polygon', () => {
42
42
  }
43
43
  });
44
44
 
45
- it('agrees with itself once flattened for a triangle', () => {
45
+ it('agrees with itself once flattened for a triangle', (): void => {
46
46
  const probes: [number, number][] = [
47
47
  [2, 2],
48
48
  [8, 8],
@@ -57,35 +57,35 @@ describe('Polygon', () => {
57
57
  }
58
58
  });
59
59
 
60
- it('reports false for a polygon with no points', () => {
60
+ it('reports false for a polygon with no points', (): void => {
61
61
  expect(new Polygon().contains(0, 0)).toBe(false);
62
62
  });
63
63
  });
64
64
 
65
- describe('toNumberArray', () => {
66
- it('flattens points to x/y pairs', () => {
65
+ describe('toNumberArray', (): void => {
66
+ it('flattens points to x/y pairs', (): void => {
67
67
  expect(square().toNumberArray()).toStrictEqual([0, 0, 10, 0, 10, 10, 0, 10]);
68
68
  });
69
69
 
70
- it('passes an already flattened polygon through unchanged', () => {
70
+ it('passes an already flattened polygon through unchanged', (): void => {
71
71
  expect(square().flatten().toNumberArray()).toStrictEqual([0, 0, 10, 0, 10, 10, 0, 10]);
72
72
  });
73
73
  });
74
74
 
75
- describe('flatten', () => {
76
- it('marks the polygon flattened and swaps the point representation', () => {
75
+ describe('flatten', (): void => {
76
+ it('marks the polygon flattened and swaps the point representation', (): void => {
77
77
  const polygon = square().flatten();
78
78
  expect(polygon.flattened).toBe(true);
79
- expect(polygon._points.every((value) => typeof value === 'number')).toBe(true);
79
+ expect(polygon._points.every((value): boolean => typeof value === 'number')).toBe(true);
80
80
  });
81
81
  });
82
82
 
83
- describe('setTo', () => {
84
- it('reads a flat list of loose numbers as x/y pairs', () => {
83
+ describe('setTo', (): void => {
84
+ it('reads a flat list of loose numbers as x/y pairs', (): void => {
85
85
  expect(new Polygon([0, 0, 10, 0, 10, 10]).toNumberArray()).toStrictEqual([0, 0, 10, 0, 10, 10]);
86
86
  });
87
87
 
88
- it('reads a list of x/y tuples', () => {
88
+ it('reads a list of x/y tuples', (): void => {
89
89
  expect(
90
90
  new Polygon([
91
91
  [0, 0],
@@ -95,23 +95,23 @@ describe('Polygon', () => {
95
95
  ).toStrictEqual([0, 0, 10, 0, 10, 10]);
96
96
  });
97
97
 
98
- it('reads a list of plain x/y objects', () => {
98
+ it('reads a list of plain x/y objects', (): void => {
99
99
  expect(new Polygon([{ x: 0, y: 0 }, { x: 10, y: 0 }, new Point(10, 10)]).toNumberArray()).toStrictEqual([
100
100
  0, 0, 10, 0, 10, 10,
101
101
  ]);
102
102
  });
103
103
 
104
- it('stores every vertex as a point whatever form it came in as', () => {
105
- expect(new Polygon([0, 0, 10, 0]).points.every((value) => value instanceof Point)).toBe(true);
104
+ it('stores every vertex as a point whatever form it came in as', (): void => {
105
+ expect(new Polygon([0, 0, 10, 0]).points.every((value): boolean => value instanceof Point)).toBe(true);
106
106
  });
107
107
 
108
- it('replaces the previous points', () => {
108
+ it('replaces the previous points', (): void => {
109
109
  const polygon = square();
110
110
  polygon.points = [new Point(1, 1), new Point(2, 2)];
111
111
  expect(polygon.toNumberArray()).toStrictEqual([1, 1, 2, 2]);
112
112
  });
113
113
 
114
- it('empties the polygon when the points are cleared', () => {
114
+ it('empties the polygon when the points are cleared', (): void => {
115
115
  const polygon = square();
116
116
  polygon.points = null;
117
117
  expect(polygon.points).toStrictEqual([]);
@@ -119,18 +119,18 @@ describe('Polygon', () => {
119
119
  });
120
120
  });
121
121
 
122
- describe('calculateArea', () => {
123
- it('measures a square', () => {
122
+ describe('calculateArea', (): void => {
123
+ it('measures a square', (): void => {
124
124
  expect(Math.abs(square().area)).toBe(100);
125
125
  });
126
126
 
127
- it('measures a triangle as half its bounding square', () => {
127
+ it('measures a triangle as half its bounding square', (): void => {
128
128
  expect(Math.abs(triangle().area)).toBe(50);
129
129
  });
130
130
  });
131
131
 
132
- describe('clone', () => {
133
- it('copies the vertices into a detached polygon', () => {
132
+ describe('clone', (): void => {
133
+ it('copies the vertices into a detached polygon', (): void => {
134
134
  const original = square();
135
135
  const copy = original.clone();
136
136
  expect(copy.toNumberArray()).toStrictEqual(original.toNumberArray());
@@ -27,7 +27,7 @@ export class Polygon {
27
27
  this.flattened = false;
28
28
  /** @type {number} */
29
29
  this.type = GEOM_POLYGON;
30
- if (points) {
30
+ if (points !== null) {
31
31
  this.setTo(points);
32
32
  }
33
33
  }
@@ -111,7 +111,7 @@ export class Polygon {
111
111
  this.area = 0;
112
112
  const vertices: Point[] = [];
113
113
  this._points = vertices;
114
- if (points) {
114
+ if (points.length > 0) {
115
115
  // If points isn't an array, use arguments as the array
116
116
  if (!Array.isArray(points)) {
117
117
  console.error('[Polygon] setTo() error, input parameter is not an array', points);