@vpmedia/phaser 1.111.0 → 1.113.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 (296) hide show
  1. package/dist/index.js +1300 -1334
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +14 -10
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts +10 -8
  6. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_parser.d.ts +5 -4
  8. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  9. package/dist/phaser/core/array_set.d.ts.map +1 -1
  10. package/dist/phaser/core/cache.d.ts +4 -3
  11. package/dist/phaser/core/cache.d.ts.map +1 -1
  12. package/dist/phaser/core/const.d.ts.map +1 -1
  13. package/dist/phaser/core/device.d.ts.map +1 -1
  14. package/dist/phaser/core/device_util.d.ts.map +1 -1
  15. package/dist/phaser/core/dom.d.ts +3 -2
  16. package/dist/phaser/core/dom.d.ts.map +1 -1
  17. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  18. package/dist/phaser/core/factory.d.ts +1 -1
  19. package/dist/phaser/core/factory.d.ts.map +1 -1
  20. package/dist/phaser/core/frame.d.ts.map +1 -1
  21. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  22. package/dist/phaser/core/game.d.ts +1 -1
  23. package/dist/phaser/core/game.d.ts.map +1 -1
  24. package/dist/phaser/core/input.d.ts +8 -6
  25. package/dist/phaser/core/input.d.ts.map +1 -1
  26. package/dist/phaser/core/input_handler.d.ts +40 -30
  27. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  28. package/dist/phaser/core/input_mouse.d.ts +3 -2
  29. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  30. package/dist/phaser/core/input_mspointer.d.ts +3 -2
  31. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  32. package/dist/phaser/core/input_pointer.d.ts +6 -4
  33. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  34. package/dist/phaser/core/input_touch.d.ts +3 -2
  35. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  36. package/dist/phaser/core/loader.d.ts +4 -3
  37. package/dist/phaser/core/loader.d.ts.map +1 -1
  38. package/dist/phaser/core/loader_parser.d.ts +9 -8
  39. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  40. package/dist/phaser/core/raf.d.ts +3 -2
  41. package/dist/phaser/core/raf.d.ts.map +1 -1
  42. package/dist/phaser/core/registry.d.ts +7 -0
  43. package/dist/phaser/core/registry.d.ts.map +1 -0
  44. package/dist/phaser/core/scale_manager.d.ts +1 -1
  45. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  46. package/dist/phaser/core/scene.d.ts +0 -1
  47. package/dist/phaser/core/scene.d.ts.map +1 -1
  48. package/dist/phaser/core/scene_manager.d.ts +1 -1
  49. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  50. package/dist/phaser/core/signal.d.ts +0 -1
  51. package/dist/phaser/core/signal.d.ts.map +1 -1
  52. package/dist/phaser/core/signal_binding.d.ts +4 -3
  53. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  54. package/dist/phaser/core/sound.d.ts +6 -4
  55. package/dist/phaser/core/sound.d.ts.map +1 -1
  56. package/dist/phaser/core/sound_manager.d.ts +3 -2
  57. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  58. package/dist/phaser/core/sound_sprite.d.ts +5 -4
  59. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  60. package/dist/phaser/core/stage.d.ts +3 -2
  61. package/dist/phaser/core/stage.d.ts.map +1 -1
  62. package/dist/phaser/core/time.d.ts +1 -1
  63. package/dist/phaser/core/time.d.ts.map +1 -1
  64. package/dist/phaser/core/timer.d.ts +1 -1
  65. package/dist/phaser/core/timer.d.ts.map +1 -1
  66. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  67. package/dist/phaser/core/tween.d.ts +10 -7
  68. package/dist/phaser/core/tween.d.ts.map +1 -1
  69. package/dist/phaser/core/tween_data.d.ts +3 -2
  70. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  71. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  72. package/dist/phaser/core/tween_manager.d.ts +3 -2
  73. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  74. package/dist/phaser/core/world.d.ts +3 -2
  75. package/dist/phaser/core/world.d.ts.map +1 -1
  76. package/dist/phaser/display/bitmap_text.d.ts +3 -2
  77. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  78. package/dist/phaser/display/button.d.ts +3 -2
  79. package/dist/phaser/display/button.d.ts.map +1 -1
  80. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  81. package/dist/phaser/display/canvas/graphics.d.ts +7 -6
  82. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  83. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  84. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  85. package/dist/phaser/display/canvas/renderer.d.ts +10 -8
  86. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  87. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  88. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  89. package/dist/phaser/display/canvas/util.d.ts +2 -2
  90. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  91. package/dist/phaser/display/display_object.d.ts +14 -12
  92. package/dist/phaser/display/display_object.d.ts.map +1 -1
  93. package/dist/phaser/display/graphics.d.ts +8 -5
  94. package/dist/phaser/display/graphics.d.ts.map +1 -1
  95. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  96. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  97. package/dist/phaser/display/group.d.ts +4 -3
  98. package/dist/phaser/display/group.d.ts.map +1 -1
  99. package/dist/phaser/display/image.d.ts +13 -10
  100. package/dist/phaser/display/image.d.ts.map +1 -1
  101. package/dist/phaser/display/sprite_batch.d.ts +3 -2
  102. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  103. package/dist/phaser/display/sprite_util.d.ts +18 -15
  104. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  105. package/dist/phaser/display/text.d.ts +11 -9
  106. package/dist/phaser/display/text.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  109. package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
  110. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  111. package/dist/phaser/display/webgl/earcut.d.ts +1 -1
  112. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  114. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
  115. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  116. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  117. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  118. package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
  119. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  120. package/dist/phaser/display/webgl/graphics.d.ts +7 -6
  121. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  122. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  123. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  124. package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
  125. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  126. package/dist/phaser/display/webgl/renderer.d.ts +16 -11
  127. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  128. package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
  129. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  130. package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
  131. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  132. package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
  133. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  134. package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
  135. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  136. package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
  137. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  138. package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
  139. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  140. package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
  141. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  142. package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
  143. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  144. package/dist/phaser/display/webgl/texture.d.ts +3 -2
  145. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  147. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  148. package/dist/phaser/geom/circle.d.ts +4 -1
  149. package/dist/phaser/geom/circle.d.ts.map +1 -1
  150. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  151. package/dist/phaser/geom/line.d.ts +1 -1
  152. package/dist/phaser/geom/line.d.ts.map +1 -1
  153. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  154. package/dist/phaser/geom/point.d.ts.map +1 -1
  155. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  156. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  157. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  159. package/dist/phaser/geom/util/ellipse.d.ts +3 -2
  160. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  161. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  162. package/dist/phaser/geom/util/matrix.d.ts +2 -2
  163. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  164. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  165. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  166. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  167. package/dist/phaser/util/math.d.ts.map +1 -1
  168. package/package.json +5 -4
  169. package/src/phaser/core/animation.ts +64 -60
  170. package/src/phaser/core/animation_manager.ts +54 -55
  171. package/src/phaser/core/animation_parser.ts +9 -9
  172. package/src/phaser/core/array_set.ts +16 -17
  173. package/src/phaser/core/cache.ts +92 -93
  174. package/src/phaser/core/const.ts +1 -1
  175. package/src/phaser/core/device.ts +24 -29
  176. package/src/phaser/core/device_util.ts +28 -32
  177. package/src/phaser/core/dom.ts +54 -65
  178. package/src/phaser/core/event_manager.ts +64 -94
  179. package/src/phaser/core/factory.ts +14 -14
  180. package/src/phaser/core/frame.ts +28 -28
  181. package/src/phaser/core/frame_data.test.ts +100 -0
  182. package/src/phaser/core/frame_data.ts +24 -24
  183. package/src/phaser/core/frame_util.ts +2 -2
  184. package/src/phaser/core/game.ts +50 -51
  185. package/src/phaser/core/input.ts +104 -110
  186. package/src/phaser/core/input_handler.test.ts +113 -0
  187. package/src/phaser/core/input_handler.ts +199 -218
  188. package/src/phaser/core/input_mouse.ts +71 -54
  189. package/src/phaser/core/input_mspointer.ts +52 -39
  190. package/src/phaser/core/input_pointer.ts +81 -80
  191. package/src/phaser/core/input_touch.ts +49 -36
  192. package/src/phaser/core/loader.ts +175 -154
  193. package/src/phaser/core/loader_parser.ts +39 -57
  194. package/src/phaser/core/raf.ts +8 -7
  195. package/src/phaser/core/registry.test.ts +31 -0
  196. package/src/phaser/core/registry.ts +9 -0
  197. package/src/phaser/core/scale_manager.ts +156 -152
  198. package/src/phaser/core/scene.ts +9 -13
  199. package/src/phaser/core/scene_manager.ts +47 -47
  200. package/src/phaser/core/signal.test.ts +4 -4
  201. package/src/phaser/core/signal.ts +41 -52
  202. package/src/phaser/core/signal_binding.ts +26 -25
  203. package/src/phaser/core/signal_dispatch.test.ts +180 -0
  204. package/src/phaser/core/sound.ts +75 -83
  205. package/src/phaser/core/sound_manager.ts +58 -56
  206. package/src/phaser/core/sound_sprite.ts +17 -16
  207. package/src/phaser/core/stage.ts +25 -24
  208. package/src/phaser/core/time.ts +52 -52
  209. package/src/phaser/core/timer.test.ts +187 -0
  210. package/src/phaser/core/timer.ts +82 -69
  211. package/src/phaser/core/timer_event.ts +10 -10
  212. package/src/phaser/core/tween.ts +90 -93
  213. package/src/phaser/core/tween_data.ts +45 -51
  214. package/src/phaser/core/tween_easing.test.ts +106 -0
  215. package/src/phaser/core/tween_easing.ts +151 -123
  216. package/src/phaser/core/tween_manager.ts +19 -18
  217. package/src/phaser/core/world.ts +4 -3
  218. package/src/phaser/display/bitmap_text.ts +56 -64
  219. package/src/phaser/display/button.ts +33 -32
  220. package/src/phaser/display/canvas/buffer.ts +8 -8
  221. package/src/phaser/display/canvas/graphics.ts +36 -37
  222. package/src/phaser/display/canvas/masker.ts +2 -2
  223. package/src/phaser/display/canvas/pool.test.ts +106 -0
  224. package/src/phaser/display/canvas/pool.ts +25 -27
  225. package/src/phaser/display/canvas/renderer.ts +32 -31
  226. package/src/phaser/display/canvas/tinter.ts +27 -27
  227. package/src/phaser/display/canvas/util.ts +7 -10
  228. package/src/phaser/display/display_object.ts +114 -118
  229. package/src/phaser/display/graphics.ts +121 -119
  230. package/src/phaser/display/graphics_data.ts +12 -12
  231. package/src/phaser/display/graphics_data_util.ts +2 -3
  232. package/src/phaser/display/group.ts +50 -57
  233. package/src/phaser/display/image.ts +55 -52
  234. package/src/phaser/display/sprite_batch.ts +3 -2
  235. package/src/phaser/display/sprite_util.ts +48 -54
  236. package/src/phaser/display/text.ts +199 -204
  237. package/src/phaser/display/webgl/abstract_filter.ts +9 -9
  238. package/src/phaser/display/webgl/base_texture.ts +21 -24
  239. package/src/phaser/display/webgl/blend_manager.ts +6 -10
  240. package/src/phaser/display/webgl/earcut.ts +73 -37
  241. package/src/phaser/display/webgl/earcut_node.ts +10 -10
  242. package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
  243. package/src/phaser/display/webgl/filter_manager.ts +13 -12
  244. package/src/phaser/display/webgl/filter_texture.ts +14 -13
  245. package/src/phaser/display/webgl/graphics.ts +51 -57
  246. package/src/phaser/display/webgl/graphics_data.ts +15 -14
  247. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  248. package/src/phaser/display/webgl/render_texture.ts +26 -25
  249. package/src/phaser/display/webgl/renderer.ts +57 -62
  250. package/src/phaser/display/webgl/shader/complex.ts +28 -12
  251. package/src/phaser/display/webgl/shader/fast.ts +30 -12
  252. package/src/phaser/display/webgl/shader/normal.ts +70 -57
  253. package/src/phaser/display/webgl/shader/primitive.ts +26 -11
  254. package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
  255. package/src/phaser/display/webgl/shader/strip.ts +27 -12
  256. package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
  257. package/src/phaser/display/webgl/shader_manager.ts +26 -34
  258. package/src/phaser/display/webgl/sprite_batch.ts +67 -61
  259. package/src/phaser/display/webgl/stencil_manager.ts +23 -34
  260. package/src/phaser/display/webgl/texture.ts +43 -50
  261. package/src/phaser/display/webgl/texture_util.ts +2 -3
  262. package/src/phaser/display/webgl/util.ts +26 -25
  263. package/src/phaser/geom/circle.test.ts +2 -3
  264. package/src/phaser/geom/circle.ts +36 -36
  265. package/src/phaser/geom/ellipse.test.ts +73 -71
  266. package/src/phaser/geom/ellipse.ts +14 -14
  267. package/src/phaser/geom/line.test.ts +5 -5
  268. package/src/phaser/geom/line.ts +35 -35
  269. package/src/phaser/geom/matrix.test.ts +1 -1
  270. package/src/phaser/geom/matrix.ts +27 -27
  271. package/src/phaser/geom/point.test.ts +1 -2
  272. package/src/phaser/geom/point.ts +35 -35
  273. package/src/phaser/geom/polygon.test.ts +82 -0
  274. package/src/phaser/geom/polygon.ts +16 -16
  275. package/src/phaser/geom/rectangle.test.ts +14 -14
  276. package/src/phaser/geom/rectangle.ts +83 -75
  277. package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
  278. package/src/phaser/geom/rounded_rectangle.ts +9 -9
  279. package/src/phaser/geom/util/circle.test.ts +25 -23
  280. package/src/phaser/geom/util/circle.ts +9 -18
  281. package/src/phaser/geom/util/ellipse.test.ts +7 -5
  282. package/src/phaser/geom/util/ellipse.ts +3 -2
  283. package/src/phaser/geom/util/line.test.ts +10 -8
  284. package/src/phaser/geom/util/line.ts +6 -16
  285. package/src/phaser/geom/util/matrix.test.ts +20 -18
  286. package/src/phaser/geom/util/matrix.ts +8 -15
  287. package/src/phaser/geom/util/point.test.ts +8 -6
  288. package/src/phaser/geom/util/point.ts +24 -28
  289. package/src/phaser/geom/util/polygon.test.ts +12 -10
  290. package/src/phaser/geom/util/polygon.ts +2 -2
  291. package/src/phaser/geom/util/rectangle.test.ts +10 -8
  292. package/src/phaser/geom/util/rectangle.ts +18 -37
  293. package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
  294. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
  295. package/src/phaser/util/math.test.ts +11 -11
  296. package/src/phaser/util/math.ts +29 -46
@@ -5,11 +5,11 @@ import { clone, contains, circumferencePoint } from './util/circle.js';
5
5
  import { GEOM_CIRCLE } from '../core/const.js';
6
6
 
7
7
  export class Circle {
8
- x: number;
9
- y: number;
10
- _diameter: number;
11
- _radius: number;
12
- type: number;
8
+ public x: number;
9
+ public y: number;
10
+ public _diameter: number;
11
+ public _radius: number;
12
+ public type: number;
13
13
 
14
14
  /**
15
15
  * Creates a new Circle instance.
@@ -17,7 +17,7 @@ export class Circle {
17
17
  * @param {number} y - The y coordinate of the center point (default: 0).
18
18
  * @param {number} diameter - The diameter of the circle (default: 0).
19
19
  */
20
- constructor(x: number = 0, y: number = 0, diameter: number = 0) {
20
+ public constructor(x = 0, y = 0, diameter = 0) {
21
21
  /** @type {number} */
22
22
  this.x = x;
23
23
  /** @type {number} */
@@ -37,7 +37,7 @@ export class Circle {
37
37
  * Calculates the circumference of this circle.
38
38
  * @returns {number} The circumference of this circle.
39
39
  */
40
- circumference() {
40
+ public circumference() {
41
41
  return 2 * (Math.PI * this._radius);
42
42
  }
43
43
 
@@ -46,8 +46,8 @@ export class Circle {
46
46
  * @param {Point} output - The point to store the result in (optional).
47
47
  * @returns {Point} A random point within this circle.
48
48
  */
49
- random(output: Point | null = null) {
50
- const result = output || new Point();
49
+ public random(output: Point | null = null) {
50
+ const result = output ?? new Point();
51
51
  const t = 2 * Math.PI * Math.random();
52
52
  const u = Math.random() + Math.random();
53
53
  const r = u > 1 ? 2 - u : u;
@@ -62,7 +62,7 @@ export class Circle {
62
62
  * Gets the bounding rectangle of this circle.
63
63
  * @returns {Rectangle} The bounding rectangle of this circle.
64
64
  */
65
- getBounds() {
65
+ public getBounds() {
66
66
  return new Rectangle(this.x - this.radius, this.y - this.radius, this.diameter, this.diameter);
67
67
  }
68
68
 
@@ -73,7 +73,7 @@ export class Circle {
73
73
  * @param {number} diameter - The new diameter of the circle.
74
74
  * @returns {Circle} This circle instance for chaining.
75
75
  */
76
- setTo(x: number, y: number, diameter: number) {
76
+ public setTo(x: number, y: number, diameter: number) {
77
77
  this.x = x;
78
78
  this.y = y;
79
79
  this._diameter = diameter;
@@ -86,7 +86,7 @@ export class Circle {
86
86
  * @param {Circle} source - The circle to copy values from.
87
87
  * @returns {Circle} This circle instance for chaining.
88
88
  */
89
- copyFrom(source: Circle) {
89
+ public copyFrom(source: Circle) {
90
90
  return this.setTo(source.x, source.y, source.diameter);
91
91
  }
92
92
 
@@ -95,7 +95,7 @@ export class Circle {
95
95
  * @param {Circle} dest - The circle to copy values to.
96
96
  * @returns {Circle} The destination circle.
97
97
  */
98
- copyTo(dest: Circle) {
98
+ public copyTo(dest: Circle) {
99
99
  dest.x = this.x;
100
100
  dest.y = this.y;
101
101
  dest.diameter = this._diameter;
@@ -108,7 +108,7 @@ export class Circle {
108
108
  * @param {boolean} round - Whether to round the result (default: false).
109
109
  * @returns {number} The distance between the circles.
110
110
  */
111
- distance(dest: Circle, round: boolean = false) {
111
+ public distance(dest: { x: number; y: number }, round = false) {
112
112
  const d = distance(this.x, this.y, dest.x, dest.y);
113
113
  return round ? Math.round(d) : d;
114
114
  }
@@ -117,7 +117,7 @@ export class Circle {
117
117
  * Creates a clone of this circle.
118
118
  * @returns {Circle} A new circle with the same values as this one.
119
119
  */
120
- clone() {
120
+ public clone() {
121
121
  return clone(this);
122
122
  }
123
123
 
@@ -127,7 +127,7 @@ export class Circle {
127
127
  * @param {number} y - The y coordinate of the point to check.
128
128
  * @returns {boolean} True if the point is contained within this circle, false otherwise.
129
129
  */
130
- contains(x: number, y: number) {
130
+ public contains(x: number, y: number) {
131
131
  return contains(this, x, y);
132
132
  }
133
133
 
@@ -138,7 +138,7 @@ export class Circle {
138
138
  * @param {Point} out - The point to store the result in (optional).
139
139
  * @returns {Point} A point at the specified angle on the circumference of this circle.
140
140
  */
141
- circumferencePoint(angle: number, asDegrees?: boolean, out?: Point) {
141
+ public circumferencePoint(angle: number, asDegrees?: boolean, out?: Point) {
142
142
  return circumferencePoint(this, angle, asDegrees, out);
143
143
  }
144
144
 
@@ -148,7 +148,7 @@ export class Circle {
148
148
  * @param {number} dy - The amount to offset the y coordinate by.
149
149
  * @returns {Circle} This circle instance for chaining.
150
150
  */
151
- offset(dx: number, dy: number) {
151
+ public offset(dx: number, dy: number) {
152
152
  this.x += dx;
153
153
  this.y += dy;
154
154
  return this;
@@ -159,7 +159,7 @@ export class Circle {
159
159
  * @param {Point} point - The point to offset the circle by.
160
160
  * @returns {Circle} This circle instance for chaining.
161
161
  */
162
- offsetPoint(point: Point) {
162
+ public offsetPoint(point: Point) {
163
163
  return this.offset(point.x, point.y);
164
164
  }
165
165
 
@@ -167,7 +167,7 @@ export class Circle {
167
167
  * Returns a string representation of this circle.
168
168
  * @returns {string} A string representation of the circle.
169
169
  */
170
- toString() {
170
+ public toString() {
171
171
  return `[{Circle (x=${this.x} y=${this.y} diameter=${this.diameter} radius=${this.radius})}]`;
172
172
  }
173
173
 
@@ -175,14 +175,14 @@ export class Circle {
175
175
  * Gets the diameter of this circle.
176
176
  * @returns {number} The diameter of this circle.
177
177
  */
178
- get diameter() {
178
+ public get diameter() {
179
179
  return this._diameter;
180
180
  }
181
181
 
182
182
  /**
183
183
  * Sets the diameter of this circle.
184
184
  */
185
- set diameter(value) {
185
+ public set diameter(value) {
186
186
  if (value > 0) {
187
187
  this._diameter = value;
188
188
  this._radius = value * 0.5;
@@ -193,14 +193,14 @@ export class Circle {
193
193
  * Gets the radius of this circle.
194
194
  * @returns {number} The radius of this circle.
195
195
  */
196
- get radius() {
196
+ public get radius() {
197
197
  return this._radius;
198
198
  }
199
199
 
200
200
  /**
201
201
  * Sets the radius of this circle.
202
202
  */
203
- set radius(value) {
203
+ public set radius(value) {
204
204
  if (value > 0) {
205
205
  this._radius = value;
206
206
  this._diameter = value * 2;
@@ -211,14 +211,14 @@ export class Circle {
211
211
  * Gets the left coordinate of this circle.
212
212
  * @returns {number} The left coordinate of this circle.
213
213
  */
214
- get left() {
214
+ public get left() {
215
215
  return this.x - this._radius;
216
216
  }
217
217
 
218
218
  /**
219
219
  * Sets the left coordinate of this circle.
220
220
  */
221
- set left(value) {
221
+ public set left(value) {
222
222
  if (value > this.x) {
223
223
  this._radius = 0;
224
224
  this._diameter = 0;
@@ -231,14 +231,14 @@ export class Circle {
231
231
  * Gets the right coordinate of this circle.
232
232
  * @returns {number} The right coordinate of this circle.
233
233
  */
234
- get right() {
234
+ public get right() {
235
235
  return this.x + this._radius;
236
236
  }
237
237
 
238
238
  /**
239
239
  * Sets the right coordinate of this circle.
240
240
  */
241
- set right(value) {
241
+ public set right(value) {
242
242
  if (value < this.x) {
243
243
  this._radius = 0;
244
244
  this._diameter = 0;
@@ -251,14 +251,14 @@ export class Circle {
251
251
  * Gets the top coordinate of this circle.
252
252
  * @returns {number} The top coordinate of this circle.
253
253
  */
254
- get top() {
254
+ public get top() {
255
255
  return this.y - this._radius;
256
256
  }
257
257
 
258
258
  /**
259
259
  * Sets the top coordinate of this circle.
260
260
  */
261
- set top(value) {
261
+ public set top(value) {
262
262
  if (value > this.y) {
263
263
  this._radius = 0;
264
264
  this._diameter = 0;
@@ -271,14 +271,14 @@ export class Circle {
271
271
  * Gets the bottom coordinate of this circle.
272
272
  * @returns {number} The bottom coordinate of this circle.
273
273
  */
274
- get bottom() {
274
+ public get bottom() {
275
275
  return this.y + this._radius;
276
276
  }
277
277
 
278
278
  /**
279
279
  * Sets the bottom coordinate of this circle.
280
280
  */
281
- set bottom(value) {
281
+ public set bottom(value) {
282
282
  if (value < this.y) {
283
283
  this._radius = 0;
284
284
  this._diameter = 0;
@@ -291,7 +291,7 @@ export class Circle {
291
291
  * Gets the area of this circle.
292
292
  * @returns {number} The area of this circle.
293
293
  */
294
- get area() {
294
+ public get area() {
295
295
  if (this._radius > 0) {
296
296
  return Math.PI * this._radius * this._radius;
297
297
  }
@@ -302,15 +302,15 @@ export class Circle {
302
302
  * Checks if this circle is empty (has zero diameter).
303
303
  * @returns {boolean} True if the circle is empty, false otherwise.
304
304
  */
305
- get empty() {
305
+ public get empty() {
306
306
  return this._diameter === 0;
307
307
  }
308
308
 
309
309
  /**
310
310
  * Sets whether this circle is empty (zero diameter).
311
311
  */
312
- set empty(value) {
313
- if (value === true) {
312
+ public set empty(value) {
313
+ if (value) {
314
314
  this.setTo(0, 0, 0);
315
315
  }
316
316
  }
@@ -1,84 +1,86 @@
1
- import { expect } from 'vitest';
1
+ import { describe, expect, it } from 'vitest';
2
2
  import { Ellipse } from './ellipse.js';
3
3
 
4
- it('should create an ellipse with default values', () => {
5
- const ellipse = new Ellipse();
6
- expect(ellipse.x).toBe(0);
7
- expect(ellipse.y).toBe(0);
8
- expect(ellipse.width).toBe(0);
9
- expect(ellipse.height).toBe(0);
10
- });
4
+ describe('Ellipse', () => {
5
+ it('should create an ellipse with default values', () => {
6
+ const ellipse = new Ellipse();
7
+ expect(ellipse.x).toBe(0);
8
+ expect(ellipse.y).toBe(0);
9
+ expect(ellipse.width).toBe(0);
10
+ expect(ellipse.height).toBe(0);
11
+ });
11
12
 
12
- it('should create an ellipse with custom x, y, width, height', () => {
13
- const ellipse = new Ellipse(10, 20, 30, 40);
14
- expect(ellipse.x).toBe(10);
15
- expect(ellipse.y).toBe(20);
16
- expect(ellipse.width).toBe(30);
17
- expect(ellipse.height).toBe(40);
18
- });
13
+ it('should create an ellipse with custom x, y, width, height', () => {
14
+ const ellipse = new Ellipse(10, 20, 30, 40);
15
+ expect(ellipse.x).toBe(10);
16
+ expect(ellipse.y).toBe(20);
17
+ expect(ellipse.width).toBe(30);
18
+ expect(ellipse.height).toBe(40);
19
+ });
19
20
 
20
- it('should set the ellipse values to new x, y, width, height', () => {
21
- const ellipse = new Ellipse();
22
- ellipse.setTo(10, 20, 30, 40);
23
- expect(ellipse.x).toBe(10);
24
- expect(ellipse.y).toBe(20);
25
- expect(ellipse.width).toBe(30);
26
- expect(ellipse.height).toBe(40);
27
- });
21
+ it('should set the ellipse values to new x, y, width, height', () => {
22
+ const ellipse = new Ellipse();
23
+ ellipse.setTo(10, 20, 30, 40);
24
+ expect(ellipse.x).toBe(10);
25
+ expect(ellipse.y).toBe(20);
26
+ expect(ellipse.width).toBe(30);
27
+ expect(ellipse.height).toBe(40);
28
+ });
28
29
 
29
- it('should return the ellipse instance', () => {
30
- const ellipse = new Ellipse();
31
- const result = ellipse.setTo(10, 20, 30, 40);
32
- expect(result).toBe(ellipse);
33
- });
30
+ it('should return the ellipse instance', () => {
31
+ const ellipse = new Ellipse();
32
+ const result = ellipse.setTo(10, 20, 30, 40);
33
+ expect(result).toBe(ellipse);
34
+ });
34
35
 
35
- it('should create a rectangle with correct bounds', () => {
36
- const ellipse = new Ellipse(10, 20, 30, 40);
37
- const bounds = ellipse.getBounds();
38
- expect(bounds.x).toBe(10 - 30);
39
- expect(bounds.y).toBe(20 - 40);
40
- expect(bounds.width).toBe(30);
41
- expect(bounds.height).toBe(40);
42
- });
36
+ it('should create a rectangle with correct bounds', () => {
37
+ const ellipse = new Ellipse(10, 20, 30, 40);
38
+ const bounds = ellipse.getBounds();
39
+ expect(bounds.x).toBe(10 - 30);
40
+ expect(bounds.y).toBe(20 - 40);
41
+ expect(bounds.width).toBe(30);
42
+ expect(bounds.height).toBe(40);
43
+ });
43
44
 
44
- it('should copy the values from another ellipse', () => {
45
- const source = new Ellipse(10, 20, 30, 40);
46
- const target = new Ellipse();
47
- target.copyFrom(source);
48
- expect(target.x).toBe(source.x);
49
- expect(target.y).toBe(source.y);
50
- expect(target.width).toBe(source.width);
51
- expect(target.height).toBe(source.height);
52
- });
45
+ it('should copy the values from another ellipse', () => {
46
+ const source = new Ellipse(10, 20, 30, 40);
47
+ const target = new Ellipse();
48
+ target.copyFrom(source);
49
+ expect(target.x).toBe(source.x);
50
+ expect(target.y).toBe(source.y);
51
+ expect(target.width).toBe(source.width);
52
+ expect(target.height).toBe(source.height);
53
+ });
53
54
 
54
- it('should copy the values to another ellipse', () => {
55
- const source = new Ellipse(10, 20, 30, 40);
56
- const target = new Ellipse();
57
- source.copyTo(target);
58
- expect(target.x).toBe(source.x);
59
- expect(target.y).toBe(source.y);
60
- expect(target.width).toBe(source.width);
61
- expect(target.height).toBe(source.height);
62
- });
55
+ it('should copy the values to another ellipse', () => {
56
+ const source = new Ellipse(10, 20, 30, 40);
57
+ const target = new Ellipse();
58
+ source.copyTo(target);
59
+ expect(target.x).toBe(source.x);
60
+ expect(target.y).toBe(source.y);
61
+ expect(target.width).toBe(source.width);
62
+ expect(target.height).toBe(source.height);
63
+ });
63
64
 
64
- it('should return true if point is inside the ellipse', () => {
65
- const ellipse = new Ellipse(10, 20, 30, 40);
66
- expect(ellipse.contains(20, 30)).toBe(true);
67
- });
65
+ it('should return true if point is inside the ellipse', () => {
66
+ const ellipse = new Ellipse(10, 20, 30, 40);
67
+ expect(ellipse.contains(20, 30)).toBe(true);
68
+ });
68
69
 
69
- it('should return false if point is outside the ellipse', () => {
70
- const ellipse = new Ellipse(10, 20, 30, 40);
71
- expect(ellipse.contains(-5, -10)).toBe(false);
72
- });
70
+ it('should return false if point is outside the ellipse', () => {
71
+ const ellipse = new Ellipse(10, 20, 30, 40);
72
+ expect(ellipse.contains(-5, -10)).toBe(false);
73
+ });
73
74
 
74
- it('should generate a random point within the ellipse', () => {
75
- const ellipse = new Ellipse(10, 20, 30, 40);
76
- const point = ellipse.random();
77
- expect(typeof point.x).toBe('number');
78
- expect(typeof point.y).toBe('number');
79
- });
75
+ it('should generate a random point within the ellipse', () => {
76
+ const ellipse = new Ellipse(10, 20, 30, 40);
77
+ const point = ellipse.random();
78
+ expect(point.x).toBeTypeOf('number');
79
+ expect(point.y).toBeTypeOf('number');
80
+ });
80
81
 
81
- it('should return a string representation of the ellipse', () => {
82
- const ellipse = new Ellipse(10, 20, 30, 40);
83
- expect(ellipse.toString()).toBe('[{Ellipse (x=10 y=20 width=30 height=40)}]');
82
+ it('should return a string representation of the ellipse', () => {
83
+ const ellipse = new Ellipse(10, 20, 30, 40);
84
+ expect(ellipse.toString()).toBe('[{Ellipse (x=10 y=20 width=30 height=40)}]');
85
+ });
84
86
  });
@@ -4,11 +4,11 @@ import { Rectangle } from './rectangle.js';
4
4
  import { contains } from './util/ellipse.js';
5
5
 
6
6
  export class Ellipse {
7
- x: number;
8
- y: number;
9
- width: number;
10
- height: number;
11
- type: number;
7
+ public x: number;
8
+ public y: number;
9
+ public width: number;
10
+ public height: number;
11
+ public type: number;
12
12
 
13
13
  /**
14
14
  * Creates a new Ellipse instance.
@@ -17,7 +17,7 @@ export class Ellipse {
17
17
  * @param {number} width - The width of the ellipse (default: 0).
18
18
  * @param {number} height - The height of the ellipse (default: 0).
19
19
  */
20
- constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
20
+ public constructor(x = 0, y = 0, width = 0, height = 0) {
21
21
  /** @type {number} */
22
22
  this.x = x;
23
23
  /** @type {number} */
@@ -38,7 +38,7 @@ export class Ellipse {
38
38
  * @param {number} height - The new height of the ellipse.
39
39
  * @returns {Ellipse} This ellipse instance for chaining.
40
40
  */
41
- setTo(x: number, y: number, width: number, height: number) {
41
+ public setTo(x: number, y: number, width: number, height: number) {
42
42
  this.x = x;
43
43
  this.y = y;
44
44
  this.width = width;
@@ -50,7 +50,7 @@ export class Ellipse {
50
50
  * Gets the bounding rectangle of this ellipse.
51
51
  * @returns {Rectangle} The bounding rectangle of this ellipse.
52
52
  */
53
- getBounds() {
53
+ public getBounds() {
54
54
  return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
55
55
  }
56
56
 
@@ -59,7 +59,7 @@ export class Ellipse {
59
59
  * @param {Ellipse} source - The ellipse to copy values from.
60
60
  * @returns {Ellipse} This ellipse instance for chaining.
61
61
  */
62
- copyFrom(source: Ellipse) {
62
+ public copyFrom(source: Ellipse) {
63
63
  return this.setTo(source.x, source.y, source.width, source.height);
64
64
  }
65
65
 
@@ -68,7 +68,7 @@ export class Ellipse {
68
68
  * @param {Ellipse} dest - The ellipse to copy values to.
69
69
  * @returns {Ellipse} The destination ellipse.
70
70
  */
71
- copyTo(dest: Ellipse) {
71
+ public copyTo(dest: Ellipse) {
72
72
  dest.x = this.x;
73
73
  dest.y = this.y;
74
74
  dest.width = this.width;
@@ -82,7 +82,7 @@ export class Ellipse {
82
82
  * @param {number} y - The y coordinate of the point to check.
83
83
  * @returns {boolean} True if the point is contained within this ellipse, false otherwise.
84
84
  */
85
- contains(x: number, y: number) {
85
+ public contains(x: number, y: number) {
86
86
  return contains(this, x, y);
87
87
  }
88
88
 
@@ -91,8 +91,8 @@ export class Ellipse {
91
91
  * @param {Point} output - The point to store the result in (optional).
92
92
  * @returns {Point} A random point within this ellipse.
93
93
  */
94
- random(output: Point | null = null) {
95
- const result = output || new Point();
94
+ public random(output: Point | null = null) {
95
+ const result = output ?? new Point();
96
96
  const p = Math.random() * Math.PI * 2;
97
97
  const r = Math.random();
98
98
  result.x = Math.sqrt(r) * Math.cos(p);
@@ -106,7 +106,7 @@ export class Ellipse {
106
106
  * Returns a string representation of this ellipse.
107
107
  * @returns {string} A string representation of the ellipse.
108
108
  */
109
- toString() {
109
+ public toString() {
110
110
  return `[{Ellipse (x=${this.x} y=${this.y} width=${this.width} height=${this.height})}]`;
111
111
  }
112
112
  }
@@ -1,4 +1,4 @@
1
- import { expect } from 'vitest';
1
+ import { expect, describe, it } from 'vitest';
2
2
  import { degToRad } from '../util/math.js';
3
3
  import { Line } from './line.js';
4
4
 
@@ -62,7 +62,7 @@ describe('Line', () => {
62
62
  const line = new Line(0, 0, 10, 10);
63
63
  const line2 = new Line(5, 5, 15, 15);
64
64
  const result = line.intersects(line2, true, null);
65
- expect(result).toBe(null);
65
+ expect(result).toBeNull();
66
66
  });
67
67
 
68
68
  it('should reflect the line across another line correctly', () => {
@@ -81,7 +81,7 @@ describe('Line', () => {
81
81
 
82
82
  it('should center the line on a point correctly', () => {
83
83
  const line = new Line(0, 0, 10, 10);
84
- const result = line.centerOn(10, 10);
84
+ line.centerOn(10, 10);
85
85
  expect(line.start.x).toBe(10 - (line.end.x - line.start.x) / 2);
86
86
  expect(line.start.y).toBe(10 - (line.end.y - line.start.y) / 2);
87
87
  });
@@ -101,8 +101,8 @@ describe('Line', () => {
101
101
  it('should get the random point on the line correctly', () => {
102
102
  const line = new Line(0, 0, 10, 10);
103
103
  const result = line.random(null);
104
- expect(result.x > 0).toBe(true);
105
- expect(result.y > 0).toBe(true);
104
+ expect(result.x).toBeGreaterThan(0);
105
+ expect(result.y).toBeGreaterThan(0);
106
106
  });
107
107
 
108
108
  it('should get the coordinates on the line correctly', () => {