@vpmedia/phaser 1.15.0 → 1.17.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 (290) 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 +114 -6
  5. package/src/phaser/core/animation_manager.js +102 -10
  6. package/src/phaser/core/animation_parser.js +6 -19
  7. package/src/phaser/core/array_set.js +59 -5
  8. package/src/phaser/core/cache.js +307 -6
  9. package/src/phaser/core/const.js +107 -4
  10. package/src/phaser/core/device.js +3 -6
  11. package/src/phaser/core/device_util.js +3 -16
  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 -12
  18. package/src/phaser/core/game.js +35 -7
  19. package/src/phaser/core/input.js +133 -17
  20. package/src/phaser/core/input_handler.js +243 -43
  21. package/src/phaser/core/input_mouse.js +70 -5
  22. package/src/phaser/core/input_mspointer.js +40 -9
  23. package/src/phaser/core/input_pointer.js +88 -17
  24. package/src/phaser/core/input_touch.js +42 -5
  25. package/src/phaser/core/loader.js +303 -101
  26. package/src/phaser/core/loader_parser.js +2 -10
  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 -8
  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 +91 -10
  46. package/src/phaser/display/button.js +63 -12
  47. package/src/phaser/display/canvas/buffer.js +16 -6
  48. package/src/phaser/display/canvas/graphics.js +1 -13
  49. package/src/phaser/display/canvas/masker.js +0 -6
  50. package/src/phaser/display/canvas/pool.js +0 -7
  51. package/src/phaser/display/canvas/renderer.js +28 -8
  52. package/src/phaser/display/canvas/tinter.js +4 -43
  53. package/src/phaser/display/canvas/util.js +0 -6
  54. package/src/phaser/display/display_object.js +192 -20
  55. package/src/phaser/display/graphics.js +161 -26
  56. package/src/phaser/display/graphics_data.js +14 -6
  57. package/src/phaser/display/graphics_data_util.js +2 -8
  58. package/src/phaser/display/group.js +82 -9
  59. package/src/phaser/display/image.js +87 -9
  60. package/src/phaser/display/sprite_batch.js +3 -8
  61. package/src/phaser/display/sprite_util.js +3 -23
  62. package/src/phaser/display/text.js +331 -31
  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 -23
  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 -28
  72. package/src/phaser/display/webgl/graphics_data.js +10 -7
  73. package/src/phaser/display/webgl/mask_manager.js +0 -6
  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 -6
  86. package/src/phaser/display/webgl/util.js +0 -7
  87. package/src/phaser/geom/circle.js +123 -18
  88. package/src/phaser/geom/ellipse.js +39 -18
  89. package/src/phaser/geom/line.js +148 -16
  90. package/src/phaser/geom/matrix.js +73 -6
  91. package/src/phaser/geom/point.js +152 -6
  92. package/src/phaser/geom/polygon.js +42 -14
  93. package/src/phaser/geom/rectangle.js +233 -6
  94. package/src/phaser/geom/rounded_rectangle.js +10 -6
  95. package/src/phaser/geom/util/circle.js +3 -9
  96. package/src/phaser/geom/util/ellipse.js +0 -7
  97. package/src/phaser/geom/util/line.js +5 -14
  98. package/src/phaser/geom/util/matrix.js +1 -7
  99. package/src/phaser/geom/util/point.js +0 -6
  100. package/src/phaser/geom/util/polygon.js +1 -7
  101. package/src/phaser/geom/util/rectangle.js +1 -7
  102. package/src/phaser/geom/util/rounded_rectangle.js +1 -7
  103. package/src/phaser/util/math.js +3 -21
  104. package/types/index.d.ts +2 -1
  105. package/types/index.d.ts.map +1 -1
  106. package/types/phaser/core/animation.d.ts +126 -13
  107. package/types/phaser/core/animation.d.ts.map +1 -1
  108. package/types/phaser/core/animation_manager.d.ts +121 -19
  109. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  110. package/types/phaser/core/animation_parser.d.ts +6 -5
  111. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  112. package/types/phaser/core/array_set.d.ts +67 -13
  113. package/types/phaser/core/array_set.d.ts.map +1 -1
  114. package/types/phaser/core/cache.d.ts +365 -69
  115. package/types/phaser/core/cache.d.ts.map +1 -1
  116. package/types/phaser/core/const.d.ts +143 -40
  117. package/types/phaser/core/const.d.ts.map +1 -1
  118. package/types/phaser/core/device.d.ts +0 -5
  119. package/types/phaser/core/device.d.ts.map +1 -1
  120. package/types/phaser/core/device_util.d.ts +1 -1
  121. package/types/phaser/core/device_util.d.ts.map +1 -1
  122. package/types/phaser/core/dom.d.ts +119 -0
  123. package/types/phaser/core/dom.d.ts.map +1 -1
  124. package/types/phaser/core/event_manager.d.ts +127 -0
  125. package/types/phaser/core/event_manager.d.ts.map +1 -1
  126. package/types/phaser/core/factory.d.ts +75 -8
  127. package/types/phaser/core/factory.d.ts.map +1 -1
  128. package/types/phaser/core/frame.d.ts +64 -21
  129. package/types/phaser/core/frame.d.ts.map +1 -1
  130. package/types/phaser/core/frame_data.d.ts +61 -9
  131. package/types/phaser/core/frame_data.d.ts.map +1 -1
  132. package/types/phaser/core/frame_util.d.ts +10 -8
  133. package/types/phaser/core/frame_util.d.ts.map +1 -1
  134. package/types/phaser/core/game.d.ts +40 -6
  135. package/types/phaser/core/game.d.ts.map +1 -1
  136. package/types/phaser/core/input.d.ts +143 -15
  137. package/types/phaser/core/input.d.ts.map +1 -1
  138. package/types/phaser/core/input_handler.d.ts +258 -25
  139. package/types/phaser/core/input_handler.d.ts.map +1 -1
  140. package/types/phaser/core/input_mouse.d.ts +62 -14
  141. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  142. package/types/phaser/core/input_mspointer.d.ts +51 -17
  143. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  144. package/types/phaser/core/input_pointer.d.ts +99 -14
  145. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  146. package/types/phaser/core/input_touch.d.ts +53 -16
  147. package/types/phaser/core/input_touch.d.ts.map +1 -1
  148. package/types/phaser/core/loader.d.ts +299 -28
  149. package/types/phaser/core/loader.d.ts.map +1 -1
  150. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  151. package/types/phaser/core/raf.d.ts +19 -9
  152. package/types/phaser/core/raf.d.ts.map +1 -1
  153. package/types/phaser/core/scale_manager.d.ts +208 -13
  154. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  155. package/types/phaser/core/scene.d.ts +21 -5
  156. package/types/phaser/core/scene.d.ts.map +1 -1
  157. package/types/phaser/core/scene_manager.d.ts +90 -10
  158. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  159. package/types/phaser/core/signal.d.ts +93 -9
  160. package/types/phaser/core/signal.d.ts.map +1 -1
  161. package/types/phaser/core/signal_binding.d.ts +34 -5
  162. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  163. package/types/phaser/core/sound.d.ts +111 -14
  164. package/types/phaser/core/sound.d.ts.map +1 -1
  165. package/types/phaser/core/sound_manager.d.ts +97 -11
  166. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  167. package/types/phaser/core/sound_sprite.d.ts +22 -8
  168. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  169. package/types/phaser/core/stage.d.ts +32 -3
  170. package/types/phaser/core/stage.d.ts.map +1 -1
  171. package/types/phaser/core/time.d.ts +73 -6
  172. package/types/phaser/core/time.d.ts.map +1 -1
  173. package/types/phaser/core/timer.d.ts +108 -7
  174. package/types/phaser/core/timer.d.ts.map +1 -1
  175. package/types/phaser/core/timer_event.d.ts +13 -7
  176. package/types/phaser/core/timer_event.d.ts.map +1 -1
  177. package/types/phaser/core/tween.d.ts +124 -4
  178. package/types/phaser/core/tween.d.ts.map +1 -1
  179. package/types/phaser/core/tween_data.d.ts +41 -2
  180. package/types/phaser/core/tween_data.d.ts.map +1 -1
  181. package/types/phaser/core/tween_easing.d.ts +0 -5
  182. package/types/phaser/core/tween_easing.d.ts.map +1 -1
  183. package/types/phaser/core/tween_manager.d.ts +49 -2
  184. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  185. package/types/phaser/core/world.d.ts +9 -1
  186. package/types/phaser/core/world.d.ts.map +1 -1
  187. package/types/phaser/display/bitmap_text.d.ts +84 -7
  188. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  189. package/types/phaser/display/button.d.ts +65 -8
  190. package/types/phaser/display/button.d.ts.map +1 -1
  191. package/types/phaser/display/canvas/buffer.d.ts +20 -4
  192. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  193. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  194. package/types/phaser/display/canvas/masker.d.ts.map +1 -1
  195. package/types/phaser/display/canvas/pool.d.ts +0 -6
  196. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  197. package/types/phaser/display/canvas/renderer.d.ts +29 -2
  198. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  199. package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
  200. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  201. package/types/phaser/display/display_object.d.ts +195 -8
  202. package/types/phaser/display/display_object.d.ts.map +1 -1
  203. package/types/phaser/display/graphics.d.ts +132 -6
  204. package/types/phaser/display/graphics.d.ts.map +1 -1
  205. package/types/phaser/display/graphics_data.d.ts +15 -1
  206. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  207. package/types/phaser/display/graphics_data_util.d.ts +3 -2
  208. package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
  209. package/types/phaser/display/group.d.ts +80 -10
  210. package/types/phaser/display/group.d.ts.map +1 -1
  211. package/types/phaser/display/image.d.ts +72 -6
  212. package/types/phaser/display/image.d.ts.map +1 -1
  213. package/types/phaser/display/sprite_batch.d.ts +4 -3
  214. package/types/phaser/display/sprite_batch.d.ts.map +1 -1
  215. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  216. package/types/phaser/display/text.d.ts +366 -46
  217. package/types/phaser/display/text.d.ts.map +1 -1
  218. package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
  219. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  220. package/types/phaser/display/webgl/base_texture.d.ts +20 -1
  221. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  222. package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
  223. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  224. package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
  225. package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
  226. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  227. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
  228. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  229. package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
  230. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  231. package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
  232. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  233. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  234. package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
  235. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  236. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  237. package/types/phaser/display/webgl/render_texture.d.ts +30 -3
  238. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  239. package/types/phaser/display/webgl/renderer.d.ts +41 -4
  240. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  241. package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
  242. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  243. package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
  244. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  245. package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
  246. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  247. package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
  248. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  249. package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
  250. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  251. package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
  252. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  253. package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
  254. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  255. package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
  256. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  257. package/types/phaser/display/webgl/texture.d.ts +21 -0
  258. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
  259. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  260. package/types/phaser/display/webgl/util.d.ts +0 -6
  261. package/types/phaser/display/webgl/util.d.ts.map +1 -1
  262. package/types/phaser/geom/circle.d.ts +131 -9
  263. package/types/phaser/geom/circle.d.ts.map +1 -1
  264. package/types/phaser/geom/ellipse.d.ts +43 -5
  265. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  266. package/types/phaser/geom/line.d.ts +159 -13
  267. package/types/phaser/geom/line.d.ts.map +1 -1
  268. package/types/phaser/geom/matrix.d.ts +85 -11
  269. package/types/phaser/geom/matrix.d.ts.map +1 -1
  270. package/types/phaser/geom/point.d.ts +170 -18
  271. package/types/phaser/geom/point.d.ts.map +1 -1
  272. package/types/phaser/geom/polygon.d.ts +45 -5
  273. package/types/phaser/geom/polygon.d.ts.map +1 -1
  274. package/types/phaser/geom/rectangle.d.ts +253 -20
  275. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  276. package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
  277. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  278. package/types/phaser/geom/util/circle.d.ts +3 -3
  279. package/types/phaser/geom/util/circle.d.ts.map +1 -1
  280. package/types/phaser/geom/util/ellipse.d.ts +0 -6
  281. package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
  282. package/types/phaser/geom/util/line.d.ts +5 -5
  283. package/types/phaser/geom/util/line.d.ts.map +1 -1
  284. package/types/phaser/geom/util/matrix.d.ts.map +1 -1
  285. package/types/phaser/geom/util/point.d.ts.map +1 -1
  286. package/types/phaser/geom/util/polygon.d.ts.map +1 -1
  287. package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
  288. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  289. package/types/phaser/util/math.d.ts +0 -5
  290. package/types/phaser/util/math.d.ts.map +1 -1
@@ -1,13 +1,9 @@
1
- /**
2
- * @module display/webgl/texture
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
- * @author Mat Groves http://matgroves.com/ @Doormat23
7
- */
8
- import { Rectangle } from '../../geom/rectangle';
1
+ import { Rectangle } from '../../geom/rectangle';
9
2
 
10
3
  export class TextureUvs {
4
+ /**
5
+ * TBD.
6
+ */
11
7
  constructor() {
12
8
  this.x0 = 0;
13
9
  this.y0 = 0;
@@ -21,6 +17,13 @@ export class TextureUvs {
21
17
  }
22
18
 
23
19
  export class Texture {
20
+ /**
21
+ * TBD.
22
+ * @param baseTexture - TBD.
23
+ * @param frame - TBD.
24
+ * @param crop - TBD.
25
+ * @param trim - TBD.
26
+ */
24
27
  constructor(baseTexture, frame, crop, trim) {
25
28
  this.noFrame = false;
26
29
  if (!frame) {
@@ -49,6 +52,9 @@ export class Texture {
49
52
  }
50
53
  }
51
54
 
55
+ /**
56
+ * TBD.
57
+ */
52
58
  onBaseTextureLoaded() {
53
59
  if (this.noFrame) {
54
60
  this.frame = new Rectangle(0, 0, this.baseTexture.width, this.baseTexture.height);
@@ -56,6 +62,10 @@ export class Texture {
56
62
  this.setFrame(this.frame);
57
63
  }
58
64
 
65
+ /**
66
+ * TBD.
67
+ * @param destroyBase - TBD.
68
+ */
59
69
  destroy(destroyBase = false) {
60
70
  if (destroyBase) {
61
71
  this.baseTexture.destroy();
@@ -63,6 +73,10 @@ export class Texture {
63
73
  this.valid = false;
64
74
  }
65
75
 
76
+ /**
77
+ * TBD.
78
+ * @param frame - TBD.
79
+ */
66
80
  setFrame(frame) {
67
81
  this.noFrame = false;
68
82
  this.frame = frame;
@@ -74,23 +88,19 @@ export class Texture {
74
88
  this.crop.height = frame.height;
75
89
  if (
76
90
  !this.trim &&
77
- (frame.x + frame.width > this.baseTexture.width ||
78
- frame.y + frame.height > this.baseTexture.height)
91
+ (frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height)
79
92
  ) {
80
93
  // If `true` then `PIXI.Texture.setFrame` will no longer throw an error if the texture dimensions are incorrect.
81
94
  // Instead `Texture.valid` will be set to `false` (#1556)
82
95
  // TODO: make this configurable
83
96
  const isTextureSilentFail = true;
84
97
  if (!isTextureSilentFail) {
85
- throw new Error(
86
- 'Texture Error: frame does not fit inside the base Texture dimensions ' + this
87
- );
98
+ throw new Error('Texture Error: frame does not fit inside the base Texture dimensions ' + this);
88
99
  }
89
100
  this.valid = false;
90
101
  return;
91
102
  }
92
- this.valid =
93
- frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded;
103
+ this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded;
94
104
  if (this.trim) {
95
105
  this.width = this.trim.width;
96
106
  this.height = this.trim.height;
@@ -102,6 +112,9 @@ export class Texture {
102
112
  }
103
113
  }
104
114
 
115
+ /**
116
+ * TBD.
117
+ */
105
118
  _updateUvs() {
106
119
  if (!this._uvs) {
107
120
  this._uvs = new TextureUvs();
@@ -1,9 +1,3 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
1
  import { BaseTexture } from './base_texture';
8
2
  import { Texture } from './texture';
9
3
 
@@ -1,10 +1,3 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- * @author Mat Groves http://matgroves.com/ @Doormat23
6
- */
7
-
8
1
  /**
9
2
  * TBD.
10
3
  */
@@ -1,11 +1,5 @@
1
- /**
2
- * @module geom/circle
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 { distance } from '../util/math';
10
4
  import { clone, contains, circumferencePoint } from './util/circle';
11
5
  import { GEOM_CIRCLE } from '../core/const';
@@ -28,10 +22,19 @@ export class Circle {
28
22
  this.type = GEOM_CIRCLE;
29
23
  }
30
24
 
25
+ /**
26
+ * TBD.
27
+ * @returns {number} TBD.
28
+ */
31
29
  circumference() {
32
30
  return 2 * (Math.PI * this._radius);
33
31
  }
34
32
 
33
+ /**
34
+ * TBD.
35
+ * @param {Point} output - TBD.
36
+ * @returns {Point} TBD.
37
+ */
35
38
  random(output = null) {
36
39
  const result = output || new Point();
37
40
  const t = 2 * Math.PI * Math.random();
@@ -44,10 +47,21 @@ export class Circle {
44
47
  return result;
45
48
  }
46
49
 
50
+ /**
51
+ * TBD.
52
+ * @returns {Rectangle} TBD.
53
+ */
47
54
  getBounds() {
48
55
  return new Rectangle(this.x - this.radius, this.y - this.radius, this.diameter, this.diameter);
49
56
  }
50
57
 
58
+ /**
59
+ * TBD.
60
+ * @param {number} x - TBD.
61
+ * @param {number} y - TBD.
62
+ * @param {number} diameter - TBD.
63
+ * @returns {Circle} TBD.
64
+ */
51
65
  setTo(x, y, diameter) {
52
66
  this.x = x;
53
67
  this.y = y;
@@ -56,10 +70,20 @@ export class Circle {
56
70
  return this;
57
71
  }
58
72
 
73
+ /**
74
+ * TBD.
75
+ * @param {Circle} source - TBD.
76
+ * @returns {Circle} TBD.
77
+ */
59
78
  copyFrom(source) {
60
79
  return this.setTo(source.x, source.y, source.diameter);
61
80
  }
62
81
 
82
+ /**
83
+ * TBD.
84
+ * @param {Circle} dest - TBD.
85
+ * @returns {Circle} TBD.
86
+ */
63
87
  copyTo(dest) {
64
88
  dest.x = this.x;
65
89
  dest.y = this.y;
@@ -67,51 +91,86 @@ export class Circle {
67
91
  return dest;
68
92
  }
69
93
 
94
+ /**
95
+ * TBD.
96
+ * @param {Circle} dest - TBD.
97
+ * @param {boolean} round - TBD.
98
+ * @returns {number} TBD.
99
+ */
70
100
  distance(dest, round = false) {
71
101
  const d = distance(this.x, this.y, dest.x, dest.y);
72
102
  return round ? Math.round(d) : d;
73
103
  }
74
104
 
105
+ /**
106
+ * TBD.
107
+ * @returns {Circle} TBD.
108
+ */
75
109
  clone() {
76
110
  return clone(this);
77
111
  }
78
112
 
113
+ /**
114
+ * TBD.
115
+ * @param {number} x - TBD.
116
+ * @param {number} y - TBD.
117
+ * @returns {boolean} TBD.
118
+ */
79
119
  contains(x, y) {
80
120
  return contains(this, x, y);
81
121
  }
82
122
 
123
+ /**
124
+ * TBD.
125
+ * @param {number} angle - TBD.
126
+ * @param {boolean} asDegrees - TBD.
127
+ * @param {Point} out - TBD.
128
+ * @returns {Point} TBD.
129
+ */
83
130
  circumferencePoint(angle, asDegrees, out) {
84
131
  return circumferencePoint(this, angle, asDegrees, out);
85
132
  }
86
133
 
134
+ /**
135
+ * TBD.
136
+ * @param {number} dx - TBD.
137
+ * @param {number} dy - TBD.
138
+ * @returns {Circle} TBD.
139
+ */
87
140
  offset(dx, dy) {
88
141
  this.x += dx;
89
142
  this.y += dy;
90
143
  return this;
91
144
  }
92
145
 
146
+ /**
147
+ * TBD.
148
+ * @param {Point} point - TBD.
149
+ * @returns {Circle} TBD.
150
+ */
93
151
  offsetPoint(point) {
94
152
  return this.offset(point.x, point.y);
95
153
  }
96
154
 
155
+ /**
156
+ * TBD.
157
+ * @returns {string} TBD.
158
+ */
97
159
  toString() {
98
- return (
99
- '[{Circle (x=' +
100
- this.x +
101
- ' y=' +
102
- this.y +
103
- ' diameter=' +
104
- this.diameter +
105
- ' radius=' +
106
- this.radius +
107
- ')}]'
108
- );
160
+ return '[{Circle (x=' + this.x + ' y=' + this.y + ' diameter=' + this.diameter + ' radius=' + this.radius + ')}]';
109
161
  }
110
162
 
163
+ /**
164
+ * TBD.
165
+ * @returns {number} TBD.
166
+ */
111
167
  get diameter() {
112
168
  return this._diameter;
113
169
  }
114
170
 
171
+ /**
172
+ * TBD.
173
+ */
115
174
  set diameter(value) {
116
175
  if (value > 0) {
117
176
  this._diameter = value;
@@ -119,10 +178,17 @@ export class Circle {
119
178
  }
120
179
  }
121
180
 
181
+ /**
182
+ * TBD.
183
+ * @returns {number} TBD.
184
+ */
122
185
  get radius() {
123
186
  return this._radius;
124
187
  }
125
188
 
189
+ /**
190
+ * TBD.
191
+ */
126
192
  set radius(value) {
127
193
  if (value > 0) {
128
194
  this._radius = value;
@@ -130,10 +196,17 @@ export class Circle {
130
196
  }
131
197
  }
132
198
 
199
+ /**
200
+ * TBD.
201
+ * @returns {number} TBD.
202
+ */
133
203
  get left() {
134
204
  return this.x - this._radius;
135
205
  }
136
206
 
207
+ /**
208
+ * TBD.
209
+ */
137
210
  set left(value) {
138
211
  if (value > this.x) {
139
212
  this._radius = 0;
@@ -143,10 +216,17 @@ export class Circle {
143
216
  }
144
217
  }
145
218
 
219
+ /**
220
+ * TBD.
221
+ * @returns {number} TBD.
222
+ */
146
223
  get right() {
147
224
  return this.x + this._radius;
148
225
  }
149
226
 
227
+ /**
228
+ * TBD.
229
+ */
150
230
  set right(value) {
151
231
  if (value < this.x) {
152
232
  this._radius = 0;
@@ -156,10 +236,17 @@ export class Circle {
156
236
  }
157
237
  }
158
238
 
239
+ /**
240
+ * TBD.
241
+ * @returns {number} TBD.
242
+ */
159
243
  get top() {
160
244
  return this.y - this._radius;
161
245
  }
162
246
 
247
+ /**
248
+ * TBD.
249
+ */
163
250
  set top(value) {
164
251
  if (value > this.y) {
165
252
  this._radius = 0;
@@ -169,10 +256,17 @@ export class Circle {
169
256
  }
170
257
  }
171
258
 
259
+ /**
260
+ * TBD.
261
+ * @returns {number} TBD.
262
+ */
172
263
  get bottom() {
173
264
  return this.y + this._radius;
174
265
  }
175
266
 
267
+ /**
268
+ * TBD.
269
+ */
176
270
  set bottom(value) {
177
271
  if (value < this.y) {
178
272
  this._radius = 0;
@@ -182,6 +276,10 @@ export class Circle {
182
276
  }
183
277
  }
184
278
 
279
+ /**
280
+ * TBD.
281
+ * @returns {number} TBD.
282
+ */
185
283
  get area() {
186
284
  if (this._radius > 0) {
187
285
  return Math.PI * this._radius * this._radius;
@@ -189,10 +287,17 @@ export class Circle {
189
287
  return 0;
190
288
  }
191
289
 
290
+ /**
291
+ * TBD.
292
+ * @returns {boolean} TBD.
293
+ */
192
294
  get empty() {
193
295
  return this._diameter === 0;
194
296
  }
195
297
 
298
+ /**
299
+ * TBD.
300
+ */
196
301
  set empty(value) {
197
302
  if (value === true) {
198
303
  this.setTo(0, 0, 0);
@@ -1,11 +1,5 @@
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
 
@@ -25,6 +19,14 @@ export class Ellipse {
25
19
  this.type = GEOM_ELLIPSE;
26
20
  }
27
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
+ */
28
30
  setTo(x, y, width, height) {
29
31
  this.x = x;
30
32
  this.y = y;
@@ -33,14 +35,28 @@ export class Ellipse {
33
35
  return this;
34
36
  }
35
37
 
38
+ /**
39
+ * TBD.
40
+ * @returns {Rectangle} TBD.
41
+ */
36
42
  getBounds() {
37
43
  return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
38
44
  }
39
45
 
46
+ /**
47
+ * TBD.
48
+ * @param {Ellipse} source - TBD.
49
+ * @returns {Ellipse} TBD.
50
+ */
40
51
  copyFrom(source) {
41
52
  return this.setTo(source.x, source.y, source.width, source.height);
42
53
  }
43
54
 
55
+ /**
56
+ * TBD.
57
+ * @param {Ellipse} dest - TBD.
58
+ * @returns {Ellipse} TBD.
59
+ */
44
60
  copyTo(dest) {
45
61
  dest.x = this.x;
46
62
  dest.y = this.y;
@@ -49,10 +65,21 @@ export class Ellipse {
49
65
  return dest;
50
66
  }
51
67
 
68
+ /**
69
+ * TBD.
70
+ * @param {number} x - TBD.
71
+ * @param {number} y - TBD.
72
+ * @returns {boolean} TBD.
73
+ */
52
74
  contains(x, y) {
53
75
  return contains(this, x, y);
54
76
  }
55
77
 
78
+ /**
79
+ * TBD.
80
+ * @param {Point} output - TBD.
81
+ * @returns {Point} TBD.
82
+ */
56
83
  random(output = null) {
57
84
  const result = output || new Point();
58
85
  const p = Math.random() * Math.PI * 2;
@@ -64,17 +91,11 @@ export class Ellipse {
64
91
  return result;
65
92
  }
66
93
 
94
+ /**
95
+ * TBD.
96
+ * @returns {string} TBD.
97
+ */
67
98
  toString() {
68
- return (
69
- '[{Ellipse (x=' +
70
- this.x +
71
- ' y=' +
72
- this.y +
73
- ' width=' +
74
- this.width +
75
- ' height=' +
76
- this.height +
77
- ')}]'
78
- );
99
+ return '[{Ellipse (x=' + this.x + ' y=' + this.y + ' width=' + this.width + ' height=' + this.height + ')}]';
79
100
  }
80
101
  }