@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,22 +1,22 @@
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
  /**
9
- *
9
+ * TBD.
10
10
  */
11
- export function initDefaultShaders() {
12
- }
11
+ export function initDefaultShaders() {}
13
12
 
14
13
  /**
14
+ * TBD.
15
15
  *
16
- * @param {object} gl TBD
17
- * @param {string[]|string} shaderSrc TBD
18
- * @param {object} shaderType TBD
19
- * @returns {object} TBD
16
+ * @param {object} gl - TBD.
17
+ * @param {string[]|string} shaderSrc - TBD.
18
+ * @param {object} shaderType - TBD.
19
+ * @returns {object} TBD.
20
20
  */
21
21
  export function compileShader(gl, shaderSrc, shaderType) {
22
22
  let src = shaderSrc;
@@ -36,31 +36,34 @@ export function compileShader(gl, shaderSrc, shaderType) {
36
36
  }
37
37
 
38
38
  /**
39
+ * TBD.
39
40
  *
40
- * @param {object} gl TBD
41
- * @param {string[]|string} shaderSrc TBD
42
- * @returns {object} TBD
41
+ * @param {object} gl - TBD.
42
+ * @param {string[]|string} shaderSrc - TBD.
43
+ * @returns {object} TBD.
43
44
  */
44
45
  export function compileVertexShader(gl, shaderSrc) {
45
46
  return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
46
47
  }
47
48
 
48
49
  /**
50
+ * TBD.
49
51
  *
50
- * @param {object} gl TBD
51
- * @param {string[]|string} shaderSrc TBD
52
- * @returns {object} TBD
52
+ * @param {object} gl - TBD.
53
+ * @param {string[]|string} shaderSrc - TBD.
54
+ * @returns {object} TBD.
53
55
  */
54
56
  export function compileFragmentShader(gl, shaderSrc) {
55
57
  return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
56
58
  }
57
59
 
58
60
  /**
61
+ * TBD.
59
62
  *
60
- * @param {object} gl TBD
61
- * @param {string[]|string} vertexSrc TBD
62
- * @param {string[]|string} fragmentSrc TBD
63
- * @returns {object} TBD
63
+ * @param {object} gl - TBD.
64
+ * @param {string[]|string} vertexSrc - TBD.
65
+ * @param {string[]|string} fragmentSrc - TBD.
66
+ * @returns {object} TBD.
64
67
  */
65
68
  export function compileProgram(gl, vertexSrc, fragmentSrc) {
66
69
  const fragmentShader = compileFragmentShader(gl, fragmentSrc);
@@ -1,16 +1,23 @@
1
1
  /**
2
+ * @module geom/circle
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 './point';
7
- import Rectangle from './rectangle';
7
+ import { Point } from './point';
8
+ import { Rectangle } from './rectangle';
8
9
  import { distance } from '../util/math';
9
10
  import { clone, contains, circumferencePoint } from './util/circle';
10
11
  import { GEOM_CIRCLE } from '../core/const';
11
12
 
12
- export default class {
13
-
13
+ export class Circle {
14
+ /**
15
+ * TBD.
16
+ *
17
+ * @param {number} x - TBD.
18
+ * @param {number} y - TBD.
19
+ * @param {number} diameter - TBD.
20
+ */
14
21
  constructor(x = 0, y = 0, diameter = 0) {
15
22
  this.x = x;
16
23
  this.y = y;
@@ -30,11 +37,11 @@ export default class {
30
37
  const result = output || new Point();
31
38
  const t = 2 * Math.PI * Math.random();
32
39
  const u = Math.random() + Math.random();
33
- const r = (u > 1) ? 2 - u : u;
40
+ const r = u > 1 ? 2 - u : u;
34
41
  const x = r * Math.cos(t);
35
42
  const y = r * Math.sin(t);
36
- result.x = this.x + (x * this.radius);
37
- result.y = this.y + (y * this.radius);
43
+ result.x = this.x + x * this.radius;
44
+ result.y = this.y + y * this.radius;
38
45
  return result;
39
46
  }
40
47
 
@@ -89,7 +96,17 @@ export default class {
89
96
  }
90
97
 
91
98
  toString() {
92
- return '[{Circle (x=' + this.x + ' y=' + this.y + ' diameter=' + this.diameter + ' radius=' + this.radius + ')}]';
99
+ return (
100
+ '[{Circle (x=' +
101
+ this.x +
102
+ ' y=' +
103
+ this.y +
104
+ ' diameter=' +
105
+ this.diameter +
106
+ ' radius=' +
107
+ this.radius +
108
+ ')}]'
109
+ );
93
110
  }
94
111
 
95
112
  get diameter() {
@@ -174,7 +191,7 @@ export default class {
174
191
  }
175
192
 
176
193
  get empty() {
177
- return (this._diameter === 0);
194
+ return this._diameter === 0;
178
195
  }
179
196
 
180
197
  set empty(value) {
@@ -182,5 +199,4 @@ export default class {
182
199
  this.setTo(0, 0, 0);
183
200
  }
184
201
  }
185
-
186
202
  }
@@ -1,15 +1,23 @@
1
1
  /**
2
+ * @module geom/ellipse
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 './point';
7
- import Rectangle from './rectangle';
7
+ import { Point } from './point';
8
+ import { Rectangle } from './rectangle';
8
9
  import { contains } from './util/ellipse';
9
10
  import { GEOM_ELLIPSE } from '../core/const';
10
11
 
11
- export default class {
12
-
12
+ export class Ellipse {
13
+ /**
14
+ * TBD.
15
+ *
16
+ * @param {number} x - TBD.
17
+ * @param {number} y - TBD.
18
+ * @param {number} width - TBD.
19
+ * @param {number} height - TBD.
20
+ */
13
21
  constructor(x = 0, y = 0, width = 0, height = 0) {
14
22
  this.x = x;
15
23
  this.y = y;
@@ -52,14 +60,22 @@ export default class {
52
60
  const r = Math.random();
53
61
  result.x = Math.sqrt(r) * Math.cos(p);
54
62
  result.y = Math.sqrt(r) * Math.sin(p);
55
- result.x = this.x + (result.x * this.width / 2.0);
56
- result.y = this.y + (result.y * this.height / 2.0);
63
+ result.x = this.x + (result.x * this.width) / 2.0;
64
+ result.y = this.y + (result.y * this.height) / 2.0;
57
65
  return result;
58
66
  }
59
67
 
60
68
  toString() {
61
- return '[{Ellipse (x=' + this.x + ' y=' + this.y + ' width=' + this.width + ' height=' + this.height + ')}]';
69
+ return (
70
+ '[{Ellipse (x=' +
71
+ this.x +
72
+ ' y=' +
73
+ this.y +
74
+ ' width=' +
75
+ this.width +
76
+ ' height=' +
77
+ this.height +
78
+ ')}]'
79
+ );
62
80
  }
63
-
64
-
65
81
  }
@@ -1,15 +1,23 @@
1
1
  /**
2
+ * @module geom/line
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 './point';
7
+ import { Point } from './point';
7
8
  import { clone, intersectsPoints, reflect } from './util/line';
8
9
  import { wrap } from '../util/math';
9
10
  import { GEOM_LINE } from '../core/const';
10
11
 
11
- export default class {
12
-
12
+ export class Line {
13
+ /**
14
+ * TBD.
15
+ *
16
+ * @param {number} x1 - TBD.
17
+ * @param {number} y1 - TBD.
18
+ * @param {number} x2 - TBD.
19
+ * @param {number} y2 - TBD.
20
+ */
13
21
  constructor(x1 = 0, y1 = 0, x2 = 0, y2 = 0) {
14
22
  this.start = new Point(x1, y1);
15
23
  this.end = new Point(x2, y2);
@@ -24,14 +32,19 @@ export default class {
24
32
 
25
33
  fromSprite(startSprite, endSprite, useCenter = false) {
26
34
  if (useCenter) {
27
- return this.setTo(startSprite.center.x, startSprite.center.y, endSprite.center.x, endSprite.center.y);
35
+ return this.setTo(
36
+ startSprite.center.x,
37
+ startSprite.center.y,
38
+ endSprite.center.x,
39
+ endSprite.center.y
40
+ );
28
41
  }
29
42
  return this.setTo(startSprite.x, startSprite.y, endSprite.x, endSprite.y);
30
43
  }
31
44
 
32
45
  fromAngle(x, y, angle, length) {
33
46
  this.start.setTo(x, y);
34
- this.end.setTo(x + (Math.cos(angle) * length), y + (Math.sin(angle) * length));
47
+ this.end.setTo(x + Math.cos(angle) * length, y + Math.sin(angle) * length);
35
48
  return this;
36
49
  }
37
50
 
@@ -74,7 +87,10 @@ export default class {
74
87
  }
75
88
 
76
89
  pointOnLine(x, y) {
77
- return ((x - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (y - this.start.y));
90
+ return (
91
+ (x - this.start.x) * (this.end.y - this.start.y) ===
92
+ (this.end.x - this.start.x) * (y - this.start.y)
93
+ );
78
94
  }
79
95
 
80
96
  pointOnSegment(x, y) {
@@ -82,7 +98,7 @@ export default class {
82
98
  const xMax = Math.max(this.start.x, this.end.x);
83
99
  const yMin = Math.min(this.start.y, this.end.y);
84
100
  const yMax = Math.max(this.start.y, this.end.y);
85
- return (this.pointOnLine(x, y) && (x >= xMin && x <= xMax) && (y >= yMin && y <= yMax));
101
+ return this.pointOnLine(x, y) && x >= xMin && x <= xMax && y >= yMin && y <= yMax;
86
102
  }
87
103
 
88
104
  random(output = null) {
@@ -100,12 +116,12 @@ export default class {
100
116
  const y2 = Math.round(this.end.y);
101
117
  const dx = Math.abs(x2 - x1);
102
118
  const dy = Math.abs(y2 - y1);
103
- const sx = (x1 < x2) ? 1 : -1;
104
- const sy = (y1 < y2) ? 1 : -1;
119
+ const sx = x1 < x2 ? 1 : -1;
120
+ const sy = y1 < y2 ? 1 : -1;
105
121
  let err = dx - dy;
106
122
  results.push([x1, y1]);
107
123
  let i = 1;
108
- while (!((x1 === x2) && (y1 === y2))) {
124
+ while (!(x1 === x2 && y1 === y2)) {
109
125
  const e2 = err << 1;
110
126
  if (e2 > -dy) {
111
127
  err -= dy;
@@ -128,7 +144,10 @@ export default class {
128
144
  }
129
145
 
130
146
  get length() {
131
- return Math.sqrt((this.end.x - this.start.x) * (this.end.x - this.start.x) + (this.end.y - this.start.y) * (this.end.y - this.start.y));
147
+ return Math.sqrt(
148
+ (this.end.x - this.start.x) * (this.end.x - this.start.x) +
149
+ (this.end.y - this.start.y) * (this.end.y - this.start.y)
150
+ );
132
151
  }
133
152
 
134
153
  get angle() {
@@ -186,5 +205,4 @@ export default class {
186
205
  get normalAngle() {
187
206
  return wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI);
188
207
  }
189
-
190
208
  }
@@ -1,14 +1,24 @@
1
1
  /**
2
+ * @module geom/matrix
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 './point';
7
+ import { Point } from './point';
7
8
  import { clone } from './util/matrix';
8
9
  import { GEOM_MATRIX } from '../core/const';
9
10
 
10
- export default class {
11
-
11
+ export class Matrix {
12
+ /**
13
+ * TBD.
14
+ *
15
+ * @param {number} a - TBD.
16
+ * @param {number} b - TBD.
17
+ * @param {number} c - TBD.
18
+ * @param {number} d - TBD.
19
+ * @param {number} tx - TBD.
20
+ * @param {number} ty - TBD.
21
+ */
12
22
  constructor(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {
13
23
  this.a = a;
14
24
  this.b = b;
@@ -143,5 +153,4 @@ export default class {
143
153
  identity() {
144
154
  return this.setTo(1, 0, 0, 1, 0, 0);
145
155
  }
146
-
147
156
  }
@@ -1,13 +1,19 @@
1
1
  /**
2
+ * @module geom/point
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 { distance, rotate, clone } from './util/point';
7
8
  import { GEOM_POINT } from '../core/const';
8
9
 
9
- export default class {
10
-
10
+ export class Point {
11
+ /**
12
+ * TBD.
13
+ *
14
+ * @param {number} x - TBD.
15
+ * @param {number} y - TBD.
16
+ */
11
17
  constructor(x = 0, y = 0) {
12
18
  this.x = x;
13
19
  this.y = y;
@@ -24,14 +30,14 @@ export default class {
24
30
 
25
31
  setTo(x, y) {
26
32
  this.x = x || 0;
27
- this.y = y || ((y !== 0) ? this.x : 0);
33
+ this.y = y || (y !== 0 ? this.x : 0);
28
34
  return this;
29
35
  }
30
36
 
31
37
  set(x, y) {
32
38
  // deprecated, use setTo(x, y)
33
39
  this.x = x || 0;
34
- this.y = y || ((y !== 0) ? this.x : 0);
40
+ this.y = y || (y !== 0 ? this.x : 0);
35
41
  return this;
36
42
  }
37
43
 
@@ -90,12 +96,12 @@ export default class {
90
96
  }
91
97
 
92
98
  equals(a) {
93
- return (a.x === this.x && a.y === this.y);
99
+ return a.x === this.x && a.y === this.y;
94
100
  }
95
101
 
96
102
  angle(a, asDegrees = false) {
97
103
  if (asDegrees) {
98
- return (180 / Math.PI) * (Math.atan2(a.y - this.y, a.x - this.x));
104
+ return (180 / Math.PI) * Math.atan2(a.y - this.y, a.x - this.x);
99
105
  }
100
106
  return Math.atan2(a.y - this.y, a.x - this.x);
101
107
  }
@@ -105,11 +111,11 @@ export default class {
105
111
  }
106
112
 
107
113
  getMagnitude() {
108
- return Math.sqrt((this.x * this.x) + (this.y * this.y));
114
+ return Math.sqrt(this.x * this.x + this.y * this.y);
109
115
  }
110
116
 
111
117
  getMagnitudeSq() {
112
- return (this.x * this.x) + (this.y * this.y);
118
+ return this.x * this.x + this.y * this.y;
113
119
  }
114
120
 
115
121
  setMagnitude(magnitude) {
@@ -126,15 +132,15 @@ export default class {
126
132
  }
127
133
 
128
134
  isZero() {
129
- return (this.x === 0 && this.y === 0);
135
+ return this.x === 0 && this.y === 0;
130
136
  }
131
137
 
132
138
  dot(a) {
133
- return ((this.x * a.x) + (this.y * a.y));
139
+ return this.x * a.x + this.y * a.y;
134
140
  }
135
141
 
136
142
  cross(a) {
137
- return ((this.x * a.y) - (this.y * a.x));
143
+ return this.x * a.y - this.y * a.x;
138
144
  }
139
145
 
140
146
  perp() {
@@ -160,5 +166,4 @@ export default class {
160
166
  toString() {
161
167
  return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
162
168
  }
163
-
164
169
  }
@@ -1,14 +1,14 @@
1
1
  /**
2
+ * @module geom/polygon
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 './point';
7
+ import { Point } from './point';
7
8
  import { clone } from './util/polygon';
8
9
  import { GEOM_POLYGON } from '../core/const';
9
10
 
10
- export default class {
11
-
11
+ export class Polygon {
12
12
  constructor(points = null) {
13
13
  this.area = 0;
14
14
  this._points = [];
@@ -53,7 +53,10 @@ export default class {
53
53
  const iy = this._points[i + 1];
54
54
  const jx = this._points[j];
55
55
  const jy = this._points[j + 1];
56
- if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) {
56
+ if (
57
+ ((iy <= y && y < jy) || (jy <= y && y < iy)) &&
58
+ x < ((jx - ix) * (y - iy)) / (jy - iy) + ix
59
+ ) {
57
60
  inside = !inside;
58
61
  }
59
62
  }
@@ -63,7 +66,10 @@ export default class {
63
66
  const iy = this._points[i].y;
64
67
  const jx = this._points[j].x;
65
68
  const jy = this._points[j].y;
66
- if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) {
69
+ if (
70
+ ((iy <= y && y < jy) || (jy <= y && y < iy)) &&
71
+ x < ((jx - ix) * (y - iy)) / (jy - iy) + ix
72
+ ) {
67
73
  inside = !inside;
68
74
  }
69
75
  }
@@ -117,7 +123,7 @@ export default class {
117
123
  } else {
118
124
  p2 = this._points[i + 1];
119
125
  }
120
- avgHeight = ((p1.y - y0) + (p2.y - y0)) / 2;
126
+ avgHeight = (p1.y - y0 + (p2.y - y0)) / 2;
121
127
  width = p1.x - p2.x;
122
128
  this.area += avgHeight * width;
123
129
  }
@@ -136,5 +142,4 @@ export default class {
136
142
  this._points = [];
137
143
  }
138
144
  }
139
-
140
145
  }
@@ -1,14 +1,44 @@
1
1
  /**
2
+ * @module geom/rectangle
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 './point';
7
- import { inflate, size, clone, contains, containsRect, equals, intersects, intersection, intersectsRaw, union } from './util/rectangle';
8
- import { GEOM_RECTANGLE, TOP_LEFT, TOP_CENTER, TOP_RIGHT, LEFT_CENTER, CENTER, RIGHT_CENTER, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT } from '../core/const';
9
-
10
- export default class {
11
-
7
+ import { Point } from './point';
8
+ import {
9
+ inflate,
10
+ size,
11
+ clone,
12
+ contains,
13
+ containsRect,
14
+ equals,
15
+ intersects,
16
+ intersection,
17
+ intersectsRaw,
18
+ union,
19
+ } from './util/rectangle';
20
+ import {
21
+ GEOM_RECTANGLE,
22
+ TOP_LEFT,
23
+ TOP_CENTER,
24
+ TOP_RIGHT,
25
+ LEFT_CENTER,
26
+ CENTER,
27
+ RIGHT_CENTER,
28
+ BOTTOM_LEFT,
29
+ BOTTOM_CENTER,
30
+ BOTTOM_RIGHT,
31
+ } from '../core/const';
32
+
33
+ export class Rectangle {
34
+ /**
35
+ * TBD.
36
+ *
37
+ * @param {number} x - TBD.
38
+ * @param {number} y - TBD.
39
+ * @param {number} width - TBD.
40
+ * @param {number} height - TBD.
41
+ */
12
42
  constructor(x = 0, y = 0, width = 0, height = 0) {
13
43
  this.x = x;
14
44
  this.y = y;
@@ -36,7 +66,9 @@ export default class {
36
66
  }
37
67
 
38
68
  scale(x, y) {
39
- if (y === undefined) { y = x; }
69
+ if (y === undefined) {
70
+ y = x;
71
+ }
40
72
  this.width *= x;
41
73
  this.height *= y;
42
74
  return this;
@@ -164,7 +196,19 @@ export default class {
164
196
  }
165
197
 
166
198
  toString() {
167
- return '[{Rectangle (x=' + this.x + ' y=' + this.y + ' width=' + this.width + ' height=' + this.height + ' empty=' + this.empty + ')}]';
199
+ return (
200
+ '[{Rectangle (x=' +
201
+ this.x +
202
+ ' y=' +
203
+ this.y +
204
+ ' width=' +
205
+ this.width +
206
+ ' height=' +
207
+ this.height +
208
+ ' empty=' +
209
+ this.empty +
210
+ ')}]'
211
+ );
168
212
  }
169
213
 
170
214
  get halfWidth() {
@@ -184,7 +228,7 @@ export default class {
184
228
  this.height = 0;
185
229
  this.y = value;
186
230
  } else {
187
- this.height = (this.bottom - value);
231
+ this.height = this.bottom - value;
188
232
  }
189
233
  }
190
234
 
@@ -266,7 +310,7 @@ export default class {
266
310
  }
267
311
 
268
312
  get perimeter() {
269
- return (this.width * 2) + (this.height * 2);
313
+ return this.width * 2 + this.height * 2;
270
314
  }
271
315
 
272
316
  get centerX() {
@@ -286,11 +330,11 @@ export default class {
286
330
  }
287
331
 
288
332
  get randomX() {
289
- return this.x + (Math.random() * this.width);
333
+ return this.x + Math.random() * this.width;
290
334
  }
291
335
 
292
336
  get randomY() {
293
- return this.y + (Math.random() * this.height);
337
+ return this.y + Math.random() * this.height;
294
338
  }
295
339
 
296
340
  get empty() {
@@ -302,5 +346,4 @@ export default class {
302
346
  this.setTo(0, 0, 0, 0);
303
347
  }
304
348
  }
305
-
306
349
  }
@@ -1,13 +1,22 @@
1
1
  /**
2
+ * @module geom/rounded_rectangle
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 { clone } from './util/rounded_rectangle';
7
8
  import { GEOM_ROUNDED_RECTANGLE } from '../core/const';
8
9
 
9
- export default class {
10
-
10
+ export class RoundedRectangle {
11
+ /**
12
+ * TBD.
13
+ *
14
+ * @param {number} x - TBD.
15
+ * @param {number} y - TBD.
16
+ * @param {number} width - TBD.
17
+ * @param {number} height - TBD.
18
+ * @param {number} radius - TBD.
19
+ */
11
20
  constructor(x = 0, y = 0, width = 0, height = 0, radius = 20) {
12
21
  this.x = x;
13
22
  this.y = y;
@@ -32,5 +41,4 @@ export default class {
32
41
  clone() {
33
42
  return clone(this);
34
43
  }
35
-
36
44
  }