@vpmedia/phaser 1.14.0 → 1.16.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 +3 -3
  2. package/package.json +6 -5
  3. package/src/index.js +15 -18
  4. package/src/phaser/core/animation.js +102 -6
  5. package/src/phaser/core/animation_manager.js +88 -10
  6. package/src/phaser/core/animation_parser.js +5 -20
  7. package/src/phaser/core/array_set.js +51 -5
  8. package/src/phaser/core/cache.js +291 -6
  9. package/src/phaser/core/const.js +107 -4
  10. package/src/phaser/core/device.js +5 -6
  11. package/src/phaser/core/device_util.js +3 -25
  12. package/src/phaser/core/dom.js +127 -29
  13. package/src/phaser/core/event_manager.js +128 -6
  14. package/src/phaser/core/factory.js +69 -34
  15. package/src/phaser/core/frame.js +43 -6
  16. package/src/phaser/core/frame_data.js +55 -5
  17. package/src/phaser/core/frame_util.js +7 -14
  18. package/src/phaser/core/game.js +35 -7
  19. package/src/phaser/core/input.js +116 -17
  20. package/src/phaser/core/input_handler.js +242 -42
  21. package/src/phaser/core/input_mouse.js +68 -7
  22. package/src/phaser/core/input_mspointer.js +40 -9
  23. package/src/phaser/core/input_pointer.js +79 -17
  24. package/src/phaser/core/input_touch.js +42 -5
  25. package/src/phaser/core/loader.js +274 -101
  26. package/src/phaser/core/loader_parser.js +2 -14
  27. package/src/phaser/core/raf.js +16 -5
  28. package/src/phaser/core/scale_manager.js +204 -39
  29. package/src/phaser/core/scene.js +24 -5
  30. package/src/phaser/core/scene_manager.js +81 -11
  31. package/src/phaser/core/signal.js +88 -11
  32. package/src/phaser/core/signal_binding.js +35 -15
  33. package/src/phaser/core/sound.js +99 -10
  34. package/src/phaser/core/sound_manager.js +89 -13
  35. package/src/phaser/core/sound_sprite.js +20 -5
  36. package/src/phaser/core/stage.js +43 -7
  37. package/src/phaser/core/time.js +67 -5
  38. package/src/phaser/core/timer.js +107 -30
  39. package/src/phaser/core/timer_event.js +11 -6
  40. package/src/phaser/core/tween.js +124 -30
  41. package/src/phaser/core/tween_data.js +42 -18
  42. package/src/phaser/core/tween_easing.js +1 -39
  43. package/src/phaser/core/tween_manager.js +47 -5
  44. package/src/phaser/core/world.js +9 -6
  45. package/src/phaser/display/bitmap_text.js +92 -11
  46. package/src/phaser/display/button.js +64 -13
  47. package/src/phaser/display/canvas/buffer.js +16 -6
  48. package/src/phaser/display/canvas/graphics.js +1 -16
  49. package/src/phaser/display/canvas/masker.js +0 -8
  50. package/src/phaser/display/canvas/pool.js +0 -14
  51. package/src/phaser/display/canvas/renderer.js +28 -8
  52. package/src/phaser/display/canvas/tinter.js +4 -48
  53. package/src/phaser/display/canvas/util.js +0 -15
  54. package/src/phaser/display/display_object.js +192 -20
  55. package/src/phaser/display/graphics.js +162 -27
  56. package/src/phaser/display/graphics_data.js +14 -6
  57. package/src/phaser/display/graphics_data_util.js +2 -9
  58. package/src/phaser/display/group.js +75 -10
  59. package/src/phaser/display/image.js +86 -10
  60. package/src/phaser/display/sprite_batch.js +3 -9
  61. package/src/phaser/display/sprite_util.js +3 -28
  62. package/src/phaser/display/text.js +332 -32
  63. package/src/phaser/display/webgl/abstract_filter.js +8 -7
  64. package/src/phaser/display/webgl/base_texture.js +20 -12
  65. package/src/phaser/display/webgl/blend_manager.js +14 -7
  66. package/src/phaser/display/webgl/earcut.js +4 -50
  67. package/src/phaser/display/webgl/earcut_node.js +6 -7
  68. package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
  69. package/src/phaser/display/webgl/filter_manager.js +25 -7
  70. package/src/phaser/display/webgl/filter_texture.js +21 -22
  71. package/src/phaser/display/webgl/graphics.js +5 -40
  72. package/src/phaser/display/webgl/graphics_data.js +10 -7
  73. package/src/phaser/display/webgl/mask_manager.js +0 -8
  74. package/src/phaser/display/webgl/render_texture.js +33 -21
  75. package/src/phaser/display/webgl/renderer.js +38 -11
  76. package/src/phaser/display/webgl/shader/complex.js +10 -6
  77. package/src/phaser/display/webgl/shader/fast.js +10 -6
  78. package/src/phaser/display/webgl/shader/normal.js +23 -32
  79. package/src/phaser/display/webgl/shader/primitive.js +10 -6
  80. package/src/phaser/display/webgl/shader/strip.js +10 -6
  81. package/src/phaser/display/webgl/shader_manager.js +18 -6
  82. package/src/phaser/display/webgl/sprite_batch.js +41 -8
  83. package/src/phaser/display/webgl/stencil_manager.js +28 -6
  84. package/src/phaser/display/webgl/texture.js +28 -15
  85. package/src/phaser/display/webgl/texture_util.js +0 -8
  86. package/src/phaser/display/webgl/util.js +0 -11
  87. package/src/phaser/geom/circle.js +123 -19
  88. package/src/phaser/geom/ellipse.js +39 -19
  89. package/src/phaser/geom/line.js +148 -17
  90. package/src/phaser/geom/matrix.js +73 -7
  91. package/src/phaser/geom/point.js +152 -7
  92. package/src/phaser/geom/polygon.js +42 -14
  93. package/src/phaser/geom/rectangle.js +233 -7
  94. package/src/phaser/geom/rounded_rectangle.js +10 -7
  95. package/src/phaser/geom/util/circle.js +3 -16
  96. package/src/phaser/geom/util/ellipse.js +0 -8
  97. package/src/phaser/geom/util/line.js +5 -19
  98. package/src/phaser/geom/util/matrix.js +1 -10
  99. package/src/phaser/geom/util/point.js +0 -26
  100. package/src/phaser/geom/util/polygon.js +1 -8
  101. package/src/phaser/geom/util/rectangle.js +1 -23
  102. package/src/phaser/geom/util/rounded_rectangle.js +1 -8
  103. package/src/phaser/util/math.js +3 -43
  104. package/{types → typedefs}/global.d.ts +1 -1
  105. package/types/index.d.ts +2 -1
  106. package/types/index.d.ts.map +1 -1
  107. package/types/phaser/core/animation.d.ts +106 -5
  108. package/types/phaser/core/animation.d.ts.map +1 -1
  109. package/types/phaser/core/animation_manager.d.ts +88 -1
  110. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  111. package/types/phaser/core/animation_parser.d.ts +5 -6
  112. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  113. package/types/phaser/core/array_set.d.ts +53 -7
  114. package/types/phaser/core/array_set.d.ts.map +1 -1
  115. package/types/phaser/core/cache.d.ts +348 -58
  116. package/types/phaser/core/cache.d.ts.map +1 -1
  117. package/types/phaser/core/const.d.ts +143 -40
  118. package/types/phaser/core/const.d.ts.map +1 -1
  119. package/types/phaser/core/device.d.ts +2 -5
  120. package/types/phaser/core/device.d.ts.map +1 -1
  121. package/types/phaser/core/device_util.d.ts +1 -10
  122. package/types/phaser/core/device_util.d.ts.map +1 -1
  123. package/types/phaser/core/dom.d.ts +122 -3
  124. package/types/phaser/core/dom.d.ts.map +1 -1
  125. package/types/phaser/core/event_manager.d.ts +142 -15
  126. package/types/phaser/core/event_manager.d.ts.map +1 -1
  127. package/types/phaser/core/factory.d.ts +74 -7
  128. package/types/phaser/core/factory.d.ts.map +1 -1
  129. package/types/phaser/core/frame.d.ts +68 -26
  130. package/types/phaser/core/frame.d.ts.map +1 -1
  131. package/types/phaser/core/frame_data.d.ts +61 -9
  132. package/types/phaser/core/frame_data.d.ts.map +1 -1
  133. package/types/phaser/core/frame_util.d.ts +10 -10
  134. package/types/phaser/core/frame_util.d.ts.map +1 -1
  135. package/types/phaser/core/game.d.ts +54 -20
  136. package/types/phaser/core/game.d.ts.map +1 -1
  137. package/types/phaser/core/input.d.ts +132 -21
  138. package/types/phaser/core/input.d.ts.map +1 -1
  139. package/types/phaser/core/input_handler.d.ts +258 -25
  140. package/types/phaser/core/input_handler.d.ts.map +1 -1
  141. package/types/phaser/core/input_mouse.d.ts +59 -12
  142. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  143. package/types/phaser/core/input_mspointer.d.ts +49 -15
  144. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  145. package/types/phaser/core/input_pointer.d.ts +80 -4
  146. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  147. package/types/phaser/core/input_touch.d.ts +52 -15
  148. package/types/phaser/core/input_touch.d.ts.map +1 -1
  149. package/types/phaser/core/loader.d.ts +268 -23
  150. package/types/phaser/core/loader.d.ts.map +1 -1
  151. package/types/phaser/core/loader_parser.d.ts +0 -4
  152. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  153. package/types/phaser/core/raf.d.ts +17 -7
  154. package/types/phaser/core/raf.d.ts.map +1 -1
  155. package/types/phaser/core/scale_manager.d.ts +210 -15
  156. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  157. package/types/phaser/core/scene.d.ts +21 -5
  158. package/types/phaser/core/scene.d.ts.map +1 -1
  159. package/types/phaser/core/scene_manager.d.ts +90 -10
  160. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  161. package/types/phaser/core/signal.d.ts +95 -11
  162. package/types/phaser/core/signal.d.ts.map +1 -1
  163. package/types/phaser/core/signal_binding.d.ts +35 -6
  164. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  165. package/types/phaser/core/sound.d.ts +111 -14
  166. package/types/phaser/core/sound.d.ts.map +1 -1
  167. package/types/phaser/core/sound_manager.d.ts +94 -8
  168. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  169. package/types/phaser/core/sound_sprite.d.ts +22 -8
  170. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  171. package/types/phaser/core/stage.d.ts +32 -3
  172. package/types/phaser/core/stage.d.ts.map +1 -1
  173. package/types/phaser/core/time.d.ts +73 -6
  174. package/types/phaser/core/time.d.ts.map +1 -1
  175. package/types/phaser/core/timer.d.ts +103 -2
  176. package/types/phaser/core/timer.d.ts.map +1 -1
  177. package/types/phaser/core/timer_event.d.ts +11 -5
  178. package/types/phaser/core/timer_event.d.ts.map +1 -1
  179. package/types/phaser/core/tween.d.ts +123 -3
  180. package/types/phaser/core/tween.d.ts.map +1 -1
  181. package/types/phaser/core/tween_data.d.ts +42 -3
  182. package/types/phaser/core/tween_data.d.ts.map +1 -1
  183. package/types/phaser/core/tween_easing.d.ts +0 -36
  184. package/types/phaser/core/tween_easing.d.ts.map +1 -1
  185. package/types/phaser/core/tween_manager.d.ts +49 -2
  186. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  187. package/types/phaser/core/world.d.ts +9 -1
  188. package/types/phaser/core/world.d.ts.map +1 -1
  189. package/types/phaser/display/bitmap_text.d.ts +89 -12
  190. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  191. package/types/phaser/display/button.d.ts +68 -11
  192. package/types/phaser/display/button.d.ts.map +1 -1
  193. package/types/phaser/display/canvas/buffer.d.ts +21 -5
  194. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  195. package/types/phaser/display/canvas/graphics.d.ts +0 -3
  196. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  197. package/types/phaser/display/canvas/masker.d.ts +0 -2
  198. package/types/phaser/display/canvas/masker.d.ts.map +1 -1
  199. package/types/phaser/display/canvas/pool.d.ts +0 -13
  200. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  201. package/types/phaser/display/canvas/renderer.d.ts +30 -3
  202. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  203. package/types/phaser/display/canvas/tinter.d.ts +0 -5
  204. package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
  205. package/types/phaser/display/canvas/util.d.ts +0 -9
  206. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  207. package/types/phaser/display/display_object.d.ts +196 -9
  208. package/types/phaser/display/display_object.d.ts.map +1 -1
  209. package/types/phaser/display/graphics.d.ts +142 -16
  210. package/types/phaser/display/graphics.d.ts.map +1 -1
  211. package/types/phaser/display/graphics_data.d.ts +15 -1
  212. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  213. package/types/phaser/display/graphics_data_util.d.ts +3 -3
  214. package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
  215. package/types/phaser/display/group.d.ts +68 -6
  216. package/types/phaser/display/group.d.ts.map +1 -1
  217. package/types/phaser/display/image.d.ts +77 -15
  218. package/types/phaser/display/image.d.ts.map +1 -1
  219. package/types/phaser/display/sprite_batch.d.ts +4 -4
  220. package/types/phaser/display/sprite_batch.d.ts.map +1 -1
  221. package/types/phaser/display/sprite_util.d.ts +0 -5
  222. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  223. package/types/phaser/display/text.d.ts +373 -53
  224. package/types/phaser/display/text.d.ts.map +1 -1
  225. package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
  226. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  227. package/types/phaser/display/webgl/base_texture.d.ts +20 -1
  228. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  229. package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
  230. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  231. package/types/phaser/display/webgl/earcut.d.ts +0 -27
  232. package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
  233. package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
  234. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  235. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
  236. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  237. package/types/phaser/display/webgl/filter_manager.d.ts +23 -7
  238. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  239. package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
  240. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  241. package/types/phaser/display/webgl/graphics.d.ts +0 -12
  242. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  243. package/types/phaser/display/webgl/graphics_data.d.ts +12 -8
  244. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  245. package/types/phaser/display/webgl/mask_manager.d.ts +0 -2
  246. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  247. package/types/phaser/display/webgl/render_texture.d.ts +31 -4
  248. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  249. package/types/phaser/display/webgl/renderer.d.ts +42 -5
  250. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  251. package/types/phaser/display/webgl/shader/complex.d.ts +12 -2
  252. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  253. package/types/phaser/display/webgl/shader/fast.d.ts +12 -2
  254. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  255. package/types/phaser/display/webgl/shader/normal.d.ts +21 -1
  256. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  257. package/types/phaser/display/webgl/shader/primitive.d.ts +12 -2
  258. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  259. package/types/phaser/display/webgl/shader/strip.d.ts +12 -2
  260. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  261. package/types/phaser/display/webgl/shader_manager.d.ts +20 -5
  262. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  263. package/types/phaser/display/webgl/sprite_batch.d.ts +38 -1
  264. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  265. package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
  266. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  267. package/types/phaser/display/webgl/texture.d.ts +22 -1
  268. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
  269. package/types/phaser/display/webgl/texture_util.d.ts +0 -2
  270. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  271. package/types/phaser/display/webgl/util.d.ts +0 -10
  272. package/types/phaser/display/webgl/util.d.ts.map +1 -1
  273. package/types/phaser/geom/circle.d.ts +130 -10
  274. package/types/phaser/geom/circle.d.ts.map +1 -1
  275. package/types/phaser/geom/ellipse.d.ts +42 -6
  276. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  277. package/types/phaser/geom/line.d.ts +159 -14
  278. package/types/phaser/geom/line.d.ts.map +1 -1
  279. package/types/phaser/geom/matrix.d.ts +84 -12
  280. package/types/phaser/geom/matrix.d.ts.map +1 -1
  281. package/types/phaser/geom/point.d.ts +170 -19
  282. package/types/phaser/geom/point.d.ts.map +1 -1
  283. package/types/phaser/geom/polygon.d.ts +45 -5
  284. package/types/phaser/geom/polygon.d.ts.map +1 -1
  285. package/types/phaser/geom/rectangle.d.ts +253 -21
  286. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  287. package/types/phaser/geom/rounded_rectangle.d.ts +11 -2
  288. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  289. package/types/phaser/geom/util/circle.d.ts +3 -10
  290. package/types/phaser/geom/util/circle.d.ts.map +1 -1
  291. package/types/phaser/geom/util/ellipse.d.ts +0 -7
  292. package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
  293. package/types/phaser/geom/util/line.d.ts +5 -10
  294. package/types/phaser/geom/util/line.d.ts.map +1 -1
  295. package/types/phaser/geom/util/matrix.d.ts +0 -3
  296. package/types/phaser/geom/util/matrix.d.ts.map +1 -1
  297. package/types/phaser/geom/util/point.d.ts +0 -20
  298. package/types/phaser/geom/util/point.d.ts.map +1 -1
  299. package/types/phaser/geom/util/polygon.d.ts +0 -1
  300. package/types/phaser/geom/util/polygon.d.ts.map +1 -1
  301. package/types/phaser/geom/util/rectangle.d.ts +0 -16
  302. package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
  303. package/types/phaser/geom/util/rounded_rectangle.d.ts +0 -1
  304. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  305. package/types/phaser/util/math.d.ts +0 -27
  306. package/types/phaser/util/math.d.ts.map +1 -1
@@ -1,18 +1,11 @@
1
- /**
2
- * @module geom/ellipse
3
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
4
- * @author Andras Csizmadia <andras@vpmedia.hu>
5
- * @author Richard Davey <rich@photonstorm.com>
6
- */
7
1
  import { Point } from './point';
8
- import { Rectangle } from './rectangle';
2
+ import { Rectangle } from './rectangle';
9
3
  import { contains } from './util/ellipse';
10
4
  import { GEOM_ELLIPSE } from '../core/const';
11
5
 
12
6
  export class Ellipse {
13
7
  /**
14
8
  * TBD.
15
- *
16
9
  * @param {number} x - TBD.
17
10
  * @param {number} y - TBD.
18
11
  * @param {number} width - TBD.
@@ -26,6 +19,14 @@ export class Ellipse {
26
19
  this.type = GEOM_ELLIPSE;
27
20
  }
28
21
 
22
+ /**
23
+ * TBD.
24
+ * @param {number} x - TBD.
25
+ * @param {number} y - TBD.
26
+ * @param {number} width - TBD.
27
+ * @param {number} height - TBD.
28
+ * @returns {Ellipse} TBD.
29
+ */
29
30
  setTo(x, y, width, height) {
30
31
  this.x = x;
31
32
  this.y = y;
@@ -34,14 +35,28 @@ export class Ellipse {
34
35
  return this;
35
36
  }
36
37
 
38
+ /**
39
+ * TBD.
40
+ * @returns {Rectangle} TBD.
41
+ */
37
42
  getBounds() {
38
43
  return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
39
44
  }
40
45
 
46
+ /**
47
+ * TBD.
48
+ * @param {Ellipse} source - TBD.
49
+ * @returns {Ellipse} TBD.
50
+ */
41
51
  copyFrom(source) {
42
52
  return this.setTo(source.x, source.y, source.width, source.height);
43
53
  }
44
54
 
55
+ /**
56
+ * TBD.
57
+ * @param {Ellipse} dest - TBD.
58
+ * @returns {Ellipse} TBD.
59
+ */
45
60
  copyTo(dest) {
46
61
  dest.x = this.x;
47
62
  dest.y = this.y;
@@ -50,10 +65,21 @@ export class Ellipse {
50
65
  return dest;
51
66
  }
52
67
 
68
+ /**
69
+ * TBD.
70
+ * @param {number} x - TBD.
71
+ * @param {number} y - TBD.
72
+ * @returns {boolean} TBD.
73
+ */
53
74
  contains(x, y) {
54
75
  return contains(this, x, y);
55
76
  }
56
77
 
78
+ /**
79
+ * TBD.
80
+ * @param {Point} output - TBD.
81
+ * @returns {Point} TBD.
82
+ */
57
83
  random(output = null) {
58
84
  const result = output || new Point();
59
85
  const p = Math.random() * Math.PI * 2;
@@ -65,17 +91,11 @@ export class Ellipse {
65
91
  return result;
66
92
  }
67
93
 
94
+ /**
95
+ * TBD.
96
+ * @returns {string} TBD.
97
+ */
68
98
  toString() {
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
- );
99
+ return '[{Ellipse (x=' + this.x + ' y=' + this.y + ' width=' + this.width + ' height=' + this.height + ')}]';
80
100
  }
81
101
  }
@@ -1,9 +1,3 @@
1
- /**
2
- * @module geom/line
3
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
4
- * @author Andras Csizmadia <andras@vpmedia.hu>
5
- * @author Richard Davey <rich@photonstorm.com>
6
- */
7
1
  import { Point } from './point';
8
2
  import { clone, intersectsPoints, reflect } from './util/line';
9
3
  import { wrap } from '../util/math';
@@ -12,7 +6,6 @@ import { GEOM_LINE } from '../core/const';
12
6
  export class Line {
13
7
  /**
14
8
  * TBD.
15
- *
16
9
  * @param {number} x1 - TBD.
17
10
  * @param {number} y1 - TBD.
18
11
  * @param {number} x2 - TBD.
@@ -24,30 +17,54 @@ export class Line {
24
17
  this.type = GEOM_LINE;
25
18
  }
26
19
 
20
+ /**
21
+ * TBD.
22
+ * @param {number} x1 - TBD.
23
+ * @param {number} y1 - TBD.
24
+ * @param {number} x2 - TBD.
25
+ * @param {number} y2 - TBD.
26
+ * @returns {Line} TBD.
27
+ */
27
28
  setTo(x1, y1, x2, y2) {
28
29
  this.start.setTo(x1, y1);
29
30
  this.end.setTo(x2, y2);
30
31
  return this;
31
32
  }
32
33
 
34
+ /**
35
+ * TBD.
36
+ * @param {object} startSprite - TBD.
37
+ * @param {object} endSprite - TBD.
38
+ * @param {boolean} useCenter - TBD.
39
+ * @returns {Line} TBD.
40
+ */
33
41
  fromSprite(startSprite, endSprite, useCenter = false) {
34
42
  if (useCenter) {
35
- return this.setTo(
36
- startSprite.center.x,
37
- startSprite.center.y,
38
- endSprite.center.x,
39
- endSprite.center.y
40
- );
43
+ return this.setTo(startSprite.center.x, startSprite.center.y, endSprite.center.x, endSprite.center.y);
41
44
  }
42
45
  return this.setTo(startSprite.x, startSprite.y, endSprite.x, endSprite.y);
43
46
  }
44
47
 
48
+ /**
49
+ * TBD.
50
+ * @param {number} x - TBD.
51
+ * @param {number} y - TBD.
52
+ * @param {number} angle - TBD.
53
+ * @param {number} length - TBD.
54
+ * @returns {Line} TBD.
55
+ */
45
56
  fromAngle(x, y, angle, length) {
46
57
  this.start.setTo(x, y);
47
58
  this.end.setTo(x + Math.cos(angle) * length, y + Math.sin(angle) * length);
48
59
  return this;
49
60
  }
50
61
 
62
+ /**
63
+ * TBD.
64
+ * @param {number} angle - TBD.
65
+ * @param {boolean} asDegrees - TBD.
66
+ * @returns {Line} TBD.
67
+ */
51
68
  rotate(angle, asDegrees = false) {
52
69
  const cx = (this.start.x + this.end.x) / 2;
53
70
  const cy = (this.start.y + this.end.y) / 2;
@@ -56,20 +73,45 @@ export class Line {
56
73
  return this;
57
74
  }
58
75
 
76
+ /**
77
+ * TBD.
78
+ * @param {number} x - TBD.
79
+ * @param {number} y - TBD.
80
+ * @param {number} angle - TBD.
81
+ * @param {boolean} asDegrees - TBD.
82
+ * @returns {Line} TBD.
83
+ */
59
84
  rotateAround(x, y, angle, asDegrees = false) {
60
85
  this.start.rotate(x, y, angle, asDegrees);
61
86
  this.end.rotate(x, y, angle, asDegrees);
62
87
  return this;
63
88
  }
64
89
 
90
+ /**
91
+ * TBD.
92
+ * @param {Line} line - TBD.
93
+ * @param {boolean} asSegment - TBD.
94
+ * @param {Point} result - TBD.
95
+ * @returns {Point} TBD.
96
+ */
65
97
  intersects(line, asSegment, result) {
66
98
  return intersectsPoints(this.start, this.end, line.start, line.end, asSegment, result);
67
99
  }
68
100
 
101
+ /**
102
+ * TBD.
103
+ * @param {Line} line - TBD.
104
+ * @returns {number} TBD.
105
+ */
69
106
  reflect(line) {
70
107
  return reflect(this, line);
71
108
  }
72
109
 
110
+ /**
111
+ * TBD.
112
+ * @param {Point} output - TBD.
113
+ * @returns {Point} TBD.
114
+ */
73
115
  midPoint(output = null) {
74
116
  const result = output || new Point();
75
117
  result.x = (this.start.x + this.end.x) / 2;
@@ -77,6 +119,11 @@ export class Line {
77
119
  return result;
78
120
  }
79
121
 
122
+ /**
123
+ * TBD.
124
+ * @param {number} x - TBD.
125
+ * @param {number} y - TBD.
126
+ */
80
127
  centerOn(x, y) {
81
128
  const cx = (this.start.x + this.end.x) / 2;
82
129
  const cy = (this.start.y + this.end.y) / 2;
@@ -86,13 +133,22 @@ export class Line {
86
133
  this.end.add(tx, ty);
87
134
  }
88
135
 
136
+ /**
137
+ * TBD.
138
+ * @param {number} x - TBD.
139
+ * @param {number} y - TBD.
140
+ * @returns {boolean} TBD.
141
+ */
89
142
  pointOnLine(x, 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
- );
143
+ return (x - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (y - this.start.y);
94
144
  }
95
145
 
146
+ /**
147
+ * TBD.
148
+ * @param {number} x - TBD.
149
+ * @param {number} y - TBD.
150
+ * @returns {boolean} TBD.
151
+ */
96
152
  pointOnSegment(x, y) {
97
153
  const xMin = Math.min(this.start.x, this.end.x);
98
154
  const xMax = Math.max(this.start.x, this.end.x);
@@ -101,6 +157,11 @@ export class Line {
101
157
  return this.pointOnLine(x, y) && x >= xMin && x <= xMax && y >= yMin && y <= yMax;
102
158
  }
103
159
 
160
+ /**
161
+ * TBD.
162
+ * @param {Point} output - TBD.
163
+ * @returns {Point} TBD.
164
+ */
104
165
  random(output = null) {
105
166
  const result = output || new Point();
106
167
  const t = Math.random();
@@ -109,6 +170,12 @@ export class Line {
109
170
  return result;
110
171
  }
111
172
 
173
+ /**
174
+ * TBD.
175
+ * @param {number} stepRate - TBD.
176
+ * @param {number[][]} results - TBD.
177
+ * @returns {number[][]} TBD.
178
+ */
112
179
  coordinatesOnLine(stepRate = 1, results = []) {
113
180
  let x1 = Math.round(this.start.x);
114
181
  let y1 = Math.round(this.start.y);
@@ -139,10 +206,18 @@ export class Line {
139
206
  return results;
140
207
  }
141
208
 
209
+ /**
210
+ * TBD.
211
+ * @returns {Line} TBD.
212
+ */
142
213
  clone() {
143
214
  return clone(this);
144
215
  }
145
216
 
217
+ /**
218
+ * TBD.
219
+ * @returns {number} TBD.
220
+ */
146
221
  get length() {
147
222
  return Math.sqrt(
148
223
  (this.end.x - this.start.x) * (this.end.x - this.start.x) +
@@ -150,58 +225,114 @@ export class Line {
150
225
  );
151
226
  }
152
227
 
228
+ /**
229
+ * TBD.
230
+ * @returns {number} TBD.
231
+ */
153
232
  get angle() {
154
233
  return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x);
155
234
  }
156
235
 
236
+ /**
237
+ * TBD.
238
+ * @returns {number} TBD.
239
+ */
157
240
  get slope() {
158
241
  return (this.end.y - this.start.y) / (this.end.x - this.start.x);
159
242
  }
160
243
 
244
+ /**
245
+ * TBD.
246
+ * @returns {number} TBD.
247
+ */
161
248
  get perpSlope() {
162
249
  return -((this.end.x - this.start.x) / (this.end.y - this.start.y));
163
250
  }
164
251
 
252
+ /**
253
+ * TBD.
254
+ * @returns {number} TBD.
255
+ */
165
256
  get x() {
166
257
  return Math.min(this.start.x, this.end.x);
167
258
  }
168
259
 
260
+ /**
261
+ * TBD.
262
+ * @returns {number} TBD.
263
+ */
169
264
  get y() {
170
265
  return Math.min(this.start.y, this.end.y);
171
266
  }
172
267
 
268
+ /**
269
+ * TBD.
270
+ * @returns {number} TBD.
271
+ */
173
272
  get left() {
174
273
  return Math.min(this.start.x, this.end.x);
175
274
  }
176
275
 
276
+ /**
277
+ * TBD.
278
+ * @returns {number} TBD.
279
+ */
177
280
  get right() {
178
281
  return Math.max(this.start.x, this.end.x);
179
282
  }
180
283
 
284
+ /**
285
+ * TBD.
286
+ * @returns {number} TBD.
287
+ */
181
288
  get top() {
182
289
  return Math.min(this.start.y, this.end.y);
183
290
  }
184
291
 
292
+ /**
293
+ * TBD.
294
+ * @returns {number} TBD.
295
+ */
185
296
  get bottom() {
186
297
  return Math.max(this.start.y, this.end.y);
187
298
  }
188
299
 
300
+ /**
301
+ * TBD.
302
+ * @returns {number} TBD.
303
+ */
189
304
  get width() {
190
305
  return Math.abs(this.start.x - this.end.x);
191
306
  }
192
307
 
308
+ /**
309
+ * TBD.
310
+ * @returns {number} TBD.
311
+ */
193
312
  get height() {
194
313
  return Math.abs(this.start.y - this.end.y);
195
314
  }
196
315
 
316
+ /**
317
+ * TBD.
318
+ * @returns {number} TBD.
319
+ */
197
320
  get normalX() {
198
321
  return Math.cos(this.angle - 1.5707963267948966);
199
322
  }
200
323
 
324
+ /**
325
+ * TBD.
326
+ * @returns {number} TBD.
327
+ */
201
328
  get normalY() {
202
329
  return Math.sin(this.angle - 1.5707963267948966);
203
330
  }
204
331
 
332
+ /**
333
+ * TBD.
334
+ * @returns {number} TBD.
335
+ */
205
336
  get normalAngle() {
206
337
  return wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI);
207
338
  }
@@ -1,9 +1,3 @@
1
- /**
2
- * @module geom/matrix
3
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
4
- * @author Andras Csizmadia <andras@vpmedia.hu>
5
- * @author Richard Davey <rich@photonstorm.com>
6
- */
7
1
  import { Point } from './point';
8
2
  import { clone } from './util/matrix';
9
3
  import { GEOM_MATRIX } from '../core/const';
@@ -11,7 +5,6 @@ import { GEOM_MATRIX } from '../core/const';
11
5
  export class Matrix {
12
6
  /**
13
7
  * TBD.
14
- *
15
8
  * @param {number} a - TBD.
16
9
  * @param {number} b - TBD.
17
10
  * @param {number} c - TBD.
@@ -29,10 +22,25 @@ export class Matrix {
29
22
  this.type = GEOM_MATRIX;
30
23
  }
31
24
 
25
+ /**
26
+ * TBD.
27
+ * @param {number[]} array - TBD.
28
+ * @returns {Matrix} TBD.
29
+ */
32
30
  fromArray(array) {
33
31
  return this.setTo(array[0], array[1], array[3], array[4], array[2], array[5]);
34
32
  }
35
33
 
34
+ /**
35
+ * TBD.
36
+ * @param {number} a - TBD.
37
+ * @param {number} b - TBD.
38
+ * @param {number} c - TBD.
39
+ * @param {number} d - TBD.
40
+ * @param {number} tx - TBD.
41
+ * @param {number} ty - TBD.
42
+ * @returns {Matrix} TBD.
43
+ */
36
44
  setTo(a, b, c, d, tx, ty) {
37
45
  this.a = a;
38
46
  this.b = b;
@@ -43,15 +51,29 @@ export class Matrix {
43
51
  return this;
44
52
  }
45
53
 
54
+ /**
55
+ * TBD.
56
+ * @returns {Matrix} TBD.
57
+ */
46
58
  clone() {
47
59
  return clone(this);
48
60
  }
49
61
 
62
+ /**
63
+ * TBD.
64
+ * @param {Matrix} matrix - TBD.
65
+ * @returns {Matrix} TBD.
66
+ */
50
67
  copyTo(matrix) {
51
68
  matrix.copyFrom(this);
52
69
  return matrix;
53
70
  }
54
71
 
72
+ /**
73
+ * TBD.
74
+ * @param {Matrix} matrix - TBD.
75
+ * @returns {Matrix} TBD.
76
+ */
55
77
  copyFrom(matrix) {
56
78
  this.a = matrix.a;
57
79
  this.b = matrix.b;
@@ -62,6 +84,12 @@ export class Matrix {
62
84
  return this;
63
85
  }
64
86
 
87
+ /**
88
+ * TBD.
89
+ * @param {boolean} transpose - TBD.
90
+ * @param {Float32Array} output - TBD.
91
+ * @returns {Float32Array} TBD.
92
+ */
65
93
  toArray(transpose = false, output = null) {
66
94
  const result = output || new Float32Array(9);
67
95
  if (transpose) {
@@ -88,6 +116,12 @@ export class Matrix {
88
116
  return result;
89
117
  }
90
118
 
119
+ /**
120
+ * TBD.
121
+ * @param {Point} pos - TBD.
122
+ * @param {Point} output - TBD.
123
+ * @returns {Point} TBD.
124
+ */
91
125
  apply(pos, output = null) {
92
126
  const result = output || new Point();
93
127
  result.x = this.a * pos.x + this.c * pos.y + this.tx;
@@ -95,6 +129,12 @@ export class Matrix {
95
129
  return result;
96
130
  }
97
131
 
132
+ /**
133
+ * TBD.
134
+ * @param {Point} pos - TBD.
135
+ * @param {Point} output - TBD.
136
+ * @returns {Point} TBD.
137
+ */
98
138
  applyInverse(pos, output = null) {
99
139
  const result = output || new Point();
100
140
  const id = 1 / (this.a * this.d + this.c * -this.b);
@@ -105,12 +145,24 @@ export class Matrix {
105
145
  return result;
106
146
  }
107
147
 
148
+ /**
149
+ * TBD.
150
+ * @param {number} x - TBD.
151
+ * @param {number} y - TBD.
152
+ * @returns {Matrix} TBD.
153
+ */
108
154
  translate(x, y) {
109
155
  this.tx += x;
110
156
  this.ty += y;
111
157
  return this;
112
158
  }
113
159
 
160
+ /**
161
+ * TBD.
162
+ * @param {number} x - TBD.
163
+ * @param {number} y - TBD.
164
+ * @returns {Matrix} TBD.
165
+ */
114
166
  scale(x, y) {
115
167
  this.a *= x;
116
168
  this.d *= y;
@@ -121,6 +173,11 @@ export class Matrix {
121
173
  return this;
122
174
  }
123
175
 
176
+ /**
177
+ * TBD.
178
+ * @param {number} angle - TBD.
179
+ * @returns {Matrix} TBD.
180
+ */
124
181
  rotate(angle) {
125
182
  const cos = Math.cos(angle);
126
183
  const sin = Math.sin(angle);
@@ -136,6 +193,11 @@ export class Matrix {
136
193
  return this;
137
194
  }
138
195
 
196
+ /**
197
+ * TBD.
198
+ * @param {Matrix} matrix - TBD.
199
+ * @returns {Matrix} TBD.
200
+ */
139
201
  append(matrix) {
140
202
  const a1 = this.a;
141
203
  const b1 = this.b;
@@ -150,6 +212,10 @@ export class Matrix {
150
212
  return this;
151
213
  }
152
214
 
215
+ /**
216
+ * TBD.
217
+ * @returns {Matrix} TBD.
218
+ */
153
219
  identity() {
154
220
  return this.setTo(1, 0, 0, 1, 0, 0);
155
221
  }