@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
@@ -1,16 +1,16 @@
1
1
  import { create, removeByCanvas } from './pool.js';
2
2
 
3
3
  export class CanvasBuffer {
4
- width!: any;
5
- height!: any;
6
- canvas!: any;
7
- context!: any;
4
+ public width!: any;
5
+ public height!: any;
6
+ public canvas!: any;
7
+ public context!: any;
8
8
  /**
9
9
  * Creates a new CanvasBuffer instance.
10
10
  * @param {number} width - The width of the canvas buffer.
11
11
  * @param {number} height - The height of the canvas buffer.
12
12
  */
13
- constructor(width: number, height: number) {
13
+ public constructor(width: number, height: number) {
14
14
  this.width = width;
15
15
  this.height = height;
16
16
  this.canvas = create(this, this.width, this.height);
@@ -22,7 +22,7 @@ export class CanvasBuffer {
22
22
  /**
23
23
  * Clears the canvas buffer.
24
24
  */
25
- clear() {
25
+ public clear() {
26
26
  this.context.setTransform(1, 0, 0, 1, 0, 0);
27
27
  this.context.clearRect(0, 0, this.width, this.height);
28
28
  }
@@ -32,7 +32,7 @@ export class CanvasBuffer {
32
32
  * @param {number} width - The new width of the canvas buffer.
33
33
  * @param {number} height - The new height of the canvas buffer.
34
34
  */
35
- resize(width: number, height: number) {
35
+ public resize(width: number, height: number) {
36
36
  this.width = width;
37
37
  this.height = height;
38
38
  this.canvas.width = width;
@@ -42,7 +42,7 @@ export class CanvasBuffer {
42
42
  /**
43
43
  * Destroys the canvas buffer and cleans up resources.
44
44
  */
45
- destroy() {
45
+ public destroy() {
46
46
  try {
47
47
  this.context?.reset();
48
48
  } catch {
@@ -1,20 +1,20 @@
1
1
  import { GEOM_CIRCLE, GEOM_ELLIPSE, GEOM_POLYGON, GEOM_RECTANGLE, GEOM_ROUNDED_RECTANGLE } from '../../core/const.js';
2
+ import type { Graphics } from '../graphics.js';
2
3
 
3
4
  /**
4
5
  * Renders a graphics object to canvas.
5
- * @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
6
+ * @param {Graphics} graphics - The graphics object to render.
6
7
  */
7
- export const updateGraphicsTint = (graphics: import('../graphics.js').Graphics) => {
8
+ export const updateGraphicsTint = (graphics: Graphics) => {
8
9
  if (graphics.tint === 0xffffff) {
9
10
  return;
10
11
  }
11
12
  const tintR = ((graphics.tint >> 16) & 0xff) / 255;
12
13
  const tintG = ((graphics.tint >> 8) & 0xff) / 255;
13
14
  const tintB = (graphics.tint & 0xff) / 255;
14
- for (let i = 0; i < graphics.graphicsData.length; i += 1) {
15
- const data = graphics.graphicsData[i];
16
- const fillColor = data.fillColor | 0;
17
- const lineColor = data.lineColor | 0;
15
+ for (const data of graphics.graphicsData) {
16
+ const fillColor = Math.trunc(data.fillColor);
17
+ const lineColor = Math.trunc(data.lineColor);
18
18
  data._fillTint =
19
19
  (((((fillColor >> 16) & 0xff) / 255) * tintR * 255) << 16) +
20
20
  (((((fillColor >> 8) & 0xff) / 255) * tintG * 255) << 8) +
@@ -28,24 +28,23 @@ export const updateGraphicsTint = (graphics: import('../graphics.js').Graphics)
28
28
 
29
29
  /**
30
30
  * Renders a graphics object to canvas.
31
- * @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
31
+ * @param {Graphics} graphics - The graphics object to render.
32
32
  * @param {object} context - The canvas rendering context.
33
33
  */
34
- export const renderGraphics = (graphics: import('../graphics.js').Graphics, context: any) => {
35
- const worldAlpha = graphics.worldAlpha;
34
+ export const renderGraphics = (graphics: Graphics, context: any) => {
35
+ const { worldAlpha } = graphics;
36
36
  if (graphics.dirty) {
37
37
  updateGraphicsTint(graphics);
38
38
  graphics.dirty = false;
39
39
  }
40
- for (let i = 0; i < graphics.graphicsData.length; i += 1) {
41
- const data = graphics.graphicsData[i];
42
- const shape = data.shape;
40
+ for (const data of graphics.graphicsData) {
41
+ const { shape } = data;
43
42
  const fillColor = data._fillTint;
44
43
  const lineColor = data._lineTint;
45
44
  context.lineWidth = data.lineWidth;
46
45
  if (data.type === GEOM_POLYGON) {
47
46
  context.beginPath();
48
- const points = shape.points;
47
+ const { points } = shape;
49
48
  context.moveTo(points[0], points[1]);
50
49
  for (let j = 1; j < points.length / 2; j += 1) {
51
50
  context.lineTo(points[j * 2], points[j * 2 + 1]);
@@ -54,28 +53,28 @@ export const renderGraphics = (graphics: import('../graphics.js').Graphics, cont
54
53
  context.lineTo(points[0], points[1]);
55
54
  }
56
55
  // if the first and last point are the same close the path - much neater :)
57
- if (points[0] === points[points.length - 2] && points[1] === points[points.length - 1]) {
56
+ if (points[0] === points.at(-2) && points[1] === points.at(-1)) {
58
57
  context.closePath();
59
58
  }
60
59
  if (data.fill) {
61
60
  context.globalAlpha = data.fillAlpha * worldAlpha;
62
- context.fillStyle = `#${`00000${(fillColor | 0).toString(16)}`.substr(-6)}`;
61
+ context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
63
62
  context.fill();
64
63
  }
65
64
  if (data.lineWidth) {
66
65
  context.globalAlpha = data.lineAlpha * worldAlpha;
67
- context.strokeStyle = `#${`00000${(lineColor | 0).toString(16)}`.substr(-6)}`;
66
+ context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
68
67
  context.stroke();
69
68
  }
70
69
  } else if (data.type === GEOM_RECTANGLE) {
71
70
  if (data.fillColor || data.fillColor === 0) {
72
71
  context.globalAlpha = data.fillAlpha * worldAlpha;
73
- context.fillStyle = `#${`00000${(fillColor | 0).toString(16)}`.substr(-6)}`;
72
+ context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
74
73
  context.fillRect(shape.x, shape.y, shape.width, shape.height);
75
74
  }
76
75
  if (data.lineWidth) {
77
76
  context.globalAlpha = data.lineAlpha * worldAlpha;
78
- context.strokeStyle = `#${`00000${(lineColor | 0).toString(16)}`.substr(-6)}`;
77
+ context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
79
78
  context.strokeRect(shape.x, shape.y, shape.width, shape.height);
80
79
  }
81
80
  } else if (data.type === GEOM_CIRCLE) {
@@ -84,12 +83,12 @@ export const renderGraphics = (graphics: import('../graphics.js').Graphics, cont
84
83
  context.closePath();
85
84
  if (data.fill) {
86
85
  context.globalAlpha = data.fillAlpha * worldAlpha;
87
- context.fillStyle = `#${`00000${(fillColor | 0).toString(16)}`.substr(-6)}`;
86
+ context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
88
87
  context.fill();
89
88
  }
90
89
  if (data.lineWidth) {
91
90
  context.globalAlpha = data.lineAlpha * worldAlpha;
92
- context.strokeStyle = `#${`00000${(lineColor | 0).toString(16)}`.substr(-6)}`;
91
+ context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
93
92
  context.stroke();
94
93
  }
95
94
  } else if (data.type === GEOM_ELLIPSE) {
@@ -114,21 +113,21 @@ export const renderGraphics = (graphics: import('../graphics.js').Graphics, cont
114
113
  context.closePath();
115
114
  if (data.fill) {
116
115
  context.globalAlpha = data.fillAlpha * worldAlpha;
117
- context.fillStyle = `#${`00000${(fillColor | 0).toString(16)}`.substr(-6)}`;
116
+ context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
118
117
  context.fill();
119
118
  }
120
119
  if (data.lineWidth) {
121
120
  context.globalAlpha = data.lineAlpha * worldAlpha;
122
- context.strokeStyle = `#${`00000${(lineColor | 0).toString(16)}`.substr(-6)}`;
121
+ context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
123
122
  context.stroke();
124
123
  }
125
124
  } else if (data.type === GEOM_ROUNDED_RECTANGLE) {
126
125
  const rx = shape.x;
127
126
  const ry = shape.y;
128
- const width = shape.width;
129
- const height = shape.height;
130
- let radius = shape.radius;
131
- const maxRadius = (Math.min(width, height) / 2) | 0;
127
+ const { width } = shape;
128
+ const { height } = shape;
129
+ let { radius } = shape;
130
+ const maxRadius = Math.trunc(Math.min(width, height) / 2);
132
131
  radius = radius > maxRadius ? maxRadius : radius;
133
132
  context.beginPath();
134
133
  context.moveTo(rx, ry + radius);
@@ -143,12 +142,12 @@ export const renderGraphics = (graphics: import('../graphics.js').Graphics, cont
143
142
  context.closePath();
144
143
  if (data.fillColor || data.fillColor === 0) {
145
144
  context.globalAlpha = data.fillAlpha * worldAlpha;
146
- context.fillStyle = `#${`00000${(fillColor | 0).toString(16)}`.substr(-6)}`;
145
+ context.fillStyle = `#${`00000${Math.trunc(fillColor).toString(16)}`.slice(-6)}`;
147
146
  context.fill();
148
147
  }
149
148
  if (data.lineWidth) {
150
149
  context.globalAlpha = data.lineAlpha * worldAlpha;
151
- context.strokeStyle = `#${`00000${(lineColor | 0).toString(16)}`.substr(-6)}`;
150
+ context.strokeStyle = `#${`00000${Math.trunc(lineColor).toString(16)}`.slice(-6)}`;
152
151
  context.stroke();
153
152
  }
154
153
  }
@@ -157,10 +156,10 @@ export const renderGraphics = (graphics: import('../graphics.js').Graphics, cont
157
156
 
158
157
  /**
159
158
  * Renders a graphics object to canvas.
160
- * @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
159
+ * @param {Graphics} graphics - The graphics object to render.
161
160
  * @param {object} context - The canvas rendering context.
162
161
  */
163
- export const renderGraphicsMask = (graphics: import('../graphics.js').Graphics, context: any) => {
162
+ export const renderGraphicsMask = (graphics: Graphics, context: any) => {
164
163
  const len = graphics.graphicsData.length;
165
164
  if (len === 0) {
166
165
  return;
@@ -168,15 +167,15 @@ export const renderGraphicsMask = (graphics: import('../graphics.js').Graphics,
168
167
  context.beginPath();
169
168
  for (let i = 0; i < len; i += 1) {
170
169
  const data = graphics.graphicsData[i];
171
- const shape = data.shape;
170
+ const { shape } = data;
172
171
  if (data.type === GEOM_POLYGON) {
173
- const points = shape.points;
172
+ const { points } = shape;
174
173
  context.moveTo(points[0], points[1]);
175
174
  for (let j = 1; j < points.length / 2; j += 1) {
176
175
  context.lineTo(points[j * 2], points[j * 2 + 1]);
177
176
  }
178
177
  // if the first and last point are the same close the path - much neater :)
179
- if (points[0] === points[points.length - 2] && points[1] === points[points.length - 1]) {
178
+ if (points[0] === points.at(-2) && points[1] === points.at(-1)) {
180
179
  context.closePath();
181
180
  }
182
181
  } else if (data.type === GEOM_RECTANGLE) {
@@ -207,10 +206,10 @@ export const renderGraphicsMask = (graphics: import('../graphics.js').Graphics,
207
206
  } else if (data.type === GEOM_ROUNDED_RECTANGLE) {
208
207
  const rx = shape.x;
209
208
  const ry = shape.y;
210
- const width = shape.width;
211
- const height = shape.height;
212
- let radius = shape.radius;
213
- const maxRadius = (Math.min(width, height) / 2) | 0;
209
+ const { width } = shape;
210
+ const { height } = shape;
211
+ let { radius } = shape;
212
+ const maxRadius = Math.trunc(Math.min(width, height) / 2);
214
213
  radius = radius > maxRadius ? maxRadius : radius;
215
214
  context.moveTo(rx, ry + radius);
216
215
  context.lineTo(rx, ry + height - radius);
@@ -6,11 +6,11 @@ import { renderGraphicsMask } from './graphics.js';
6
6
  * @param {object} renderSession - The rendering session object.
7
7
  */
8
8
  export const pushMask = (maskData: any, renderSession: any) => {
9
- const context = renderSession.context;
9
+ const { context } = renderSession;
10
10
  context.save();
11
11
  const cacheAlpha = maskData.alpha;
12
12
  const transform = maskData.worldTransform;
13
- const resolution = renderSession.resolution;
13
+ const { resolution } = renderSession;
14
14
  context.setTransform(
15
15
  transform.a * resolution,
16
16
  transform.b * resolution,
@@ -0,0 +1,106 @@
1
+ import { beforeEach, describe, expect, it } from 'vitest';
2
+ import { create, getFirst, getFree, getPool, getTotal, remove, removeByCanvas } from './pool.js';
3
+
4
+ describe('canvas pool', () => {
5
+ beforeEach(() => {
6
+ getPool().length = 0;
7
+ });
8
+
9
+ describe('getPool', () => {
10
+ it('lazily creates the backing array and returns the same one thereafter', () => {
11
+ expect(getPool()).toBe(getPool());
12
+ expect(getPool()).toStrictEqual([]);
13
+ });
14
+ });
15
+
16
+ describe('create', () => {
17
+ it('adds a new entry when the pool is empty', () => {
18
+ const parent = { name: 'owner' };
19
+ const canvas = create(parent);
20
+ expect(getPool()).toHaveLength(1);
21
+ expect(getPool()[0]?.parent).toBe(parent);
22
+ expect(getPool()[0]?.canvas).toBe(canvas);
23
+ });
24
+
25
+ it('reuses a free entry instead of growing the pool', () => {
26
+ const first = { name: 'first' };
27
+ const canvas = create(first);
28
+ remove(first);
29
+ const second = { name: 'second' };
30
+ expect(create(second)).toBe(canvas);
31
+ expect(getPool()).toHaveLength(1);
32
+ expect(getPool()[0]?.parent).toBe(second);
33
+ });
34
+
35
+ it('grows the pool when skipPool is set even if an entry is free', () => {
36
+ const first = { name: 'first' };
37
+ create(first);
38
+ remove(first);
39
+ create({ name: 'second' }, undefined, undefined, true);
40
+ expect(getPool()).toHaveLength(2);
41
+ });
42
+
43
+ it('applies the requested dimensions', () => {
44
+ const canvas = create({ name: 'sized' }, 64, 32);
45
+ expect(canvas.width).toBe(64);
46
+ expect(canvas.height).toBe(32);
47
+ });
48
+ });
49
+
50
+ describe('getFirst', () => {
51
+ it('reports -1 when every entry is claimed', () => {
52
+ create({ name: 'owner' });
53
+ expect(getFirst()).toBe(-1);
54
+ });
55
+
56
+ it('reports the index of the first free entry', () => {
57
+ create({ name: 'a' });
58
+ const b = { name: 'b' };
59
+ create(b);
60
+ create({ name: 'c' });
61
+ remove(b);
62
+ expect(getFirst()).toBe(1);
63
+ });
64
+ });
65
+
66
+ describe('remove', () => {
67
+ it('frees the entry and shrinks its canvas to 1x1', () => {
68
+ const parent = { name: 'owner' };
69
+ const canvas = create(parent, 100, 50);
70
+ remove(parent);
71
+ expect(getPool()[0]?.parent).toBeNull();
72
+ expect(canvas.width).toBe(1);
73
+ expect(canvas.height).toBe(1);
74
+ });
75
+
76
+ it('ignores a parent that owns nothing', () => {
77
+ create({ name: 'owner' });
78
+ expect(() => {
79
+ remove({ name: 'stranger' });
80
+ }).not.toThrow();
81
+ expect(getPool()[0]?.parent).not.toBeNull();
82
+ });
83
+ });
84
+
85
+ describe('removeByCanvas', () => {
86
+ it('frees the entry holding that canvas', () => {
87
+ const canvas = create({ name: 'owner' }, 100, 50);
88
+ removeByCanvas(canvas);
89
+ expect(getPool()[0]?.parent).toBeNull();
90
+ expect(canvas.width).toBe(1);
91
+ });
92
+ });
93
+
94
+ describe('getTotal and getFree', () => {
95
+ it('count claimed and unclaimed entries', () => {
96
+ const a = { name: 'a' };
97
+ create(a);
98
+ create({ name: 'b' });
99
+ expect(getTotal()).toBe(2);
100
+ expect(getFree()).toBe(0);
101
+ remove(a);
102
+ expect(getTotal()).toBe(1);
103
+ expect(getFree()).toBe(1);
104
+ });
105
+ });
106
+ });
@@ -1,15 +1,12 @@
1
+ import { getRegistry } from '../../core/registry.js';
1
2
  /**
2
3
  * Gets the canvas pool array.
3
4
  * @returns {{canvas: HTMLCanvasElement, parent: object}[]} The canvas pool array.
4
5
  */
5
- export const getPool = () => {
6
- if (!window.PhaserRegistry) {
7
- window.PhaserRegistry = {};
8
- }
9
- if (!window.PhaserRegistry.CANVAS_POOL) {
10
- window.PhaserRegistry.CANVAS_POOL = [];
11
- }
12
- return window.PhaserRegistry.CANVAS_POOL;
6
+ export const getPool = (): CanvasPoolEntry[] => {
7
+ const registry = getRegistry();
8
+ registry.CANVAS_POOL ??= [];
9
+ return registry.CANVAS_POOL;
13
10
  };
14
11
 
15
12
  /**
@@ -19,7 +16,7 @@ export const getPool = () => {
19
16
  export const getFirst = () => {
20
17
  const pool = getPool();
21
18
  for (let i = 0; i < pool.length; i += 1) {
22
- if (!pool[i].parent) {
19
+ if (!pool[i]!.parent) {
23
20
  return i;
24
21
  }
25
22
  }
@@ -32,11 +29,11 @@ export const getFirst = () => {
32
29
  */
33
30
  export const remove = (parent: any) => {
34
31
  const pool = getPool();
35
- for (let i = 0; i < pool.length; i += 1) {
36
- if (pool[i].parent === parent) {
37
- pool[i].parent = null;
38
- pool[i].canvas.width = 1;
39
- pool[i].canvas.height = 1;
32
+ for (const entry of pool) {
33
+ if (entry.parent === parent) {
34
+ entry.parent = null;
35
+ entry.canvas.width = 1;
36
+ entry.canvas.height = 1;
40
37
  }
41
38
  }
42
39
  };
@@ -47,11 +44,11 @@ export const remove = (parent: any) => {
47
44
  */
48
45
  export const removeByCanvas = (canvas: HTMLCanvasElement) => {
49
46
  const pool = getPool();
50
- for (let i = 0; i < pool.length; i += 1) {
51
- if (pool[i].canvas === canvas) {
52
- pool[i].parent = null;
53
- pool[i].canvas.width = 1;
54
- pool[i].canvas.height = 1;
47
+ for (const entry of pool) {
48
+ if (entry.canvas === canvas) {
49
+ entry.parent = null;
50
+ entry.canvas.width = 1;
51
+ entry.canvas.height = 1;
55
52
  }
56
53
  }
57
54
  };
@@ -63,8 +60,8 @@ export const removeByCanvas = (canvas: HTMLCanvasElement) => {
63
60
  export const getTotal = () => {
64
61
  const pool = getPool();
65
62
  let c = 0;
66
- for (let i = 0; i < pool.length; i += 1) {
67
- if (pool[i].parent) {
63
+ for (const entry of pool) {
64
+ if (entry.parent) {
68
65
  c += 1;
69
66
  }
70
67
  }
@@ -78,8 +75,8 @@ export const getTotal = () => {
78
75
  export const getFree = () => {
79
76
  const pool = getPool();
80
77
  let c = 0;
81
- for (let i = 0; i < pool.length; i += 1) {
82
- if (!pool[i].parent) {
78
+ for (const entry of pool) {
79
+ if (!entry.parent) {
83
80
  c += 1;
84
81
  }
85
82
  }
@@ -94,14 +91,14 @@ export const getFree = () => {
94
91
  * @param {boolean} skipPool - True to skip using the pool and create a new canvas.
95
92
  * @returns {HTMLCanvasElement} The canvas from the pool or a newly created one.
96
93
  */
97
- export const create = (parent: any, width?: any, height?: any, skipPool: boolean = false) => {
94
+ export const create = (parent: any, width?: any, height?: any, skipPool = false) => {
98
95
  if (parent === undefined) {
99
96
  console.warn('Created CanvasPool element with undefined parent.');
100
97
  }
101
98
  const idx = getFirst();
102
99
  const pool = getPool();
103
100
  let canvas;
104
- if (idx === -1 || skipPool === true) {
101
+ if (idx === -1 || skipPool) {
105
102
  const container = {
106
103
  parent,
107
104
  canvas: document.createElement('canvas'),
@@ -109,8 +106,9 @@ export const create = (parent: any, width?: any, height?: any, skipPool: boolean
109
106
  pool.push(container);
110
107
  canvas = container.canvas;
111
108
  } else {
112
- pool[idx].parent = parent;
113
- canvas = pool[idx].canvas;
109
+ const entry = pool[idx]!;
110
+ entry.parent = parent;
111
+ canvas = entry.canvas;
114
112
  }
115
113
  if (width !== undefined) {
116
114
  canvas.width = width;
@@ -1,3 +1,5 @@
1
+ import type { Game } from '../../core/game.js';
2
+ import type { Stage } from '../../core/stage.js';
1
3
  import {
2
4
  BLEND_ADD,
3
5
  BLEND_COLOR,
@@ -26,24 +28,24 @@ import { detectCapabilities } from './tinter.js';
26
28
  import { getSmoothingPrefix } from './util.js';
27
29
 
28
30
  export class CanvasRenderer {
29
- type!: any;
30
- resolution!: any;
31
- clearBeforeRender!: any;
32
- transparent!: any;
33
- autoResize!: any;
34
- contextLost!: any;
35
- width!: any;
36
- height!: any;
37
- view!: any;
38
- context!: any;
39
- refresh!: any;
40
- count!: any;
41
- renderSession!: any;
31
+ public type!: any;
32
+ public resolution!: any;
33
+ public clearBeforeRender!: any;
34
+ public transparent!: any;
35
+ public autoResize!: any;
36
+ public contextLost!: any;
37
+ public width!: any;
38
+ public height!: any;
39
+ public view!: any;
40
+ public context!: any;
41
+ public refresh!: any;
42
+ public count!: any;
43
+ public renderSession!: any;
42
44
  /**
43
45
  * Creates a new CanvasRenderer instance.
44
- * @param {import('../../core/game.js').Game} _game - The game instance.
46
+ * @param {Game} _game - The game instance.
45
47
  */
46
- constructor(game: import('../../core/game.js').Game) {
48
+ public constructor(game: Game) {
47
49
  detectCapabilities(game);
48
50
  /** @type {number} */
49
51
  this.type = RENDER_CANVAS;
@@ -56,7 +58,6 @@ export class CanvasRenderer {
56
58
  this.height = game.height * this.resolution;
57
59
  this.view = game.canvas;
58
60
  /** @type {CanvasRenderingContext2D} */
59
- // @ts-ignore
60
61
  this.context = this.view.getContext('2d', { willReadFrequently: false, alpha: this.transparent });
61
62
  if (!this.context) {
62
63
  throw new Error(ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT);
@@ -76,9 +77,9 @@ export class CanvasRenderer {
76
77
 
77
78
  /**
78
79
  * Renders the stage to canvas.
79
- * @param {import('../../core/stage.js').Stage} root - The root stage to render.
80
+ * @param {Stage} root - The root stage to render.
80
81
  */
81
- render(root: import('../../core/stage.js').Stage) {
82
+ public render(root: Stage) {
82
83
  if (!this.context) {
83
84
  return;
84
85
  }
@@ -103,7 +104,7 @@ export class CanvasRenderer {
103
104
  * Destroys this renderer and cleans up resources.
104
105
  * @param {boolean} removeView - Whether to remove the view from the DOM.
105
106
  */
106
- destroy(removeView: boolean = true) {
107
+ public destroy(removeView = true) {
107
108
  if (removeView && this.view.parent) {
108
109
  this.view.parent.removeChild(this.view);
109
110
  }
@@ -117,7 +118,7 @@ export class CanvasRenderer {
117
118
  * @param {number} width - The new width of the canvas.
118
119
  * @param {number} height - The new height of the canvas.
119
120
  */
120
- resize(width: number, height: number) {
121
+ public resize(width: number, height: number) {
121
122
  this.width = width * this.resolution;
122
123
  this.height = height * this.resolution;
123
124
  this.view.width = this.width;
@@ -133,12 +134,12 @@ export class CanvasRenderer {
133
134
 
134
135
  /**
135
136
  * Renders a display object to canvas.
136
- * @param {import('../../display/image.js').Image} displayObject - The display object to render.
137
+ * @param {Image} displayObject - The display object to render.
137
138
  * @param {CanvasRenderingContext2D} context - The canvas rendering context.
138
- * @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
139
+ * @param {Matrix} matrix - The transformation matrix.
139
140
  */
140
- renderDisplayObject(displayObject: any, context?: any, matrix?: any) {
141
- this.renderSession.context = context || this.context;
141
+ public renderDisplayObject(displayObject: any, context?: any, matrix?: any) {
142
+ this.renderSession.context = context ?? this.context;
142
143
  this.renderSession.resolution = this.resolution;
143
144
  displayObject.renderCanvas(this.renderSession, matrix);
144
145
  }
@@ -146,12 +147,12 @@ export class CanvasRenderer {
146
147
  /**
147
148
  * Maps blend modes to canvas rendering operations.
148
149
  */
149
- mapBlendModes() {
150
- if (window.PhaserRegistry.blendModesCanvas) {
150
+ public mapBlendModes() {
151
+ if (globalThis.PhaserRegistry.blendModesCanvas) {
151
152
  return;
152
153
  }
153
- const b = [];
154
- const useNew = window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY;
154
+ const b: GlobalCompositeOperation[] = [];
155
+ const useNew = globalThis.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY;
155
156
  b[BLEND_NORMAL] = 'source-over';
156
157
  b[BLEND_ADD] = 'lighter';
157
158
  b[BLEND_MULTIPLY] = useNew ? 'multiply' : 'source-over';
@@ -169,14 +170,14 @@ export class CanvasRenderer {
169
170
  b[BLEND_SATURATION] = useNew ? 'saturation' : 'source-over';
170
171
  b[BLEND_COLOR] = useNew ? 'color' : 'source-over';
171
172
  b[BLEND_LUMINOSITY] = useNew ? 'luminosity' : 'source-over';
172
- window.PhaserRegistry.blendModesCanvas = b;
173
+ globalThis.PhaserRegistry.blendModesCanvas = b;
173
174
  }
174
175
 
175
176
  /**
176
177
  * Initializes the WebGL context for rendering.
177
- * @param {import('../../core/game.js').Game} game - The game instance.
178
+ * @param {Game} game - The game instance.
178
179
  */
179
- initContext(_game: import('../../core/game.js').Game) {
180
+ public initContext(_game: Game) {
180
181
  // stub
181
182
  }
182
183
  }