@vpmedia/phaser 1.11.0 → 1.13.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 (306) hide show
  1. package/README.md +1 -1
  2. package/package.json +8 -5
  3. package/src/index.js +19 -19
  4. package/src/phaser/core/animation.js +12 -9
  5. package/src/phaser/core/animation_manager.js +16 -6
  6. package/src/phaser/core/animation_parser.js +40 -17
  7. package/src/phaser/core/array_set.js +3 -5
  8. package/src/phaser/core/cache.js +12 -12
  9. package/src/phaser/core/const.js +1 -1
  10. package/src/phaser/core/device.js +2 -4
  11. package/src/phaser/core/device_util.js +50 -17
  12. package/src/phaser/core/dom.js +36 -27
  13. package/src/phaser/core/event_manager.js +47 -19
  14. package/src/phaser/core/factory.js +34 -12
  15. package/src/phaser/core/frame.js +3 -5
  16. package/src/phaser/core/frame_data.js +2 -4
  17. package/src/phaser/core/frame_util.js +11 -9
  18. package/src/phaser/core/game.js +22 -19
  19. package/src/phaser/core/input.js +24 -16
  20. package/src/phaser/core/input_handler.js +102 -28
  21. package/src/phaser/core/input_mouse.js +12 -16
  22. package/src/phaser/core/input_mspointer.js +11 -10
  23. package/src/phaser/core/input_pointer.js +61 -20
  24. package/src/phaser/core/input_touch.js +7 -9
  25. package/src/phaser/core/loader.js +171 -54
  26. package/src/phaser/core/loader_parser.js +29 -22
  27. package/src/phaser/core/raf.js +2 -4
  28. package/src/phaser/core/scale_manager.js +75 -31
  29. package/src/phaser/core/scene.js +2 -4
  30. package/src/phaser/core/scene_manager.js +9 -6
  31. package/src/phaser/core/signal.js +19 -11
  32. package/src/phaser/core/signal_binding.js +12 -7
  33. package/src/phaser/core/sound.js +23 -14
  34. package/src/phaser/core/sound_manager.js +62 -26
  35. package/src/phaser/core/sound_sprite.js +34 -34
  36. package/src/phaser/core/stage.js +4 -7
  37. package/src/phaser/core/time.js +3 -5
  38. package/src/phaser/core/timer.js +27 -10
  39. package/src/phaser/core/timer_event.js +1 -3
  40. package/src/phaser/core/tween.js +36 -12
  41. package/src/phaser/core/tween_data.js +17 -9
  42. package/src/phaser/core/tween_easing.js +87 -83
  43. package/src/phaser/core/tween_manager.js +34 -16
  44. package/src/phaser/core/world.js +3 -5
  45. package/src/phaser/display/bitmap_text.js +25 -14
  46. package/src/phaser/display/button.js +35 -8
  47. package/src/phaser/display/canvas/buffer.js +1 -3
  48. package/src/phaser/display/canvas/graphics.js +30 -15
  49. package/src/phaser/display/canvas/masker.js +7 -5
  50. package/src/phaser/display/canvas/pool.js +18 -11
  51. package/src/phaser/display/canvas/renderer.js +40 -20
  52. package/src/phaser/display/canvas/tinter.js +61 -19
  53. package/src/phaser/display/canvas/util.js +44 -35
  54. package/src/phaser/display/display_object.js +42 -24
  55. package/src/phaser/display/graphics.js +72 -39
  56. package/src/phaser/display/graphics_data.js +3 -4
  57. package/src/phaser/display/graphics_data_util.js +15 -5
  58. package/src/phaser/display/group.js +15 -9
  59. package/src/phaser/display/image.js +17 -9
  60. package/src/phaser/display/sprite_batch.js +8 -4
  61. package/src/phaser/display/sprite_util.js +67 -26
  62. package/src/phaser/display/text.js +92 -31
  63. package/src/phaser/display/webgl/abstract_filter.js +1 -3
  64. package/src/phaser/display/webgl/base_texture.js +8 -5
  65. package/src/phaser/display/webgl/blend_manager.js +1 -3
  66. package/src/phaser/display/webgl/earcut.js +170 -129
  67. package/src/phaser/display/webgl/earcut_node.js +1 -3
  68. package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
  69. package/src/phaser/display/webgl/filter_manager.js +1 -3
  70. package/src/phaser/display/webgl/filter_texture.js +17 -6
  71. package/src/phaser/display/webgl/graphics.js +72 -50
  72. package/src/phaser/display/webgl/graphics_data.js +2 -4
  73. package/src/phaser/display/webgl/mask_manager.js +17 -7
  74. package/src/phaser/display/webgl/render_texture.js +19 -10
  75. package/src/phaser/display/webgl/renderer.js +41 -9
  76. package/src/phaser/display/webgl/shader/complex.js +1 -3
  77. package/src/phaser/display/webgl/shader/fast.js +9 -4
  78. package/src/phaser/display/webgl/shader/normal.js +43 -15
  79. package/src/phaser/display/webgl/shader/primitive.js +1 -3
  80. package/src/phaser/display/webgl/shader/strip.js +1 -3
  81. package/src/phaser/display/webgl/shader_manager.js +1 -3
  82. package/src/phaser/display/webgl/sprite_batch.js +14 -15
  83. package/src/phaser/display/webgl/stencil_manager.js +19 -21
  84. package/src/phaser/display/webgl/texture.js +14 -10
  85. package/src/phaser/display/webgl/texture_util.js +11 -9
  86. package/src/phaser/display/webgl/util.js +21 -18
  87. package/src/phaser/geom/circle.js +27 -11
  88. package/src/phaser/geom/ellipse.js +26 -10
  89. package/src/phaser/geom/line.js +31 -13
  90. package/src/phaser/geom/matrix.js +14 -5
  91. package/src/phaser/geom/point.js +18 -13
  92. package/src/phaser/geom/polygon.js +13 -8
  93. package/src/phaser/geom/rectangle.js +57 -14
  94. package/src/phaser/geom/rounded_rectangle.js +12 -4
  95. package/src/phaser/geom/util/circle.js +40 -32
  96. package/src/phaser/geom/util/ellipse.js +10 -18
  97. package/src/phaser/geom/util/line.js +46 -37
  98. package/src/phaser/geom/util/matrix.js +11 -9
  99. package/src/phaser/geom/util/point.js +101 -79
  100. package/src/phaser/geom/util/polygon.js +7 -15
  101. package/src/phaser/geom/util/rectangle.js +95 -69
  102. package/src/phaser/geom/util/rounded_rectangle.js +7 -15
  103. package/src/phaser/util/math.js +123 -89
  104. package/types/global.d.ts +7 -0
  105. package/types/index.d.ts +22 -0
  106. package/types/index.d.ts.map +1 -0
  107. package/types/phaser/core/animation.d.ts +55 -0
  108. package/types/phaser/core/animation.d.ts.map +1 -0
  109. package/types/phaser/core/animation_manager.d.ts +35 -0
  110. package/types/phaser/core/animation_manager.d.ts.map +1 -0
  111. package/types/phaser/core/animation_parser.d.ts +22 -0
  112. package/types/phaser/core/animation_parser.d.ts.map +1 -0
  113. package/types/phaser/core/array_set.d.ts +23 -0
  114. package/types/phaser/core/array_set.d.ts.map +1 -0
  115. package/types/phaser/core/cache.d.ts +106 -0
  116. package/types/phaser/core/cache.d.ts.map +1 -0
  117. package/types/phaser/core/const.d.ts +81 -0
  118. package/types/phaser/core/const.d.ts.map +1 -0
  119. package/types/phaser/core/device.d.ts +36 -0
  120. package/types/phaser/core/device.d.ts.map +1 -0
  121. package/types/phaser/core/device_util.d.ts +58 -0
  122. package/types/phaser/core/device_util.d.ts.map +1 -0
  123. package/types/phaser/core/dom.d.ts +63 -0
  124. package/types/phaser/core/dom.d.ts.map +1 -0
  125. package/types/phaser/core/event_manager.d.ts +53 -0
  126. package/types/phaser/core/event_manager.d.ts.map +1 -0
  127. package/types/phaser/core/factory.d.ts +12 -0
  128. package/types/phaser/core/factory.d.ts.map +1 -0
  129. package/types/phaser/core/frame.d.ts +30 -0
  130. package/types/phaser/core/frame.d.ts.map +1 -0
  131. package/types/phaser/core/frame_data.d.ts +14 -0
  132. package/types/phaser/core/frame_data.d.ts.map +1 -0
  133. package/types/phaser/core/frame_util.d.ts +17 -0
  134. package/types/phaser/core/frame_util.d.ts.map +1 -0
  135. package/types/phaser/core/game.d.ts +57 -0
  136. package/types/phaser/core/game.d.ts.map +1 -0
  137. package/types/phaser/core/input.d.ts +92 -0
  138. package/types/phaser/core/input.d.ts.map +1 -0
  139. package/types/phaser/core/input_handler.d.ts +111 -0
  140. package/types/phaser/core/input_handler.d.ts.map +1 -0
  141. package/types/phaser/core/input_mouse.d.ts +39 -0
  142. package/types/phaser/core/input_mouse.d.ts.map +1 -0
  143. package/types/phaser/core/input_mspointer.d.ts +34 -0
  144. package/types/phaser/core/input_mspointer.d.ts.map +1 -0
  145. package/types/phaser/core/input_pointer.d.ts +68 -0
  146. package/types/phaser/core/input_pointer.d.ts.map +1 -0
  147. package/types/phaser/core/input_touch.d.ts +37 -0
  148. package/types/phaser/core/input_touch.d.ts.map +1 -0
  149. package/types/phaser/core/loader.d.ts +94 -0
  150. package/types/phaser/core/loader.d.ts.map +1 -0
  151. package/types/phaser/core/loader_parser.d.ts +39 -0
  152. package/types/phaser/core/loader_parser.d.ts.map +1 -0
  153. package/types/phaser/core/raf.d.ts +15 -0
  154. package/types/phaser/core/raf.d.ts.map +1 -0
  155. package/types/phaser/core/scale_manager.d.ts +137 -0
  156. package/types/phaser/core/scale_manager.d.ts.map +1 -0
  157. package/types/phaser/core/scene.d.ts +17 -0
  158. package/types/phaser/core/scene.d.ts.map +1 -0
  159. package/types/phaser/core/scene_manager.d.ts +39 -0
  160. package/types/phaser/core/scene_manager.d.ts.map +1 -0
  161. package/types/phaser/core/signal.d.ts +25 -0
  162. package/types/phaser/core/signal.d.ts.map +1 -0
  163. package/types/phaser/core/signal_binding.d.ts +26 -0
  164. package/types/phaser/core/signal_binding.d.ts.map +1 -0
  165. package/types/phaser/core/sound.d.ts +72 -0
  166. package/types/phaser/core/sound.d.ts.map +1 -0
  167. package/types/phaser/core/sound_manager.d.ts +50 -0
  168. package/types/phaser/core/sound_manager.d.ts.map +1 -0
  169. package/types/phaser/core/sound_sprite.d.ts +18 -0
  170. package/types/phaser/core/sound_sprite.d.ts.map +1 -0
  171. package/types/phaser/core/stage.d.ts +23 -0
  172. package/types/phaser/core/stage.d.ts.map +1 -0
  173. package/types/phaser/core/time.d.ts +49 -0
  174. package/types/phaser/core/time.d.ts.map +1 -0
  175. package/types/phaser/core/timer.d.ts +49 -0
  176. package/types/phaser/core/timer.d.ts.map +1 -0
  177. package/types/phaser/core/timer_event.d.ts +18 -0
  178. package/types/phaser/core/timer_event.d.ts.map +1 -0
  179. package/types/phaser/core/tween.d.ts +52 -0
  180. package/types/phaser/core/tween.d.ts.map +1 -0
  181. package/types/phaser/core/tween_data.d.ts +37 -0
  182. package/types/phaser/core/tween_data.d.ts.map +1 -0
  183. package/types/phaser/core/tween_easing.d.ts +192 -0
  184. package/types/phaser/core/tween_easing.d.ts.map +1 -0
  185. package/types/phaser/core/tween_manager.d.ts +94 -0
  186. package/types/phaser/core/tween_manager.d.ts.map +1 -0
  187. package/types/phaser/core/world.d.ts +6 -0
  188. package/types/phaser/core/world.d.ts.map +1 -0
  189. package/types/phaser/display/bitmap_text.d.ts +59 -0
  190. package/types/phaser/display/bitmap_text.d.ts.map +1 -0
  191. package/types/phaser/display/button.d.ts +47 -0
  192. package/types/phaser/display/button.d.ts.map +1 -0
  193. package/types/phaser/display/canvas/buffer.d.ts +11 -0
  194. package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
  195. package/types/phaser/display/canvas/graphics.d.ts +21 -0
  196. package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
  197. package/types/phaser/display/canvas/masker.d.ts +14 -0
  198. package/types/phaser/display/canvas/masker.d.ts.map +1 -0
  199. package/types/phaser/display/canvas/pool.d.ts +52 -0
  200. package/types/phaser/display/canvas/pool.d.ts.map +1 -0
  201. package/types/phaser/display/canvas/renderer.d.ts +28 -0
  202. package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
  203. package/types/phaser/display/canvas/tinter.d.ts +41 -0
  204. package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
  205. package/types/phaser/display/canvas/util.d.ts +79 -0
  206. package/types/phaser/display/canvas/util.d.ts.map +1 -0
  207. package/types/phaser/display/display_object.d.ts +83 -0
  208. package/types/phaser/display/display_object.d.ts.map +1 -0
  209. package/types/phaser/display/graphics.d.ts +60 -0
  210. package/types/phaser/display/graphics.d.ts.map +1 -0
  211. package/types/phaser/display/graphics_data.d.ts +15 -0
  212. package/types/phaser/display/graphics_data.d.ts.map +1 -0
  213. package/types/phaser/display/graphics_data_util.d.ts +8 -0
  214. package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
  215. package/types/phaser/display/group.d.ts +49 -0
  216. package/types/phaser/display/group.d.ts.map +1 -0
  217. package/types/phaser/display/image.d.ts +52 -0
  218. package/types/phaser/display/image.d.ts.map +1 -0
  219. package/types/phaser/display/sprite_batch.d.ts +11 -0
  220. package/types/phaser/display/sprite_batch.d.ts.map +1 -0
  221. package/types/phaser/display/sprite_util.d.ts +40 -0
  222. package/types/phaser/display/sprite_util.d.ts.map +1 -0
  223. package/types/phaser/display/text.d.ts +125 -0
  224. package/types/phaser/display/text.d.ts.map +1 -0
  225. package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
  226. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
  227. package/types/phaser/display/webgl/base_texture.d.ts +20 -0
  228. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
  229. package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
  230. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
  231. package/types/phaser/display/webgl/earcut.d.ts +215 -0
  232. package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
  233. package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
  234. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
  235. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
  236. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
  237. package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
  238. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
  239. package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
  240. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
  241. package/types/phaser/display/webgl/graphics.d.ts +80 -0
  242. package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
  243. package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
  244. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
  245. package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
  246. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
  247. package/types/phaser/display/webgl/render_texture.d.ts +25 -0
  248. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
  249. package/types/phaser/display/webgl/renderer.d.ts +44 -0
  250. package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
  251. package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
  252. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
  253. package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
  254. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
  255. package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
  256. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
  257. package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
  258. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
  259. package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
  260. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
  261. package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
  262. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
  263. package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
  264. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
  265. package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
  266. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
  267. package/types/phaser/display/webgl/texture.d.ts +30 -0
  268. package/types/phaser/display/webgl/texture.d.ts.map +1 -0
  269. package/types/phaser/display/webgl/texture_util.d.ts +17 -0
  270. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
  271. package/types/phaser/display/webgl/util.d.ts +45 -0
  272. package/types/phaser/display/webgl/util.d.ts.map +1 -0
  273. package/types/phaser/geom/circle.d.ts +46 -0
  274. package/types/phaser/geom/circle.d.ts.map +1 -0
  275. package/types/phaser/geom/ellipse.d.ts +26 -0
  276. package/types/phaser/geom/ellipse.d.ts.map +1 -0
  277. package/types/phaser/geom/line.d.ts +45 -0
  278. package/types/phaser/geom/line.d.ts.map +1 -0
  279. package/types/phaser/geom/matrix.d.ts +35 -0
  280. package/types/phaser/geom/matrix.d.ts.map +1 -0
  281. package/types/phaser/geom/point.d.ts +43 -0
  282. package/types/phaser/geom/point.d.ts.map +1 -0
  283. package/types/phaser/geom/polygon.d.ts +17 -0
  284. package/types/phaser/geom/polygon.d.ts.map +1 -0
  285. package/types/phaser/geom/rectangle.d.ts +71 -0
  286. package/types/phaser/geom/rectangle.d.ts.map +1 -0
  287. package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
  288. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
  289. package/types/phaser/geom/util/circle.d.ts +64 -0
  290. package/types/phaser/geom/util/circle.d.ts.map +1 -0
  291. package/types/phaser/geom/util/ellipse.d.ts +16 -0
  292. package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
  293. package/types/phaser/geom/util/line.d.ts +49 -0
  294. package/types/phaser/geom/util/line.d.ts.map +1 -0
  295. package/types/phaser/geom/util/matrix.d.ts +22 -0
  296. package/types/phaser/geom/util/matrix.d.ts.map +1 -0
  297. package/types/phaser/geom/util/point.d.ts +179 -0
  298. package/types/phaser/geom/util/point.d.ts.map +1 -0
  299. package/types/phaser/geom/util/polygon.d.ts +10 -0
  300. package/types/phaser/geom/util/polygon.d.ts.map +1 -0
  301. package/types/phaser/geom/util/rectangle.d.ts +141 -0
  302. package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
  303. package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
  304. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
  305. package/types/phaser/util/math.d.ts +182 -0
  306. package/types/phaser/util/math.d.ts.map +1 -0
@@ -1,17 +1,19 @@
1
1
  /**
2
+ * @module display/sprite_util
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
7
  import { getTintedTexture } from './canvas/tinter';
7
8
  import { getIdentityMatrix } from '../geom/util/matrix';
8
9
  import { SCALE_LINEAR } from '../core/const';
9
10
 
10
11
  /**
12
+ * TBD.
11
13
  *
12
- * @param {object} target TBD
13
- * @param {object} texture TBD
14
- * @param {boolean} destroyBase TBD
14
+ * @param {object} target - TBD.
15
+ * @param {object} texture - TBD.
16
+ * @param {boolean} destroyBase - TBD.
15
17
  */
16
18
  export function setTexture(target, texture, destroyBase = false) {
17
19
  if (destroyBase) {
@@ -24,10 +26,11 @@ export function setTexture(target, texture, destroyBase = false) {
24
26
  }
25
27
 
26
28
  /**
29
+ * TBD.
27
30
  *
28
- * @param {object} target TBD
29
- * @param {object} matrix TBD
30
- * @returns {object} TBD
31
+ * @param {object} target - TBD.
32
+ * @param {object} matrix - TBD.
33
+ * @returns {object} TBD.
31
34
  */
32
35
  export function getBounds(target, matrix = null) {
33
36
  // TODO verify
@@ -107,9 +110,10 @@ export function getBounds(target, matrix = null) {
107
110
  }
108
111
 
109
112
  /**
113
+ * TBD.
110
114
  *
111
- * @param {object} target TBD
112
- * @returns {object} TBD
115
+ * @param {object} target - TBD.
116
+ * @returns {object} TBD.
113
117
  */
114
118
  export function getLocalBounds(target) {
115
119
  const matrixCache = target.worldTransform;
@@ -127,10 +131,11 @@ export function getLocalBounds(target) {
127
131
  }
128
132
 
129
133
  /**
134
+ * TBD.
130
135
  *
131
- * @param {object} target TBD
132
- * @param {object} renderSession TBD
133
- * @param {object} matrix TBD
136
+ * @param {object} target - TBD.
137
+ * @param {object} renderSession - TBD.
138
+ * @param {object} matrix - TBD.
134
139
  */
135
140
  export function renderWebGL(target, renderSession, matrix) {
136
141
  // if the sprite is not visible or the alpha is 0 then no need to render this element
@@ -176,14 +181,21 @@ export function renderWebGL(target, renderSession, matrix) {
176
181
  }
177
182
 
178
183
  /**
184
+ * TBD.
179
185
  *
180
- * @param {object} target TBD
181
- * @param {object} renderSession TBD
182
- * @param {object} matrix TBD
186
+ * @param {object} target - TBD.
187
+ * @param {object} renderSession - TBD.
188
+ * @param {object} matrix - TBD.
183
189
  */
184
190
  export function renderCanvas(target, renderSession, matrix) {
185
191
  // If the sprite is not visible or the alpha is 0 then no need to render this element
186
- if (!target.visible || target.alpha === 0 || !target.renderable || target.texture.crop.width <= 0 || target.texture.crop.height <= 0) {
192
+ if (
193
+ !target.visible ||
194
+ target.alpha === 0 ||
195
+ !target.renderable ||
196
+ target.texture.crop.width <= 0 ||
197
+ target.texture.crop.height <= 0
198
+ ) {
187
199
  return;
188
200
  }
189
201
  let wt = target.worldTransform;
@@ -193,7 +205,8 @@ export function renderCanvas(target, renderSession, matrix) {
193
205
  }
194
206
  if (target.blendMode !== renderSession.currentBlendMode) {
195
207
  renderSession.currentBlendMode = target.blendMode;
196
- renderSession.context.globalCompositeOperation = window.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
208
+ renderSession.context.globalCompositeOperation =
209
+ window.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
197
210
  }
198
211
  if (target._mask) {
199
212
  renderSession.maskManager.pushMask(target._mask, renderSession);
@@ -204,15 +217,23 @@ export function renderCanvas(target, renderSession, matrix) {
204
217
  renderSession.context.globalAlpha = target.worldAlpha;
205
218
 
206
219
  // If smoothingEnabled is supported and we need to change the smoothing property for this texture
207
- if (renderSession.smoothProperty && renderSession.scaleMode !== target.texture.baseTexture.scaleMode) {
220
+ if (
221
+ renderSession.smoothProperty &&
222
+ renderSession.scaleMode !== target.texture.baseTexture.scaleMode
223
+ ) {
208
224
  renderSession.scaleMode = target.texture.baseTexture.scaleMode;
209
- renderSession.context[renderSession.smoothProperty] = (renderSession.scaleMode === SCALE_LINEAR);
225
+ renderSession.context[renderSession.smoothProperty] =
226
+ renderSession.scaleMode === SCALE_LINEAR;
210
227
  }
211
228
  // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions
212
- let dx = (target.texture.trim) ? target.texture.trim.x - target.anchor.x * target.texture.trim.width : target.anchor.x * -target.texture.frame.width;
213
- let dy = (target.texture.trim) ? target.texture.trim.y - target.anchor.y * target.texture.trim.height : target.anchor.y * -target.texture.frame.height;
214
- const tx = (wt.tx * renderSession.resolution) + renderSession.shakeX;
215
- const ty = (wt.ty * renderSession.resolution) + renderSession.shakeY;
229
+ let dx = target.texture.trim
230
+ ? target.texture.trim.x - target.anchor.x * target.texture.trim.width
231
+ : target.anchor.x * -target.texture.frame.width;
232
+ let dy = target.texture.trim
233
+ ? target.texture.trim.y - target.anchor.y * target.texture.trim.height
234
+ : target.anchor.y * -target.texture.frame.height;
235
+ const tx = wt.tx * renderSession.resolution + renderSession.shakeX;
236
+ const ty = wt.ty * renderSession.resolution + renderSession.shakeY;
216
237
  // Allow for pixel rounding
217
238
  if (renderSession.roundPixels) {
218
239
  renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx | 0, ty | 0);
@@ -225,20 +246,40 @@ export function renderCanvas(target, renderSession, matrix) {
225
246
  let ch = target.texture.crop.height;
226
247
  dx /= resolution;
227
248
  dy /= resolution;
228
- if (target.tint !== 0xFFFFFF) {
249
+ if (target.tint !== 0xffffff) {
229
250
  if (target.texture.requiresReTint || target.cachedTint !== target.tint) {
230
251
  target.tintedTexture = getTintedTexture(target, target.tint);
231
252
  target.cachedTint = target.tint;
232
253
  target.texture.requiresReTint = false;
233
254
  }
234
- renderSession.context.drawImage(target.tintedTexture, 0, 0, cw, ch, dx, dy, cw / resolution, ch / resolution);
255
+ renderSession.context.drawImage(
256
+ target.tintedTexture,
257
+ 0,
258
+ 0,
259
+ cw,
260
+ ch,
261
+ dx,
262
+ dy,
263
+ cw / resolution,
264
+ ch / resolution
265
+ );
235
266
  } else {
236
267
  const cx = target.texture.crop.x;
237
268
  const cy = target.texture.crop.y;
238
269
  // https://github.com/photonstorm/phaser-ce/pull/61
239
270
  cw = Math.floor(cw);
240
271
  ch = Math.floor(ch);
241
- renderSession.context.drawImage(target.texture.baseTexture.source, cx, cy, cw, ch, dx, dy, cw / resolution, ch / resolution);
272
+ renderSession.context.drawImage(
273
+ target.texture.baseTexture.source,
274
+ cx,
275
+ cy,
276
+ cw,
277
+ ch,
278
+ dx,
279
+ dy,
280
+ cw / resolution,
281
+ ch / resolution
282
+ );
242
283
  }
243
284
  }
244
285
  for (let i = 0; i < target.children.length; i += 1) {
@@ -1,19 +1,28 @@
1
1
  /**
2
+ * @module display/text
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import Point from '../geom/point';
7
- import Rectangle from '../geom/rectangle';
8
- import Image from './image';
7
+ import { Point } from '../geom/point';
8
+ import { Rectangle } from '../geom/rectangle';
9
+ import { Image } from './image';
9
10
  import { create, remove } from './canvas/pool';
10
11
  import { textureFromCanvas } from './webgl/texture_util';
11
12
  import { TEXT } from '../core/const';
12
13
  import { snapToCeil } from '../util/math';
13
14
  import { renderCanvas, renderWebGL, getBounds } from './sprite_util';
14
15
 
15
- export default class extends Image {
16
-
16
+ export class Text extends Image {
17
+ /**
18
+ * TBD.
19
+ *
20
+ * @param {object} game - TBD.
21
+ * @param {number} x - TBD.
22
+ * @param {number} y - TBD.
23
+ * @param {string} text - TBD.
24
+ * @param {object} style - TBD.
25
+ */
17
26
  constructor(game, x, y, text = '', style = {}) {
18
27
  super(game, x, y, null);
19
28
  this.game = game;
@@ -60,7 +69,14 @@ export default class extends Image {
60
69
  super.destroy();
61
70
  }
62
71
 
63
- setShadow(x = 0, y = 0, color = 'rgba(0, 0, 0, 1)', blur = 0, shadowStroke = true, shadowFill = true) {
72
+ setShadow(
73
+ x = 0,
74
+ y = 0,
75
+ color = 'rgba(0, 0, 0, 1)',
76
+ blur = 0,
77
+ shadowStroke = true,
78
+ shadowFill = true
79
+ ) {
64
80
  this.style.shadowOffsetX = x;
65
81
  this.style.shadowOffsetY = y;
66
82
  this.style.shadowColor = color;
@@ -139,7 +155,12 @@ export default class extends Image {
139
155
  if (tabs === 0) {
140
156
  // Simple layout (no tabs)
141
157
  lineWidth = this.style.strokeThickness + this.padding.x;
142
- if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0) {
158
+ if (
159
+ this.colors.length > 0 ||
160
+ this.strokeColors.length > 0 ||
161
+ this.fontWeights.length > 0 ||
162
+ this.fontStyles.length > 0
163
+ ) {
143
164
  lineWidth += this.measureLine(lines[i]);
144
165
  } else {
145
166
  lineWidth += this.context.measureText(lines[i]).width;
@@ -156,7 +177,12 @@ export default class extends Image {
156
177
  let tab = 0;
157
178
  for (let c = 0; c < line.length; c += 1) {
158
179
  let section = 0;
159
- if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0) {
180
+ if (
181
+ this.colors.length > 0 ||
182
+ this.strokeColors.length > 0 ||
183
+ this.fontWeights.length > 0 ||
184
+ this.fontStyles.length > 0
185
+ ) {
160
186
  section = this.measureLine(line[c]);
161
187
  } else {
162
188
  section = Math.ceil(this.context.measureText(line[c]).width);
@@ -169,7 +195,12 @@ export default class extends Image {
169
195
  } else {
170
196
  for (let c = 0; c < line.length; c += 1) {
171
197
  // How far to the next tab?
172
- if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0) {
198
+ if (
199
+ this.colors.length > 0 ||
200
+ this.strokeColors.length > 0 ||
201
+ this.fontWeights.length > 0 ||
202
+ this.fontStyles.length > 0
203
+ ) {
173
204
  lineWidth += this.measureLine(line[c]);
174
205
  } else {
175
206
  lineWidth += Math.ceil(this.context.measureText(line[c]).width);
@@ -192,7 +223,7 @@ export default class extends Image {
192
223
  }
193
224
  // Adjust for line spacing
194
225
  if (lineSpacing !== 0) {
195
- height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1);
226
+ height += lineSpacing > 0 ? lineSpacing * lines.length : lineSpacing * (lines.length - 1);
196
227
  }
197
228
  this.canvas.height = height * this._res;
198
229
  this.context.scale(this._res, this._res);
@@ -214,9 +245,9 @@ export default class extends Image {
214
245
  for (let i = 0; i < drawnLines; i += 1) {
215
246
  // Split the line by
216
247
  linePositionX = this.style.strokeThickness / 2;
217
- linePositionY = (this.style.strokeThickness / 2 + i * lineHeight) + fontProperties.ascent;
248
+ linePositionY = this.style.strokeThickness / 2 + i * lineHeight + fontProperties.ascent;
218
249
  if (i > 0) {
219
- linePositionY += (lineSpacing * i);
250
+ linePositionY += lineSpacing * i;
220
251
  }
221
252
  if (this.style.align === 'right') {
222
253
  linePositionX += maxLineWidth - lineWidths[i];
@@ -227,7 +258,12 @@ export default class extends Image {
227
258
  linePositionX = Math.round(linePositionX);
228
259
  linePositionY = Math.round(linePositionY);
229
260
  }
230
- if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0) {
261
+ if (
262
+ this.colors.length > 0 ||
263
+ this.strokeColors.length > 0 ||
264
+ this.fontWeights.length > 0 ||
265
+ this.fontStyles.length > 0
266
+ ) {
231
267
  this.updateLine(lines[i], linePositionX, linePositionY);
232
268
  } else {
233
269
  if (this.style.stroke && this.style.strokeThickness) {
@@ -456,7 +492,9 @@ export default class extends Image {
456
492
  // if wordWrapWidth is too small for even a single
457
493
  // letter, shame user failure with a fatal error
458
494
  if (!newWord.length) {
459
- throw new Error('This text\'s wordWrapWidth setting is less than a single character!');
495
+ throw new Error(
496
+ "This text's wordWrapWidth setting is less than a single character!"
497
+ );
460
498
  }
461
499
  // replace current word in array with remainder
462
500
  const secondPart = word.substr(newWord.length);
@@ -465,10 +503,13 @@ export default class extends Image {
465
503
  out += newWord;
466
504
  }
467
505
  // if existing word length is 0, don't include it
468
- const offset = (words[j].length) ? j : j + 1;
506
+ const offset = words[j].length ? j : j + 1;
469
507
  // collapse rest of sentence
470
508
  // remove any trailing white space
471
- const remainder = words.slice(offset).join(' ').replace(/[ \n]*$/gi, '');
509
+ const remainder = words
510
+ .slice(offset)
511
+ .join(' ')
512
+ .replace(/[ \n]*$/gi, '');
472
513
  // prepend remainder to next line
473
514
  lines[i + 1] = remainder + ' ' + (lines[i + 1] || '');
474
515
  linesCount = lines.length;
@@ -536,11 +577,16 @@ export default class extends Image {
536
577
  // larger | smaller
537
578
  // {number} (em | ex | ch | rem | vh | vw | vmin | vmax | px | mm | cm | in | pt | pc | %)
538
579
  // font-family - rest (but identifiers or quoted with comma separation)
539
- const m = font.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);
580
+ const m = font.match(
581
+ /^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/
582
+ );
540
583
  if (m) {
541
584
  let family = m[5].trim();
542
585
  // If it looks like the value should be quoted, but isn't, then quote it.
543
- if (!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(family) && !/['",]/.exec(family)) {
586
+ if (
587
+ !/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(family) &&
588
+ !/['",]/.exec(family)
589
+ ) {
544
590
  family = "'" + family + "'";
545
591
  }
546
592
  return {
@@ -560,15 +606,25 @@ export default class extends Image {
560
606
  const parts = [];
561
607
  let v;
562
608
  v = components.fontStyle;
563
- if (v && v !== 'normal') { parts.push(v); }
609
+ if (v && v !== 'normal') {
610
+ parts.push(v);
611
+ }
564
612
  v = components.fontVariant;
565
- if (v && v !== 'normal') { parts.push(v); }
613
+ if (v && v !== 'normal') {
614
+ parts.push(v);
615
+ }
566
616
  v = components.fontWeight;
567
- if (v && v !== 'normal') { parts.push(v); }
617
+ if (v && v !== 'normal') {
618
+ parts.push(v);
619
+ }
568
620
  v = components.fontSize;
569
- if (v && v !== 'medium') { parts.push(v); }
621
+ if (v && v !== 'medium') {
622
+ parts.push(v);
623
+ }
570
624
  v = components.fontFamily;
571
- if (v) { parts.push(v); }
625
+ if (v) {
626
+ parts.push(v);
627
+ }
572
628
  if (!parts.length) {
573
629
  // Fallback to whatever value the 'font' was
574
630
  parts.push(components.font);
@@ -649,18 +705,18 @@ export default class extends Image {
649
705
  if (this.style.boundsAlignH === 'right') {
650
706
  x += this.textBounds.width - this.canvas.width / this.resolution;
651
707
  } else if (this.style.boundsAlignH === 'center') {
652
- x += this.textBounds.halfWidth - (this.canvas.width / this.resolution / 2);
708
+ x += this.textBounds.halfWidth - this.canvas.width / this.resolution / 2;
653
709
  }
654
710
  if (this.style.boundsAlignV === 'bottom') {
655
711
  y += this.textBounds.height - this.canvas.height / this.resolution;
656
712
  } else if (this.style.boundsAlignV === 'middle') {
657
- y += this.textBounds.halfHeight - (this.canvas.height / this.resolution / 2);
713
+ y += this.textBounds.halfHeight - this.canvas.height / this.resolution / 2;
658
714
  }
659
715
  this.pivot.x = -x;
660
716
  this.pivot.y = -y;
661
717
  }
662
718
  // Can't render something with a zero sized dimension
663
- this.renderable = (w !== 0 && h !== 0);
719
+ this.renderable = w !== 0 && h !== 0;
664
720
  this.texture.requiresReTint = true;
665
721
  this.texture.baseTexture.dirty();
666
722
  }
@@ -697,7 +753,10 @@ export default class extends Image {
697
753
 
698
754
  getFontPropertiesContext() {
699
755
  if (!window.PhaserRegistry.fontPropertiesContext) {
700
- window.PhaserRegistry.fontPropertiesContext = this.getFontPropertiesCanvas().getContext('2d', { willReadFrequently: true });
756
+ window.PhaserRegistry.fontPropertiesContext = this.getFontPropertiesCanvas().getContext(
757
+ '2d',
758
+ { willReadFrequently: true }
759
+ );
701
760
  }
702
761
  return window.PhaserRegistry.fontPropertiesContext;
703
762
  }
@@ -713,7 +772,7 @@ export default class extends Image {
713
772
  const width = Math.ceil(context.measureText('|MÉq').width);
714
773
  let baseline = Math.ceil(context.measureText('|MÉq').width);
715
774
  const height = 2 * baseline;
716
- baseline = baseline * 1.4 | 0;
775
+ baseline = (baseline * 1.4) | 0;
717
776
  canvas.width = width;
718
777
  canvas.height = height;
719
778
  context.fillStyle = '#f00';
@@ -815,7 +874,10 @@ export default class extends Image {
815
874
  let mutatedValue = value || 'Arial';
816
875
  mutatedValue = mutatedValue.trim();
817
876
  // If it looks like the value should be quoted, but isn't, then quote it.
818
- if (!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(mutatedValue) && !/['",]/.exec(mutatedValue)) {
877
+ if (
878
+ !/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(mutatedValue) &&
879
+ !/['",]/.exec(mutatedValue)
880
+ ) {
819
881
  mutatedValue = "'" + mutatedValue + "'";
820
882
  }
821
883
 
@@ -1082,5 +1144,4 @@ export default class extends Image {
1082
1144
  this.scale.y = value / this.texture.frame.height;
1083
1145
  this._height = value;
1084
1146
  }
1085
-
1086
1147
  }
@@ -1,12 +1,11 @@
1
1
  /**
2
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
3
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
4
  * @author Richard Davey <rich@photonstorm.com>
4
5
  * @author Mat Groves http://matgroves.com/ @Doormat23
5
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
6
6
  */
7
7
 
8
8
  export default class {
9
-
10
9
  constructor(fragmentSrc, uniforms) {
11
10
  this.passes = [this];
12
11
  this.shaders = [];
@@ -21,5 +20,4 @@ export default class {
21
20
  this.shaders[i].dirty = true;
22
21
  }
23
22
  }
24
-
25
23
  }
@@ -1,13 +1,13 @@
1
1
  /**
2
+ * @module display/webgl/base_texture
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
6
  * @author Mat Groves http://matgroves.com/ @Doormat23
5
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
6
7
  */
7
8
  import { removeByCanvas } from '../canvas/pool';
8
9
 
9
- export default class {
10
-
10
+ export class BaseTexture {
11
11
  constructor(source, scaleMode) {
12
12
  this.resolution = 1;
13
13
  this.width = 100;
@@ -22,7 +22,11 @@ export default class {
22
22
  this._powerOf2 = false;
23
23
  this._dirty = [true, true, true, true];
24
24
  if (source) {
25
- if ((this.source.complete || this.source.getContext) && this.source.width && this.source.height) {
25
+ if (
26
+ (this.source.complete || this.source.getContext) &&
27
+ this.source.width &&
28
+ this.source.height
29
+ ) {
26
30
  this.hasLoaded = true;
27
31
  this.width = this.source.naturalWidth || this.source.width;
28
32
  this.height = this.source.naturalHeight || this.source.height;
@@ -64,5 +68,4 @@ export default class {
64
68
  this._glTextures.length = 0;
65
69
  this.dirty();
66
70
  }
67
-
68
71
  }
@@ -1,12 +1,11 @@
1
1
  /**
2
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
3
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
4
  * @author Richard Davey <rich@photonstorm.com>
4
5
  * @author Mat Groves http://matgroves.com/ @Doormat23
5
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
6
6
  */
7
7
 
8
8
  export default class {
9
-
10
9
  constructor() {
11
10
  this.gl = null;
12
11
  this.currentBlendMode = 99999;
@@ -31,5 +30,4 @@ export default class {
31
30
  destroy() {
32
31
  this.gl = null;
33
32
  }
34
-
35
33
  }