@vpmedia/phaser 1.112.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 (295) hide show
  1. package/dist/index.js +1261 -1314
  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.map +1 -1
  23. package/dist/phaser/core/input.d.ts +8 -6
  24. package/dist/phaser/core/input.d.ts.map +1 -1
  25. package/dist/phaser/core/input_handler.d.ts +40 -30
  26. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  27. package/dist/phaser/core/input_mouse.d.ts +3 -2
  28. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  29. package/dist/phaser/core/input_mspointer.d.ts +3 -2
  30. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  31. package/dist/phaser/core/input_pointer.d.ts +6 -4
  32. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  33. package/dist/phaser/core/input_touch.d.ts +3 -2
  34. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  35. package/dist/phaser/core/loader.d.ts +4 -3
  36. package/dist/phaser/core/loader.d.ts.map +1 -1
  37. package/dist/phaser/core/loader_parser.d.ts +9 -8
  38. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  39. package/dist/phaser/core/raf.d.ts +3 -2
  40. package/dist/phaser/core/raf.d.ts.map +1 -1
  41. package/dist/phaser/core/registry.d.ts +7 -0
  42. package/dist/phaser/core/registry.d.ts.map +1 -0
  43. package/dist/phaser/core/scale_manager.d.ts +1 -1
  44. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  45. package/dist/phaser/core/scene.d.ts +0 -1
  46. package/dist/phaser/core/scene.d.ts.map +1 -1
  47. package/dist/phaser/core/scene_manager.d.ts +1 -1
  48. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  49. package/dist/phaser/core/signal.d.ts +0 -1
  50. package/dist/phaser/core/signal.d.ts.map +1 -1
  51. package/dist/phaser/core/signal_binding.d.ts +4 -3
  52. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  53. package/dist/phaser/core/sound.d.ts +6 -4
  54. package/dist/phaser/core/sound.d.ts.map +1 -1
  55. package/dist/phaser/core/sound_manager.d.ts +3 -2
  56. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  57. package/dist/phaser/core/sound_sprite.d.ts +5 -4
  58. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  59. package/dist/phaser/core/stage.d.ts +3 -2
  60. package/dist/phaser/core/stage.d.ts.map +1 -1
  61. package/dist/phaser/core/time.d.ts +1 -1
  62. package/dist/phaser/core/time.d.ts.map +1 -1
  63. package/dist/phaser/core/timer.d.ts +1 -1
  64. package/dist/phaser/core/timer.d.ts.map +1 -1
  65. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  66. package/dist/phaser/core/tween.d.ts +10 -7
  67. package/dist/phaser/core/tween.d.ts.map +1 -1
  68. package/dist/phaser/core/tween_data.d.ts +3 -2
  69. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  70. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  71. package/dist/phaser/core/tween_manager.d.ts +3 -2
  72. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  73. package/dist/phaser/core/world.d.ts +3 -2
  74. package/dist/phaser/core/world.d.ts.map +1 -1
  75. package/dist/phaser/display/bitmap_text.d.ts +3 -2
  76. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  77. package/dist/phaser/display/button.d.ts +3 -2
  78. package/dist/phaser/display/button.d.ts.map +1 -1
  79. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  80. package/dist/phaser/display/canvas/graphics.d.ts +7 -6
  81. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  82. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  83. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  84. package/dist/phaser/display/canvas/renderer.d.ts +10 -8
  85. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  86. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  87. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  88. package/dist/phaser/display/canvas/util.d.ts +2 -2
  89. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  90. package/dist/phaser/display/display_object.d.ts +14 -12
  91. package/dist/phaser/display/display_object.d.ts.map +1 -1
  92. package/dist/phaser/display/graphics.d.ts +8 -5
  93. package/dist/phaser/display/graphics.d.ts.map +1 -1
  94. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  95. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  96. package/dist/phaser/display/group.d.ts +4 -3
  97. package/dist/phaser/display/group.d.ts.map +1 -1
  98. package/dist/phaser/display/image.d.ts +13 -10
  99. package/dist/phaser/display/image.d.ts.map +1 -1
  100. package/dist/phaser/display/sprite_batch.d.ts +3 -2
  101. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  102. package/dist/phaser/display/sprite_util.d.ts +18 -15
  103. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  104. package/dist/phaser/display/text.d.ts +11 -9
  105. package/dist/phaser/display/text.d.ts.map +1 -1
  106. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
  109. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  110. package/dist/phaser/display/webgl/earcut.d.ts +1 -1
  111. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  112. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
  114. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  115. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  116. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  117. package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
  118. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  119. package/dist/phaser/display/webgl/graphics.d.ts +7 -6
  120. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  121. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  122. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  123. package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
  124. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  125. package/dist/phaser/display/webgl/renderer.d.ts +16 -11
  126. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  127. package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
  128. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  129. package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
  130. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  131. package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
  132. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  133. package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
  134. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  135. package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
  136. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  137. package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
  138. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  139. package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
  140. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  141. package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
  142. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  143. package/dist/phaser/display/webgl/texture.d.ts +3 -2
  144. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  145. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  147. package/dist/phaser/geom/circle.d.ts +4 -1
  148. package/dist/phaser/geom/circle.d.ts.map +1 -1
  149. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  150. package/dist/phaser/geom/line.d.ts +1 -1
  151. package/dist/phaser/geom/line.d.ts.map +1 -1
  152. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  153. package/dist/phaser/geom/point.d.ts.map +1 -1
  154. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  155. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  156. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  157. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/ellipse.d.ts +3 -2
  159. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  160. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  161. package/dist/phaser/geom/util/matrix.d.ts +2 -2
  162. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  163. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  164. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  165. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  166. package/dist/phaser/util/math.d.ts.map +1 -1
  167. package/package.json +5 -5
  168. package/src/phaser/core/animation.ts +64 -60
  169. package/src/phaser/core/animation_manager.ts +50 -53
  170. package/src/phaser/core/animation_parser.ts +9 -9
  171. package/src/phaser/core/array_set.ts +16 -17
  172. package/src/phaser/core/cache.ts +92 -93
  173. package/src/phaser/core/const.ts +1 -1
  174. package/src/phaser/core/device.ts +24 -29
  175. package/src/phaser/core/device_util.ts +22 -26
  176. package/src/phaser/core/dom.ts +54 -65
  177. package/src/phaser/core/event_manager.ts +64 -94
  178. package/src/phaser/core/factory.ts +14 -14
  179. package/src/phaser/core/frame.ts +28 -28
  180. package/src/phaser/core/frame_data.test.ts +100 -0
  181. package/src/phaser/core/frame_data.ts +24 -24
  182. package/src/phaser/core/frame_util.ts +2 -2
  183. package/src/phaser/core/game.ts +47 -48
  184. package/src/phaser/core/input.ts +104 -110
  185. package/src/phaser/core/input_handler.test.ts +113 -0
  186. package/src/phaser/core/input_handler.ts +199 -218
  187. package/src/phaser/core/input_mouse.ts +71 -54
  188. package/src/phaser/core/input_mspointer.ts +52 -39
  189. package/src/phaser/core/input_pointer.ts +81 -80
  190. package/src/phaser/core/input_touch.ts +49 -36
  191. package/src/phaser/core/loader.ts +173 -152
  192. package/src/phaser/core/loader_parser.ts +39 -57
  193. package/src/phaser/core/raf.ts +8 -7
  194. package/src/phaser/core/registry.test.ts +31 -0
  195. package/src/phaser/core/registry.ts +9 -0
  196. package/src/phaser/core/scale_manager.ts +156 -152
  197. package/src/phaser/core/scene.ts +9 -13
  198. package/src/phaser/core/scene_manager.ts +47 -47
  199. package/src/phaser/core/signal.test.ts +4 -4
  200. package/src/phaser/core/signal.ts +41 -52
  201. package/src/phaser/core/signal_binding.ts +26 -25
  202. package/src/phaser/core/signal_dispatch.test.ts +180 -0
  203. package/src/phaser/core/sound.ts +75 -83
  204. package/src/phaser/core/sound_manager.ts +52 -51
  205. package/src/phaser/core/sound_sprite.ts +17 -16
  206. package/src/phaser/core/stage.ts +25 -24
  207. package/src/phaser/core/time.ts +52 -52
  208. package/src/phaser/core/timer.test.ts +187 -0
  209. package/src/phaser/core/timer.ts +82 -69
  210. package/src/phaser/core/timer_event.ts +10 -10
  211. package/src/phaser/core/tween.ts +90 -93
  212. package/src/phaser/core/tween_data.ts +45 -51
  213. package/src/phaser/core/tween_easing.test.ts +106 -0
  214. package/src/phaser/core/tween_easing.ts +151 -123
  215. package/src/phaser/core/tween_manager.ts +19 -18
  216. package/src/phaser/core/world.ts +4 -3
  217. package/src/phaser/display/bitmap_text.ts +56 -64
  218. package/src/phaser/display/button.ts +33 -32
  219. package/src/phaser/display/canvas/buffer.ts +8 -8
  220. package/src/phaser/display/canvas/graphics.ts +36 -37
  221. package/src/phaser/display/canvas/masker.ts +2 -2
  222. package/src/phaser/display/canvas/pool.test.ts +106 -0
  223. package/src/phaser/display/canvas/pool.ts +25 -27
  224. package/src/phaser/display/canvas/renderer.ts +32 -31
  225. package/src/phaser/display/canvas/tinter.ts +25 -25
  226. package/src/phaser/display/canvas/util.ts +7 -10
  227. package/src/phaser/display/display_object.ts +114 -118
  228. package/src/phaser/display/graphics.ts +121 -119
  229. package/src/phaser/display/graphics_data.ts +12 -12
  230. package/src/phaser/display/graphics_data_util.ts +2 -3
  231. package/src/phaser/display/group.ts +50 -57
  232. package/src/phaser/display/image.ts +55 -52
  233. package/src/phaser/display/sprite_batch.ts +3 -2
  234. package/src/phaser/display/sprite_util.ts +48 -54
  235. package/src/phaser/display/text.ts +199 -204
  236. package/src/phaser/display/webgl/abstract_filter.ts +9 -9
  237. package/src/phaser/display/webgl/base_texture.ts +21 -24
  238. package/src/phaser/display/webgl/blend_manager.ts +6 -10
  239. package/src/phaser/display/webgl/earcut.ts +73 -37
  240. package/src/phaser/display/webgl/earcut_node.ts +10 -10
  241. package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
  242. package/src/phaser/display/webgl/filter_manager.ts +13 -12
  243. package/src/phaser/display/webgl/filter_texture.ts +14 -13
  244. package/src/phaser/display/webgl/graphics.ts +51 -57
  245. package/src/phaser/display/webgl/graphics_data.ts +15 -14
  246. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  247. package/src/phaser/display/webgl/render_texture.ts +26 -25
  248. package/src/phaser/display/webgl/renderer.ts +57 -62
  249. package/src/phaser/display/webgl/shader/complex.ts +28 -12
  250. package/src/phaser/display/webgl/shader/fast.ts +30 -12
  251. package/src/phaser/display/webgl/shader/normal.ts +70 -57
  252. package/src/phaser/display/webgl/shader/primitive.ts +26 -11
  253. package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
  254. package/src/phaser/display/webgl/shader/strip.ts +27 -12
  255. package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
  256. package/src/phaser/display/webgl/shader_manager.ts +26 -34
  257. package/src/phaser/display/webgl/sprite_batch.ts +67 -61
  258. package/src/phaser/display/webgl/stencil_manager.ts +23 -34
  259. package/src/phaser/display/webgl/texture.ts +43 -50
  260. package/src/phaser/display/webgl/texture_util.ts +2 -3
  261. package/src/phaser/display/webgl/util.ts +26 -25
  262. package/src/phaser/geom/circle.test.ts +2 -3
  263. package/src/phaser/geom/circle.ts +36 -36
  264. package/src/phaser/geom/ellipse.test.ts +73 -71
  265. package/src/phaser/geom/ellipse.ts +14 -14
  266. package/src/phaser/geom/line.test.ts +5 -5
  267. package/src/phaser/geom/line.ts +35 -35
  268. package/src/phaser/geom/matrix.test.ts +1 -1
  269. package/src/phaser/geom/matrix.ts +27 -27
  270. package/src/phaser/geom/point.test.ts +1 -2
  271. package/src/phaser/geom/point.ts +35 -35
  272. package/src/phaser/geom/polygon.test.ts +82 -0
  273. package/src/phaser/geom/polygon.ts +16 -16
  274. package/src/phaser/geom/rectangle.test.ts +14 -14
  275. package/src/phaser/geom/rectangle.ts +83 -75
  276. package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
  277. package/src/phaser/geom/rounded_rectangle.ts +9 -9
  278. package/src/phaser/geom/util/circle.test.ts +25 -23
  279. package/src/phaser/geom/util/circle.ts +9 -18
  280. package/src/phaser/geom/util/ellipse.test.ts +7 -5
  281. package/src/phaser/geom/util/ellipse.ts +3 -2
  282. package/src/phaser/geom/util/line.test.ts +10 -8
  283. package/src/phaser/geom/util/line.ts +6 -16
  284. package/src/phaser/geom/util/matrix.test.ts +20 -18
  285. package/src/phaser/geom/util/matrix.ts +8 -15
  286. package/src/phaser/geom/util/point.test.ts +8 -6
  287. package/src/phaser/geom/util/point.ts +24 -28
  288. package/src/phaser/geom/util/polygon.test.ts +12 -10
  289. package/src/phaser/geom/util/polygon.ts +2 -2
  290. package/src/phaser/geom/util/rectangle.test.ts +10 -8
  291. package/src/phaser/geom/util/rectangle.ts +18 -37
  292. package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
  293. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
  294. package/src/phaser/util/math.test.ts +11 -11
  295. package/src/phaser/util/math.ts +29 -46
@@ -25,11 +25,11 @@ import {
25
25
  } from '../core/const.js';
26
26
 
27
27
  export class Rectangle {
28
- x: number;
29
- y: number;
30
- width: number;
31
- height: number;
32
- type: number;
28
+ public x: number;
29
+ public y: number;
30
+ public width: number;
31
+ public height: number;
32
+ public type: number;
33
33
 
34
34
  /**
35
35
  * Creates a new Rectangle instance.
@@ -38,7 +38,7 @@ export class Rectangle {
38
38
  * @param {number} width - The width of the rectangle (default: 0).
39
39
  * @param {number} height - The height of the rectangle (default: 0).
40
40
  */
41
- constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
41
+ public constructor(x = 0, y = 0, width = 0, height = 0) {
42
42
  /** @type {number} */
43
43
  this.x = x;
44
44
  /** @type {number} */
@@ -57,7 +57,7 @@ export class Rectangle {
57
57
  * @param {number} dy - The amount to offset the y coordinate by.
58
58
  * @returns {Rectangle} This rectangle instance for chaining.
59
59
  */
60
- offset(dx: number, dy: number) {
60
+ public offset(dx: number, dy: number) {
61
61
  this.x += dx;
62
62
  this.y += dy;
63
63
  return this;
@@ -68,7 +68,7 @@ export class Rectangle {
68
68
  * @param {Point} point - The point to offset the rectangle by.
69
69
  * @returns {Rectangle} This rectangle instance for chaining.
70
70
  */
71
- offsetPoint(point: Point) {
71
+ public offsetPoint(point: Point) {
72
72
  return this.offset(point.x, point.y);
73
73
  }
74
74
 
@@ -80,7 +80,7 @@ export class Rectangle {
80
80
  * @param {number} height - The new height of the rectangle.
81
81
  * @returns {Rectangle} This rectangle instance for chaining.
82
82
  */
83
- setTo(x: number, y: number, width: number, height: number) {
83
+ public setTo(x: number, y: number, width: number, height: number) {
84
84
  this.x = x;
85
85
  this.y = y;
86
86
  this.width = width;
@@ -94,10 +94,8 @@ export class Rectangle {
94
94
  * @param {number} y - The amount to scale the height by (default: x).
95
95
  * @returns {Rectangle} This rectangle instance for chaining.
96
96
  */
97
- scale(x: number, y?: number) {
98
- if (y === undefined) {
99
- y = x;
100
- }
97
+ public scale(x: number, y?: number) {
98
+ y ??= x;
101
99
  this.width *= x;
102
100
  this.height *= y;
103
101
  return this;
@@ -109,7 +107,7 @@ export class Rectangle {
109
107
  * @param {number} y - The y coordinate to center the rectangle on.
110
108
  * @returns {Rectangle} This rectangle instance for chaining.
111
109
  */
112
- centerOn(x: number, y: number) {
110
+ public centerOn(x: number, y: number) {
113
111
  this.centerX = x;
114
112
  this.centerY = y;
115
113
  return this;
@@ -118,7 +116,7 @@ export class Rectangle {
118
116
  /**
119
117
  * Floors the x and y coordinates of the rectangle (rounds down to nearest integer).
120
118
  */
121
- floor() {
119
+ public floor() {
122
120
  this.x = Math.floor(this.x);
123
121
  this.y = Math.floor(this.y);
124
122
  }
@@ -126,7 +124,7 @@ export class Rectangle {
126
124
  /**
127
125
  * Floors all coordinates of the rectangle (rounds down to nearest integer).
128
126
  */
129
- floorAll() {
127
+ public floorAll() {
130
128
  this.x = Math.floor(this.x);
131
129
  this.y = Math.floor(this.y);
132
130
  this.width = Math.floor(this.width);
@@ -136,7 +134,7 @@ export class Rectangle {
136
134
  /**
137
135
  * Ceils the x and y coordinates of the rectangle (rounds up to nearest integer).
138
136
  */
139
- ceil() {
137
+ public ceil() {
140
138
  this.x = Math.ceil(this.x);
141
139
  this.y = Math.ceil(this.y);
142
140
  }
@@ -144,7 +142,7 @@ export class Rectangle {
144
142
  /**
145
143
  * Ceils all coordinates of the rectangle (rounds up to nearest integer).
146
144
  */
147
- ceilAll() {
145
+ public ceilAll() {
148
146
  this.x = Math.ceil(this.x);
149
147
  this.y = Math.ceil(this.y);
150
148
  this.width = Math.ceil(this.width);
@@ -156,7 +154,7 @@ export class Rectangle {
156
154
  * @param {Rectangle} source - The rectangle to copy values from.
157
155
  * @returns {Rectangle} This rectangle instance for chaining.
158
156
  */
159
- copyFrom(source: Rectangle) {
157
+ public copyFrom(source: Rectangle) {
160
158
  return this.setTo(source.x, source.y, source.width, source.height);
161
159
  }
162
160
 
@@ -165,7 +163,7 @@ export class Rectangle {
165
163
  * @param {Rectangle} dest - The rectangle to copy values to.
166
164
  * @returns {Rectangle} The destination rectangle.
167
165
  */
168
- copyTo(dest: Rectangle) {
166
+ public copyTo(dest: Rectangle) {
169
167
  dest.x = this.x;
170
168
  dest.y = this.y;
171
169
  dest.width = this.width;
@@ -179,7 +177,7 @@ export class Rectangle {
179
177
  * @param {number} dy - The amount to increase the height by.
180
178
  * @returns {Rectangle} This rectangle instance for chaining.
181
179
  */
182
- inflate(dx: number, dy: number) {
180
+ public inflate(dx: number, dy: number) {
183
181
  return inflate(this, dx, dy);
184
182
  }
185
183
 
@@ -188,7 +186,7 @@ export class Rectangle {
188
186
  * @param {Point} output - The point to store the size in (optional).
189
187
  * @returns {Point} The size of the rectangle as a point.
190
188
  */
191
- size(output: Point) {
189
+ public size(output: Point) {
192
190
  return size(this, output);
193
191
  }
194
192
 
@@ -198,7 +196,7 @@ export class Rectangle {
198
196
  * @param {number} height - The new height of the rectangle.
199
197
  * @returns {Rectangle} This rectangle instance for chaining.
200
198
  */
201
- resize(width: number, height: number) {
199
+ public resize(width: number, height: number) {
202
200
  this.width = width;
203
201
  this.height = height;
204
202
  return this;
@@ -209,7 +207,7 @@ export class Rectangle {
209
207
  * @param {Rectangle} output - The rectangle to store the clone in (optional).
210
208
  * @returns {Rectangle} A new rectangle with the same values as this one.
211
209
  */
212
- clone(output?: Rectangle) {
210
+ public clone(output?: Rectangle) {
213
211
  return clone(this, output);
214
212
  }
215
213
 
@@ -219,7 +217,7 @@ export class Rectangle {
219
217
  * @param {number} y - The y coordinate of the point to check.
220
218
  * @returns {boolean} True if the point is contained within this rectangle, false otherwise.
221
219
  */
222
- contains(x: number, y: number) {
220
+ public contains(x: number, y: number) {
223
221
  return contains(this, x, y);
224
222
  }
225
223
 
@@ -228,7 +226,7 @@ export class Rectangle {
228
226
  * @param {Rectangle} b - The rectangle to check if it's contained.
229
227
  * @returns {boolean} True if the rectangle is contained within this rectangle, false otherwise.
230
228
  */
231
- containsRect(b: Rectangle) {
229
+ public containsRect(b: Rectangle) {
232
230
  return containsRect(b, this);
233
231
  }
234
232
 
@@ -237,7 +235,7 @@ export class Rectangle {
237
235
  * @param {Rectangle} b - The rectangle to compare with.
238
236
  * @returns {boolean} True if the rectangles have the same values, false otherwise.
239
237
  */
240
- equals(b: Rectangle) {
238
+ public equals(b: Rectangle) {
241
239
  return equals(this, b);
242
240
  }
243
241
 
@@ -247,7 +245,7 @@ export class Rectangle {
247
245
  * @param {Rectangle} out - The rectangle to store the result in (optional).
248
246
  * @returns {Rectangle} The intersection of the two rectangles.
249
247
  */
250
- intersection(b: Rectangle, out?: Rectangle) {
248
+ public intersection(b: Rectangle, out?: Rectangle) {
251
249
  return intersection(this, b, out);
252
250
  }
253
251
 
@@ -256,7 +254,7 @@ export class Rectangle {
256
254
  * @param {Rectangle} b - The rectangle to check for intersection with.
257
255
  * @returns {boolean} True if the rectangles intersect, false otherwise.
258
256
  */
259
- intersects(b: Rectangle) {
257
+ public intersects(b: Rectangle) {
260
258
  return intersects(this, b);
261
259
  }
262
260
 
@@ -269,7 +267,7 @@ export class Rectangle {
269
267
  * @param {number} tolerance - A tolerance value to use when checking (default: 0).
270
268
  * @returns {boolean} True if the rectangle intersects with the bounds, false otherwise.
271
269
  */
272
- intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number) {
270
+ public intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number) {
273
271
  return intersectsRaw(this, left, right, top, bottom, tolerance);
274
272
  }
275
273
 
@@ -279,7 +277,7 @@ export class Rectangle {
279
277
  * @param {Rectangle} out - The rectangle to store the result in (optional).
280
278
  * @returns {Rectangle} The union of the two rectangles.
281
279
  */
282
- union(b: Rectangle, out?: Rectangle) {
280
+ public union(b: Rectangle, out?: Rectangle) {
283
281
  return union(this, b, out);
284
282
  }
285
283
 
@@ -288,8 +286,8 @@ export class Rectangle {
288
286
  * @param {Point} output - The point to store the result in (optional).
289
287
  * @returns {Point} A random point within this rectangle.
290
288
  */
291
- random(output: Point | null = null) {
292
- const result = output || new Point();
289
+ public random(output: Point | null = null) {
290
+ const result = output ?? new Point();
293
291
  result.x = this.randomX;
294
292
  result.y = this.randomY;
295
293
  return result;
@@ -301,29 +299,39 @@ export class Rectangle {
301
299
  * @param {Point} output - The point to store the result in (optional).
302
300
  * @returns {Point} A point at the specified position on the rectangle.
303
301
  */
304
- getPoint(position: number, output: Point | null = null) {
305
- const result = output || new Point();
302
+ public getPoint(position: number, output: Point | null = null) {
303
+ const result = output ?? new Point();
306
304
  switch (position) {
307
- case TOP_LEFT:
305
+ case TOP_LEFT: {
308
306
  return result.setTo(this.x, this.y);
309
- case TOP_CENTER:
307
+ }
308
+ case TOP_CENTER: {
310
309
  return result.setTo(this.centerX, this.y);
311
- case TOP_RIGHT:
310
+ }
311
+ case TOP_RIGHT: {
312
312
  return result.setTo(this.right, this.y);
313
- case LEFT_CENTER:
313
+ }
314
+ case LEFT_CENTER: {
314
315
  return result.setTo(this.x, this.centerY);
315
- case CENTER:
316
+ }
317
+ case CENTER: {
316
318
  return result.setTo(this.centerX, this.centerY);
317
- case RIGHT_CENTER:
319
+ }
320
+ case RIGHT_CENTER: {
318
321
  return result.setTo(this.right, this.centerY);
319
- case BOTTOM_LEFT:
322
+ }
323
+ case BOTTOM_LEFT: {
320
324
  return result.setTo(this.x, this.bottom);
321
- case BOTTOM_CENTER:
325
+ }
326
+ case BOTTOM_CENTER: {
322
327
  return result.setTo(this.centerX, this.bottom);
323
- case BOTTOM_RIGHT:
328
+ }
329
+ case BOTTOM_RIGHT: {
324
330
  return result.setTo(this.right, this.bottom);
325
- default:
331
+ }
332
+ default: {
326
333
  return result.setTo(this.x, this.y);
334
+ }
327
335
  }
328
336
  }
329
337
 
@@ -331,7 +339,7 @@ export class Rectangle {
331
339
  * Returns a string representation of this rectangle.
332
340
  * @returns {string} A string representation of the rectangle.
333
341
  */
334
- toString() {
342
+ public toString() {
335
343
  return `[{Rectangle (x=${this.x} y=${this.y} width=${this.width} height=${this.height} empty=${this.empty})}]`;
336
344
  }
337
345
 
@@ -339,7 +347,7 @@ export class Rectangle {
339
347
  * Gets half the width of this rectangle.
340
348
  * @returns {number} Half the width of this rectangle.
341
349
  */
342
- get halfWidth() {
350
+ public get halfWidth() {
343
351
  return Math.round(this.width / 2);
344
352
  }
345
353
 
@@ -347,7 +355,7 @@ export class Rectangle {
347
355
  * Gets half the height of this rectangle.
348
356
  * @returns {number} Half the height of this rectangle.
349
357
  */
350
- get halfHeight() {
358
+ public get halfHeight() {
351
359
  return Math.round(this.height / 2);
352
360
  }
353
361
 
@@ -355,14 +363,14 @@ export class Rectangle {
355
363
  * Gets the top coordinate of this rectangle.
356
364
  * @returns {number} The top coordinate of this rectangle.
357
365
  */
358
- get top() {
366
+ public get top() {
359
367
  return this.y;
360
368
  }
361
369
 
362
370
  /**
363
371
  * Sets the top coordinate of this rectangle.
364
372
  */
365
- set top(value) {
373
+ public set top(value) {
366
374
  if (value >= this.bottom) {
367
375
  this.height = 0;
368
376
  this.y = value;
@@ -375,14 +383,14 @@ export class Rectangle {
375
383
  * Gets the top-left point of this rectangle.
376
384
  * @returns {Point} The top-left point of this rectangle.
377
385
  */
378
- get topLeft() {
386
+ public get topLeft() {
379
387
  return new Point(this.x, this.y);
380
388
  }
381
389
 
382
390
  /**
383
391
  * Sets the top-left point of this rectangle.
384
392
  */
385
- set topLeft(value) {
393
+ public set topLeft(value) {
386
394
  this.x = value.x;
387
395
  this.y = value.y;
388
396
  }
@@ -391,14 +399,14 @@ export class Rectangle {
391
399
  * Gets the top-right point of this rectangle.
392
400
  * @returns {Point} The top-right point of this rectangle.
393
401
  */
394
- get topRight() {
402
+ public get topRight() {
395
403
  return new Point(this.x + this.width, this.y);
396
404
  }
397
405
 
398
406
  /**
399
407
  * Sets the top-right point of this rectangle.
400
408
  */
401
- set topRight(value) {
409
+ public set topRight(value) {
402
410
  this.right = value.x;
403
411
  this.y = value.y;
404
412
  }
@@ -407,14 +415,14 @@ export class Rectangle {
407
415
  * Gets the bottom coordinate of this rectangle.
408
416
  * @returns {number} The bottom coordinate of this rectangle.
409
417
  */
410
- get bottom() {
418
+ public get bottom() {
411
419
  return this.y + this.height;
412
420
  }
413
421
 
414
422
  /**
415
423
  * Sets the bottom coordinate of this rectangle.
416
424
  */
417
- set bottom(value) {
425
+ public set bottom(value) {
418
426
  if (value <= this.y) {
419
427
  this.height = 0;
420
428
  } else {
@@ -426,14 +434,14 @@ export class Rectangle {
426
434
  * Gets the bottom-left point of this rectangle.
427
435
  * @returns {Point} The bottom-left point of this rectangle.
428
436
  */
429
- get bottomLeft() {
437
+ public get bottomLeft() {
430
438
  return new Point(this.x, this.bottom);
431
439
  }
432
440
 
433
441
  /**
434
442
  * Sets the bottom-left point of this rectangle.
435
443
  */
436
- set bottomLeft(value) {
444
+ public set bottomLeft(value) {
437
445
  this.x = value.x;
438
446
  this.bottom = value.y;
439
447
  }
@@ -442,14 +450,14 @@ export class Rectangle {
442
450
  * Gets the bottom-right point of this rectangle.
443
451
  * @returns {Point} The bottom-right point of this rectangle.
444
452
  */
445
- get bottomRight() {
453
+ public get bottomRight() {
446
454
  return new Point(this.right, this.bottom);
447
455
  }
448
456
 
449
457
  /**
450
458
  * Sets the bottom-right point of this rectangle.
451
459
  */
452
- set bottomRight(value) {
460
+ public set bottomRight(value) {
453
461
  this.right = value.x;
454
462
  this.bottom = value.y;
455
463
  }
@@ -458,14 +466,14 @@ export class Rectangle {
458
466
  * Gets the left coordinate of this rectangle.
459
467
  * @returns {number} The left coordinate of this rectangle.
460
468
  */
461
- get left() {
469
+ public get left() {
462
470
  return this.x;
463
471
  }
464
472
 
465
473
  /**
466
474
  * Sets the left coordinate of this rectangle.
467
475
  */
468
- set left(value) {
476
+ public set left(value) {
469
477
  if (value >= this.right) {
470
478
  this.width = 0;
471
479
  } else {
@@ -478,14 +486,14 @@ export class Rectangle {
478
486
  * Gets the right coordinate of this rectangle.
479
487
  * @returns {number} The right coordinate of this rectangle.
480
488
  */
481
- get right() {
489
+ public get right() {
482
490
  return this.x + this.width;
483
491
  }
484
492
 
485
493
  /**
486
494
  * Sets the right coordinate of this rectangle.
487
495
  */
488
- set right(value) {
496
+ public set right(value) {
489
497
  if (value <= this.x) {
490
498
  this.width = 0;
491
499
  } else {
@@ -497,7 +505,7 @@ export class Rectangle {
497
505
  * Gets the volume (area) of this rectangle.
498
506
  * @returns {number} The volume (area) of this rectangle.
499
507
  */
500
- get volume() {
508
+ public get volume() {
501
509
  return this.width * this.height;
502
510
  }
503
511
 
@@ -505,7 +513,7 @@ export class Rectangle {
505
513
  * Gets the perimeter of this rectangle.
506
514
  * @returns {number} The perimeter of this rectangle.
507
515
  */
508
- get perimeter() {
516
+ public get perimeter() {
509
517
  return this.width * 2 + this.height * 2;
510
518
  }
511
519
 
@@ -513,14 +521,14 @@ export class Rectangle {
513
521
  * Gets the x coordinate of the center of this rectangle.
514
522
  * @returns {number} The x coordinate of the center of this rectangle.
515
523
  */
516
- get centerX() {
524
+ public get centerX() {
517
525
  return this.x + this.halfWidth;
518
526
  }
519
527
 
520
528
  /**
521
529
  * Sets the x coordinate of the center of this rectangle.
522
530
  */
523
- set centerX(value) {
531
+ public set centerX(value) {
524
532
  this.x = value - this.halfWidth;
525
533
  }
526
534
 
@@ -528,14 +536,14 @@ export class Rectangle {
528
536
  * Gets the y coordinate of the center of this rectangle.
529
537
  * @returns {number} The y coordinate of the center of this rectangle.
530
538
  */
531
- get centerY() {
539
+ public get centerY() {
532
540
  return this.y + this.halfHeight;
533
541
  }
534
542
 
535
543
  /**
536
544
  * Sets the y coordinate of the center of this rectangle.
537
545
  */
538
- set centerY(value) {
546
+ public set centerY(value) {
539
547
  this.y = value - this.halfHeight;
540
548
  }
541
549
 
@@ -543,7 +551,7 @@ export class Rectangle {
543
551
  * Gets a random x coordinate within this rectangle.
544
552
  * @returns {number} A random x coordinate within this rectangle.
545
553
  */
546
- get randomX() {
554
+ public get randomX() {
547
555
  return this.x + Math.random() * this.width;
548
556
  }
549
557
 
@@ -551,7 +559,7 @@ export class Rectangle {
551
559
  * Gets a random y coordinate within this rectangle.
552
560
  * @returns {number} A random y coordinate within this rectangle.
553
561
  */
554
- get randomY() {
562
+ public get randomY() {
555
563
  return this.y + Math.random() * this.height;
556
564
  }
557
565
 
@@ -559,15 +567,15 @@ export class Rectangle {
559
567
  * Checks if this rectangle is empty (has zero width or height).
560
568
  * @returns {boolean} True if the rectangle is empty, false otherwise.
561
569
  */
562
- get empty() {
570
+ public get empty() {
563
571
  return !this.width || !this.height;
564
572
  }
565
573
 
566
574
  /**
567
575
  * Sets whether this rectangle is empty (zero width or height).
568
576
  */
569
- set empty(value) {
570
- if (value === true) {
577
+ public set empty(value) {
578
+ if (value) {
571
579
  this.setTo(0, 0, 0, 0);
572
580
  }
573
581
  }
@@ -1,4 +1,4 @@
1
- import { expect } from 'vitest';
1
+ import { expect, describe, it } from 'vitest';
2
2
  import { RoundedRectangle } from './rounded_rectangle.js';
3
3
 
4
4
  describe('RoundedRectangle Constructor', () => {
@@ -20,16 +20,12 @@ describe('RoundedRectangle contains Method', () => {
20
20
  const rectangle2 = new RoundedRectangle(10, 20, 30, 0, 5);
21
21
  expect(rectangle2.contains(15, 25)).toBe(false);
22
22
  });
23
- });
24
23
 
25
- describe('RoundedRectangle contains Method', () => {
26
24
  it('should return true for a point inside the rectangle', () => {
27
25
  const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
28
26
  expect(rectangle.contains(15, 25)).toBe(true);
29
27
  });
30
- });
31
28
 
32
- describe('RoundedRectangle contains Method', () => {
33
29
  it("should return true for a point on the rectangle's edge", () => {
34
30
  const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
35
31
  expect(rectangle.contains(0, 25)).toBe(false);
@@ -37,9 +33,7 @@ describe('RoundedRectangle contains Method', () => {
37
33
  expect(rectangle.contains(15, 0)).toBe(false);
38
34
  expect(rectangle.contains(15, 40)).toBe(true);
39
35
  });
40
- });
41
36
 
42
- describe('RoundedRectangle contains Method', () => {
43
37
  it('should return false for a point outside the rectangle', () => {
44
38
  const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
45
39
  expect(rectangle.contains(-1, -1)).toBe(false);
@@ -2,12 +2,12 @@ import { clone } from './util/rounded_rectangle.js';
2
2
  import { GEOM_ROUNDED_RECTANGLE } from '../core/const.js';
3
3
 
4
4
  export class RoundedRectangle {
5
- x: number;
6
- y: number;
7
- width: number;
8
- height: number;
9
- radius: number;
10
- type: number;
5
+ public x: number;
6
+ public y: number;
7
+ public width: number;
8
+ public height: number;
9
+ public radius: number;
10
+ public type: number;
11
11
 
12
12
  /**
13
13
  * Creates a new RoundedRectangle instance.
@@ -17,7 +17,7 @@ export class RoundedRectangle {
17
17
  * @param {number} height - The height of the rectangle (default: 0).
18
18
  * @param {number} radius - The corner radius (default: 20).
19
19
  */
20
- constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0, radius: number = 20) {
20
+ public constructor(x = 0, y = 0, width = 0, height = 0, radius = 20) {
21
21
  this.x = x;
22
22
  this.y = y;
23
23
  this.width = width;
@@ -32,7 +32,7 @@ export class RoundedRectangle {
32
32
  * @param {number} y - The y coordinate of the point to check.
33
33
  * @returns {boolean} True if the point is contained within this rounded rectangle, false otherwise.
34
34
  */
35
- contains(x: number, y: number) {
35
+ public contains(x: number, y: number) {
36
36
  if (this.width <= 0 || this.height <= 0) {
37
37
  return false;
38
38
  }
@@ -48,7 +48,7 @@ export class RoundedRectangle {
48
48
  * Creates a clone of this rounded rectangle.
49
49
  * @returns {RoundedRectangle} A new rounded rectangle with the same values as this one.
50
50
  */
51
- clone() {
51
+ public clone() {
52
52
  return clone(this);
53
53
  }
54
54
  }
@@ -1,30 +1,32 @@
1
- import { expect } from 'vitest';
1
+ 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
- it('should clone a circle', () => {
6
- const circle1 = new Circle(0, 0, 10);
7
- const circle2 = clone(circle1);
8
- expect(circle1.x).toBe(circle2.x);
9
- expect(circle1.y).toBe(circle2.y);
10
- expect(circle1.radius).toBe(circle2.radius);
11
- });
5
+ describe('circle utils', () => {
6
+ it('should clone a circle', () => {
7
+ const circle1 = new Circle(0, 0, 10);
8
+ const circle2 = clone(circle1);
9
+ expect(circle1.x).toBe(circle2.x);
10
+ expect(circle1.y).toBe(circle2.y);
11
+ expect(circle1.radius).toBe(circle2.radius);
12
+ });
12
13
 
13
- it('should contain a point in a circle', () => {
14
- const circle = new Circle(5, 5, 10);
15
- expect(contains(circle, 5, 5)).toBe(true);
16
- });
14
+ it('should contain a point in a circle', () => {
15
+ const circle = new Circle(5, 5, 10);
16
+ expect(contains(circle, 5, 5)).toBe(true);
17
+ });
17
18
 
18
- it('should match two circles', () => {
19
- const circle1 = new Circle(5, 5, 10);
20
- const circle2 = new Circle(5, 5, 10);
21
- expect(equals(circle1, circle2)).toBe(true);
22
- circle2.x = 0;
23
- expect(equals(circle1, circle2)).toBe(false);
24
- });
19
+ it('should match two circles', () => {
20
+ const circle1 = new Circle(5, 5, 10);
21
+ const circle2 = new Circle(5, 5, 10);
22
+ expect(equals(circle1, circle2)).toBe(true);
23
+ circle2.x = 0;
24
+ expect(equals(circle1, circle2)).toBe(false);
25
+ });
25
26
 
26
- it('should intersects two circles', () => {
27
- const circle1 = new Circle(5, 5, 10);
28
- const circle2 = new Circle(5, 5, 5);
29
- expect(intersects(circle1, circle2)).toBe(true);
27
+ it('should intersects two circles', () => {
28
+ const circle1 = new Circle(5, 5, 10);
29
+ const circle2 = new Circle(5, 5, 5);
30
+ expect(intersects(circle1, circle2)).toBe(true);
31
+ });
30
32
  });