@tsparticles/engine 3.9.1 → 4.0.0-alpha.1

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 (431) hide show
  1. package/638.min.js +2 -0
  2. package/638.min.js.LICENSE.txt +1 -0
  3. package/browser/Core/Canvas.js +126 -181
  4. package/browser/Core/Container.js +22 -18
  5. package/browser/Core/Engine.js +64 -54
  6. package/browser/Core/Particle.js +43 -48
  7. package/browser/Core/Particles.js +33 -24
  8. package/browser/Core/Retina.js +2 -3
  9. package/browser/Core/Utils/Constants.js +2 -2
  10. package/browser/Core/Utils/EventListeners.js +74 -64
  11. package/browser/Core/Utils/QuadTree.js +1 -1
  12. package/browser/Core/Utils/Ranges.js +2 -2
  13. package/browser/Core/Utils/Vectors.js +15 -21
  14. package/browser/Options/Classes/AnimatableColor.js +3 -3
  15. package/browser/Options/Classes/AnimationOptions.js +1 -1
  16. package/browser/Options/Classes/ColorAnimation.js +1 -1
  17. package/browser/Options/Classes/Options.js +13 -10
  18. package/browser/Options/Classes/Particles/Move/Move.js +1 -4
  19. package/browser/Options/Classes/Particles/Move/MoveAngle.js +1 -1
  20. package/browser/Options/Classes/Particles/Move/MoveAttract.js +1 -1
  21. package/browser/Options/Classes/Particles/Move/MoveGravity.js +1 -1
  22. package/browser/Options/Classes/Particles/Move/Spin.js +1 -1
  23. package/browser/Options/Classes/Particles/ParticlesOptions.js +0 -6
  24. package/browser/Options/Classes/Particles/Stroke.js +1 -1
  25. package/browser/Options/Classes/ValueWithRandom.js +1 -1
  26. package/browser/Utils/CanvasUtils.js +65 -21
  27. package/browser/Utils/ColorUtils.js +61 -45
  28. package/browser/Utils/EventDispatcher.js +3 -1
  29. package/browser/Utils/LogUtils.js +22 -0
  30. package/browser/Utils/{NumberUtils.js → MathUtils.js} +14 -7
  31. package/browser/Utils/Utils.js +23 -125
  32. package/browser/bundle.js +3 -3
  33. package/browser/export-types.js +1 -99
  34. package/browser/exports.js +2 -9
  35. package/browser/index.js +3 -7
  36. package/browser/initEngine.js +4 -0
  37. package/cjs/Core/Canvas.js +136 -195
  38. package/cjs/Core/Container.js +57 -57
  39. package/cjs/Core/Engine.js +77 -71
  40. package/cjs/Core/Interfaces/Colors.js +1 -2
  41. package/cjs/Core/Interfaces/IBounds.js +1 -2
  42. package/cjs/Core/Interfaces/IBubbleParticleData.js +1 -2
  43. package/cjs/Core/Interfaces/ICircleBouncer.js +1 -2
  44. package/cjs/Core/Interfaces/IColorManager.js +1 -2
  45. package/cjs/Core/Interfaces/IContainerInteractivity.js +1 -2
  46. package/cjs/Core/Interfaces/IContainerPlugin.js +1 -2
  47. package/cjs/Core/Interfaces/ICoordinates.js +1 -2
  48. package/cjs/Core/Interfaces/IDelta.js +1 -2
  49. package/cjs/Core/Interfaces/IDimension.js +1 -2
  50. package/cjs/Core/Interfaces/IDistance.js +1 -2
  51. package/cjs/Core/Interfaces/IDrawParticleParams.js +1 -2
  52. package/cjs/Core/Interfaces/IEffectDrawer.js +1 -2
  53. package/cjs/Core/Interfaces/IExternalInteractor.js +1 -2
  54. package/cjs/Core/Interfaces/IInteractor.js +1 -2
  55. package/cjs/Core/Interfaces/ILoadParams.js +1 -2
  56. package/cjs/Core/Interfaces/IMouseData.js +1 -2
  57. package/cjs/Core/Interfaces/IMovePathGenerator.js +1 -2
  58. package/cjs/Core/Interfaces/IParticleColorStyle.js +1 -2
  59. package/cjs/Core/Interfaces/IParticleHslAnimation.js +1 -2
  60. package/cjs/Core/Interfaces/IParticleLife.js +1 -2
  61. package/cjs/Core/Interfaces/IParticleMover.js +1 -2
  62. package/cjs/Core/Interfaces/IParticleRetinaProps.js +1 -2
  63. package/cjs/Core/Interfaces/IParticleRoll.js +1 -2
  64. package/cjs/Core/Interfaces/IParticleTransformValues.js +1 -2
  65. package/cjs/Core/Interfaces/IParticleUpdater.js +1 -2
  66. package/cjs/Core/Interfaces/IParticleValueAnimation.js +1 -2
  67. package/cjs/Core/Interfaces/IParticlesInteractor.js +1 -2
  68. package/cjs/Core/Interfaces/IPlugin.js +1 -2
  69. package/cjs/Core/Interfaces/IPositionFromSizeParams.js +1 -2
  70. package/cjs/Core/Interfaces/IRangeValue.js +1 -2
  71. package/cjs/Core/Interfaces/IShapeDrawData.js +1 -2
  72. package/cjs/Core/Interfaces/IShapeDrawer.js +1 -2
  73. package/cjs/Core/Interfaces/IShapeValues.js +1 -2
  74. package/cjs/Core/Interfaces/ISlowParticleData.js +1 -2
  75. package/cjs/Core/Particle.js +99 -108
  76. package/cjs/Core/Particles.js +63 -58
  77. package/cjs/Core/Retina.js +13 -18
  78. package/cjs/Core/Utils/Constants.js +3 -7
  79. package/cjs/Core/Utils/EventListeners.js +94 -88
  80. package/cjs/Core/Utils/ExternalInteractorBase.js +3 -7
  81. package/cjs/Core/Utils/InteractionManager.js +4 -8
  82. package/cjs/Core/Utils/ParticlesInteractorBase.js +3 -7
  83. package/cjs/Core/Utils/Point.js +1 -5
  84. package/cjs/Core/Utils/QuadTree.js +10 -14
  85. package/cjs/Core/Utils/Ranges.js +14 -20
  86. package/cjs/Core/Utils/Vectors.js +24 -35
  87. package/cjs/Enums/AnimationStatus.js +2 -5
  88. package/cjs/Enums/Directions/MoveDirection.js +2 -5
  89. package/cjs/Enums/Directions/OutModeDirection.js +2 -5
  90. package/cjs/Enums/Directions/RotateDirection.js +2 -5
  91. package/cjs/Enums/InteractivityDetect.js +2 -5
  92. package/cjs/Enums/Modes/AnimationMode.js +2 -5
  93. package/cjs/Enums/Modes/LimitMode.js +2 -5
  94. package/cjs/Enums/Modes/OutMode.js +2 -5
  95. package/cjs/Enums/Modes/PixelMode.js +2 -5
  96. package/cjs/Enums/Modes/ResponsiveMode.js +2 -5
  97. package/cjs/Enums/Modes/ThemeMode.js +2 -5
  98. package/cjs/Enums/Types/AlterType.js +2 -5
  99. package/cjs/Enums/Types/DestroyType.js +2 -5
  100. package/cjs/Enums/Types/DivType.js +2 -5
  101. package/cjs/Enums/Types/EasingType.js +2 -5
  102. package/cjs/Enums/Types/EventType.js +2 -5
  103. package/cjs/Enums/Types/GradientType.js +2 -5
  104. package/cjs/Enums/Types/InteractorType.js +2 -5
  105. package/cjs/Enums/Types/ParticleOutType.js +2 -5
  106. package/cjs/Enums/Types/StartValueType.js +2 -5
  107. package/cjs/Options/Classes/AnimatableColor.js +10 -14
  108. package/cjs/Options/Classes/AnimationOptions.js +14 -19
  109. package/cjs/Options/Classes/Background/Background.js +6 -10
  110. package/cjs/Options/Classes/ColorAnimation.js +6 -10
  111. package/cjs/Options/Classes/FullScreen/FullScreen.js +3 -7
  112. package/cjs/Options/Classes/HslAnimation.js +7 -11
  113. package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +3 -7
  114. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +5 -9
  115. package/cjs/Options/Classes/Interactivity/Events/Events.js +14 -18
  116. package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +5 -9
  117. package/cjs/Options/Classes/Interactivity/Events/Parallax.js +3 -7
  118. package/cjs/Options/Classes/Interactivity/Events/ResizeEvent.js +3 -7
  119. package/cjs/Options/Classes/Interactivity/Interactivity.js +9 -13
  120. package/cjs/Options/Classes/Interactivity/Modes/Modes.js +3 -7
  121. package/cjs/Options/Classes/ManualParticle.js +10 -14
  122. package/cjs/Options/Classes/Options.js +41 -42
  123. package/cjs/Options/Classes/OptionsColor.js +5 -9
  124. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +6 -10
  125. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +2 -6
  126. package/cjs/Options/Classes/Particles/Effect/Effect.js +5 -9
  127. package/cjs/Options/Classes/Particles/Move/Move.js +26 -33
  128. package/cjs/Options/Classes/Particles/Move/MoveAngle.js +6 -10
  129. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +5 -9
  130. package/cjs/Options/Classes/Particles/Move/MoveCenter.js +5 -9
  131. package/cjs/Options/Classes/Particles/Move/MoveGravity.js +6 -10
  132. package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -9
  133. package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +7 -11
  134. package/cjs/Options/Classes/Particles/Move/Spin.js +7 -11
  135. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -7
  136. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +7 -11
  137. package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +5 -9
  138. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +6 -10
  139. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +6 -10
  140. package/cjs/Options/Classes/Particles/ParticlesOptions.js +29 -39
  141. package/cjs/Options/Classes/Particles/Shape/Shape.js +5 -9
  142. package/cjs/Options/Classes/Particles/Size/Size.js +6 -10
  143. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +6 -10
  144. package/cjs/Options/Classes/Particles/Stroke.js +8 -12
  145. package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +4 -8
  146. package/cjs/Options/Classes/Responsive.js +13 -17
  147. package/cjs/Options/Classes/Theme/Theme.js +7 -11
  148. package/cjs/Options/Classes/Theme/ThemeDefault.js +5 -9
  149. package/cjs/Options/Classes/ValueWithRandom.js +12 -18
  150. package/cjs/Options/Interfaces/Background/IBackground.js +1 -2
  151. package/cjs/Options/Interfaces/FullScreen/IFullScreen.js +1 -2
  152. package/cjs/Options/Interfaces/IAnimatable.js +1 -2
  153. package/cjs/Options/Interfaces/IAnimatableColor.js +1 -2
  154. package/cjs/Options/Interfaces/IAnimation.js +1 -2
  155. package/cjs/Options/Interfaces/IColorAnimation.js +1 -2
  156. package/cjs/Options/Interfaces/IHslAnimation.js +1 -2
  157. package/cjs/Options/Interfaces/IManualParticle.js +1 -2
  158. package/cjs/Options/Interfaces/IOptionLoader.js +1 -2
  159. package/cjs/Options/Interfaces/IOptions.js +1 -2
  160. package/cjs/Options/Interfaces/IOptionsColor.js +1 -2
  161. package/cjs/Options/Interfaces/IResponsive.js +1 -2
  162. package/cjs/Options/Interfaces/IValueWithRandom.js +1 -2
  163. package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +1 -2
  164. package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +1 -2
  165. package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +1 -2
  166. package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +1 -2
  167. package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +1 -2
  168. package/cjs/Options/Interfaces/Interactivity/Events/IResizeEvent.js +1 -2
  169. package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +1 -2
  170. package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +1 -2
  171. package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +1 -2
  172. package/cjs/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +1 -2
  173. package/cjs/Options/Interfaces/Particles/Effect/IEffect.js +1 -2
  174. package/cjs/Options/Interfaces/Particles/IParticlesOptions.js +1 -2
  175. package/cjs/Options/Interfaces/Particles/IStroke.js +1 -2
  176. package/cjs/Options/Interfaces/Particles/Move/IMove.js +1 -2
  177. package/cjs/Options/Interfaces/Particles/Move/IMoveAngle.js +1 -2
  178. package/cjs/Options/Interfaces/Particles/Move/IMoveAttract.js +1 -2
  179. package/cjs/Options/Interfaces/Particles/Move/IMoveCenter.js +1 -2
  180. package/cjs/Options/Interfaces/Particles/Move/IMoveGravity.js +1 -2
  181. package/cjs/Options/Interfaces/Particles/Move/IOutModes.js +1 -2
  182. package/cjs/Options/Interfaces/Particles/Move/ISpin.js +1 -2
  183. package/cjs/Options/Interfaces/Particles/Move/Path/IMovePath.js +1 -2
  184. package/cjs/Options/Interfaces/Particles/Number/IParticlesDensity.js +1 -2
  185. package/cjs/Options/Interfaces/Particles/Number/IParticlesNumber.js +1 -2
  186. package/cjs/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +1 -2
  187. package/cjs/Options/Interfaces/Particles/Opacity/IOpacity.js +1 -2
  188. package/cjs/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +1 -2
  189. package/cjs/Options/Interfaces/Particles/Shape/IShape.js +1 -2
  190. package/cjs/Options/Interfaces/Particles/Size/ISize.js +1 -2
  191. package/cjs/Options/Interfaces/Particles/Size/ISizeAnimation.js +1 -2
  192. package/cjs/Options/Interfaces/Particles/ZIndex/IZIndex.js +1 -2
  193. package/cjs/Options/Interfaces/Theme/ITheme.js +1 -2
  194. package/cjs/Options/Interfaces/Theme/IThemeDefault.js +1 -2
  195. package/cjs/Types/CustomEventArgs.js +1 -2
  196. package/cjs/Types/CustomEventListener.js +1 -2
  197. package/cjs/Types/EasingFunction.js +1 -2
  198. package/cjs/Types/ExportResult.js +1 -2
  199. package/cjs/Types/ISourceOptions.js +1 -2
  200. package/cjs/Types/ParticlesGroups.js +1 -2
  201. package/cjs/Types/PathOptions.js +1 -2
  202. package/cjs/Types/RangeValue.js +1 -2
  203. package/cjs/Types/RecursivePartial.js +1 -2
  204. package/cjs/Types/ShapeData.js +1 -2
  205. package/cjs/Types/SingleOrMultiple.js +1 -2
  206. package/cjs/Utils/CanvasUtils.js +86 -55
  207. package/cjs/Utils/ColorUtils.js +136 -141
  208. package/cjs/Utils/EventDispatcher.js +8 -10
  209. package/cjs/Utils/LogUtils.js +22 -0
  210. package/{esm/Utils/NumberUtils.js → cjs/Utils/MathUtils.js} +14 -7
  211. package/cjs/Utils/OptionsUtils.js +4 -8
  212. package/cjs/Utils/TypeUtils.js +7 -16
  213. package/cjs/Utils/Utils.js +104 -239
  214. package/cjs/bundle.js +5 -22
  215. package/cjs/export-types.js +1 -115
  216. package/cjs/exports.js +77 -100
  217. package/cjs/index.js +5 -26
  218. package/cjs/initEngine.js +4 -0
  219. package/dist_browser_Core_Container_js.js +102 -0
  220. package/esm/Core/Canvas.js +126 -181
  221. package/esm/Core/Container.js +22 -18
  222. package/esm/Core/Engine.js +64 -54
  223. package/esm/Core/Particle.js +43 -48
  224. package/esm/Core/Particles.js +33 -24
  225. package/esm/Core/Retina.js +2 -3
  226. package/esm/Core/Utils/Constants.js +2 -2
  227. package/esm/Core/Utils/EventListeners.js +74 -64
  228. package/esm/Core/Utils/QuadTree.js +1 -1
  229. package/esm/Core/Utils/Ranges.js +2 -2
  230. package/esm/Core/Utils/Vectors.js +15 -21
  231. package/esm/Enums/RangeType.js +5 -0
  232. package/esm/Options/Classes/AnimatableColor.js +3 -3
  233. package/esm/Options/Classes/AnimationOptions.js +1 -1
  234. package/esm/Options/Classes/ColorAnimation.js +1 -1
  235. package/esm/Options/Classes/Options.js +13 -10
  236. package/esm/Options/Classes/Particles/Move/Move.js +1 -4
  237. package/esm/Options/Classes/Particles/Move/MoveAngle.js +1 -1
  238. package/esm/Options/Classes/Particles/Move/MoveAttract.js +1 -1
  239. package/esm/Options/Classes/Particles/Move/MoveGravity.js +1 -1
  240. package/esm/Options/Classes/Particles/Move/Spin.js +1 -1
  241. package/esm/Options/Classes/Particles/ParticlesOptions.js +0 -6
  242. package/esm/Options/Classes/Particles/Stroke.js +1 -1
  243. package/esm/Options/Classes/ValueWithRandom.js +1 -1
  244. package/esm/Utils/CanvasUtils.js +65 -21
  245. package/esm/Utils/ColorUtils.js +61 -45
  246. package/esm/Utils/EventDispatcher.js +3 -1
  247. package/esm/Utils/LogUtils.js +22 -0
  248. package/esm/Utils/MathUtils.js +158 -0
  249. package/esm/Utils/Utils.js +23 -125
  250. package/esm/bundle.js +3 -3
  251. package/esm/export-types.js +1 -99
  252. package/esm/exports.js +2 -9
  253. package/esm/index.js +3 -7
  254. package/esm/initEngine.js +4 -0
  255. package/package.json +3 -2
  256. package/report.html +5 -4
  257. package/scripts/install.js +204 -118
  258. package/tsparticles.engine.js +492 -451
  259. package/tsparticles.engine.min.js +1 -1
  260. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  261. package/types/Core/Canvas.d.ts +6 -9
  262. package/types/Core/Container.d.ts +1 -0
  263. package/types/Core/Engine.d.ts +20 -16
  264. package/types/Core/Interfaces/Colors.d.ts +46 -2
  265. package/types/Core/Interfaces/IColorManager.d.ts +1 -1
  266. package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -0
  267. package/types/Core/Interfaces/IDrawParticleParams.d.ts +0 -4
  268. package/types/Core/Interfaces/IEffectDrawer.d.ts +2 -1
  269. package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -0
  270. package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -0
  271. package/types/Core/Particle.d.ts +4 -5
  272. package/types/Core/Particles.d.ts +1 -1
  273. package/types/Core/Utils/Constants.d.ts +2 -2
  274. package/types/Core/Utils/EventListeners.d.ts +1 -0
  275. package/types/Core/Utils/Vectors.d.ts +3 -3
  276. package/types/Options/Classes/Options.d.ts +1 -2
  277. package/types/Options/Classes/OptionsColor.d.ts +2 -2
  278. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
  279. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -4
  280. package/types/Options/Interfaces/IOptions.d.ts +1 -2
  281. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -4
  282. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
  283. package/types/Utils/CanvasUtils.d.ts +4 -1
  284. package/types/Utils/ColorUtils.d.ts +2 -2
  285. package/types/Utils/LogUtils.d.ts +11 -0
  286. package/types/Utils/{NumberUtils.d.ts → MathUtils.d.ts} +2 -1
  287. package/types/Utils/TypeUtils.d.ts +2 -2
  288. package/types/Utils/Utils.d.ts +4 -16
  289. package/types/export-types.d.ts +91 -101
  290. package/types/exports.d.ts +2 -9
  291. package/types/index.d.ts +1 -1
  292. package/types/initEngine.d.ts +2 -0
  293. package/umd/Core/Canvas.js +123 -178
  294. package/umd/Core/Container.js +25 -21
  295. package/umd/Core/Engine.js +97 -53
  296. package/umd/Core/Particle.js +54 -59
  297. package/umd/Core/Particles.js +33 -24
  298. package/umd/Core/Retina.js +9 -10
  299. package/umd/Core/Utils/Constants.js +3 -3
  300. package/umd/Core/Utils/EventListeners.js +72 -62
  301. package/umd/Core/Utils/QuadTree.js +3 -3
  302. package/umd/Core/Utils/Ranges.js +4 -4
  303. package/umd/Core/Utils/Vectors.js +15 -21
  304. package/umd/Options/Classes/AnimatableColor.js +3 -3
  305. package/umd/Options/Classes/AnimationOptions.js +6 -6
  306. package/umd/Options/Classes/ColorAnimation.js +3 -3
  307. package/umd/Options/Classes/Options.js +16 -13
  308. package/umd/Options/Classes/Particles/Move/Move.js +5 -8
  309. package/umd/Options/Classes/Particles/Move/MoveAngle.js +4 -4
  310. package/umd/Options/Classes/Particles/Move/MoveAttract.js +3 -3
  311. package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -4
  312. package/umd/Options/Classes/Particles/Move/Spin.js +3 -3
  313. package/umd/Options/Classes/Particles/ParticlesOptions.js +1 -7
  314. package/umd/Options/Classes/Particles/Stroke.js +4 -4
  315. package/umd/Options/Classes/ValueWithRandom.js +3 -3
  316. package/umd/Utils/CanvasUtils.js +69 -22
  317. package/umd/Utils/ColorUtils.js +72 -56
  318. package/umd/Utils/EventDispatcher.js +3 -1
  319. package/umd/Utils/LogUtils.js +36 -0
  320. package/umd/Utils/{NumberUtils.js → MathUtils.js} +16 -8
  321. package/umd/Utils/Utils.js +36 -141
  322. package/umd/bundle.js +4 -4
  323. package/umd/export-types.js +1 -114
  324. package/umd/exports.js +3 -10
  325. package/umd/index.js +4 -8
  326. package/umd/{init.js → initEngine.js} +3 -5
  327. package/browser/Core/Interfaces/IRectSideResult.js +0 -1
  328. package/browser/Core/Interfaces/ITrailFillData.js +0 -1
  329. package/browser/Enums/Modes/CollisionMode.js +0 -6
  330. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
  331. package/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
  332. package/browser/Options/Classes/Particles/Collisions/Collisions.js +0 -33
  333. package/browser/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
  334. package/browser/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
  335. package/browser/Options/Classes/Particles/Move/MoveTrail.js +0 -23
  336. package/browser/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
  337. package/browser/Options/Classes/Particles/Shadow.js +0 -35
  338. package/browser/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
  339. package/browser/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
  340. package/browser/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
  341. package/browser/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
  342. package/browser/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
  343. package/browser/Options/Interfaces/Particles/IShadow.js +0 -1
  344. package/browser/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
  345. package/browser/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
  346. package/browser/init.js +0 -6
  347. package/cjs/Core/Interfaces/IRectSideResult.js +0 -2
  348. package/cjs/Core/Interfaces/ITrailFillData.js +0 -2
  349. package/cjs/Enums/Modes/CollisionMode.js +0 -9
  350. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +0 -28
  351. package/cjs/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -25
  352. package/cjs/Options/Classes/Particles/Collisions/Collisions.js +0 -37
  353. package/cjs/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -18
  354. package/cjs/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -22
  355. package/cjs/Options/Classes/Particles/Move/MoveTrail.js +0 -27
  356. package/cjs/Options/Classes/Particles/Move/MoveTrailFill.js +0 -19
  357. package/cjs/Options/Classes/Particles/Shadow.js +0 -39
  358. package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -2
  359. package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -2
  360. package/cjs/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -2
  361. package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -2
  362. package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -2
  363. package/cjs/Options/Interfaces/Particles/IShadow.js +0 -2
  364. package/cjs/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -2
  365. package/cjs/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -2
  366. package/cjs/Types/RangeType.js +0 -8
  367. package/cjs/Utils/NumberUtils.js +0 -177
  368. package/cjs/init.js +0 -9
  369. package/esm/Core/Interfaces/IRectSideResult.js +0 -1
  370. package/esm/Core/Interfaces/ITrailFillData.js +0 -1
  371. package/esm/Enums/Modes/CollisionMode.js +0 -6
  372. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
  373. package/esm/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
  374. package/esm/Options/Classes/Particles/Collisions/Collisions.js +0 -33
  375. package/esm/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
  376. package/esm/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
  377. package/esm/Options/Classes/Particles/Move/MoveTrail.js +0 -23
  378. package/esm/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
  379. package/esm/Options/Classes/Particles/Shadow.js +0 -35
  380. package/esm/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
  381. package/esm/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
  382. package/esm/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
  383. package/esm/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
  384. package/esm/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
  385. package/esm/Options/Interfaces/Particles/IShadow.js +0 -1
  386. package/esm/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
  387. package/esm/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
  388. package/esm/init.js +0 -6
  389. package/types/Core/Interfaces/IRectSideResult.d.ts +0 -5
  390. package/types/Core/Interfaces/ITrailFillData.d.ts +0 -6
  391. package/types/Enums/Modes/CollisionMode.d.ts +0 -5
  392. package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +0 -11
  393. package/types/Options/Classes/BackgroundMask/BackgroundMaskCover.d.ts +0 -11
  394. package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +0 -18
  395. package/types/Options/Classes/Particles/Collisions/CollisionsAbsorb.d.ts +0 -8
  396. package/types/Options/Classes/Particles/Collisions/CollisionsOverlap.d.ts +0 -9
  397. package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +0 -11
  398. package/types/Options/Classes/Particles/Move/MoveTrailFill.d.ts +0 -9
  399. package/types/Options/Classes/Particles/Shadow.d.ts +0 -13
  400. package/types/Options/Interfaces/BackgroundMask/IBackgroundMask.d.ts +0 -8
  401. package/types/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.d.ts +0 -6
  402. package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +0 -13
  403. package/types/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.d.ts +0 -3
  404. package/types/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.d.ts +0 -4
  405. package/types/Options/Interfaces/Particles/IShadow.d.ts +0 -8
  406. package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +0 -6
  407. package/types/Options/Interfaces/Particles/Move/IMoveTrailFill.d.ts +0 -5
  408. package/types/init.d.ts +0 -2
  409. package/umd/Core/Interfaces/IRectSideResult.js +0 -12
  410. package/umd/Core/Interfaces/ITrailFillData.js +0 -12
  411. package/umd/Enums/Modes/CollisionMode.js +0 -19
  412. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +0 -38
  413. package/umd/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -35
  414. package/umd/Options/Classes/Particles/Collisions/Collisions.js +0 -47
  415. package/umd/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -28
  416. package/umd/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -32
  417. package/umd/Options/Classes/Particles/Move/MoveTrail.js +0 -37
  418. package/umd/Options/Classes/Particles/Move/MoveTrailFill.js +0 -29
  419. package/umd/Options/Classes/Particles/Shadow.js +0 -49
  420. package/umd/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -12
  421. package/umd/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -12
  422. package/umd/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -12
  423. package/umd/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -12
  424. package/umd/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -12
  425. package/umd/Options/Interfaces/Particles/IShadow.js +0 -12
  426. package/umd/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -12
  427. package/umd/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -12
  428. /package/browser/{Types → Enums}/RangeType.js +0 -0
  429. /package/{esm/Types → cjs/Enums}/RangeType.js +0 -0
  430. /package/types/{Types → Enums}/RangeType.d.ts +0 -0
  431. /package/umd/{Types → Enums}/RangeType.js +0 -0
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventListeners = void 0;
4
- const Constants_js_1 = require("./Constants.js");
5
- const Utils_js_1 = require("../../Utils/Utils.js");
6
- const InteractivityDetect_js_1 = require("../../Enums/InteractivityDetect.js");
7
- const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
1
+ import { double, lengthOffset, millisecondsToSeconds, mouseDownEvent, mouseLeaveEvent, mouseMoveEvent, mouseOutEvent, mouseUpEvent, resizeEvent, touchCancelEvent, touchDelay, touchEndEvent, touchMoveEvent, touchStartEvent, visibilityChangeEvent, } from "./Constants.js";
2
+ import { executeOnSingleOrMultiple, safeDocument, safeMatchMedia } from "../../Utils/Utils.js";
3
+ import { InteractivityDetect } from "../../Enums/InteractivityDetect.js";
4
+ import { isBoolean } from "../../Utils/TypeUtils.js";
8
5
  function manageListener(element, event, handler, add, options) {
9
6
  if (add) {
10
7
  let addOptions = { passive: true };
11
- if ((0, TypeUtils_js_1.isBoolean)(options)) {
8
+ if (isBoolean(options)) {
12
9
  addOptions.capture = options;
13
10
  }
14
11
  else if (options !== undefined) {
@@ -21,9 +18,10 @@ function manageListener(element, event, handler, add, options) {
21
18
  element.removeEventListener(event, handler, removeOptions);
22
19
  }
23
20
  }
24
- class EventListeners {
21
+ export class EventListeners {
25
22
  constructor(container) {
26
23
  this.container = container;
24
+ this._canPush = true;
27
25
  this._doMouseTouchClick = e => {
28
26
  const container = this.container, options = container.actualOptions;
29
27
  if (this._canPush) {
@@ -32,12 +30,16 @@ class EventListeners {
32
30
  return;
33
31
  }
34
32
  mouseInteractivity.clickPosition = { ...mousePos };
35
- mouseInteractivity.clickTime = new Date().getTime();
33
+ mouseInteractivity.clickTime = Date.now();
36
34
  const onClick = options.interactivity.events.onClick;
37
- (0, Utils_js_1.executeOnSingleOrMultiple)(onClick.mode, mode => this.container.handleClickMode(mode));
35
+ executeOnSingleOrMultiple(onClick.mode, mode => {
36
+ this.container.handleClickMode(mode);
37
+ });
38
38
  }
39
39
  if (e.type === "touchend") {
40
- setTimeout(() => this._mouseTouchFinish(), Constants_js_1.touchDelay);
40
+ setTimeout(() => {
41
+ this._mouseTouchFinish();
42
+ }, touchDelay);
41
43
  }
42
44
  };
43
45
  this._handleThemeChange = (e) => {
@@ -52,17 +54,17 @@ class EventListeners {
52
54
  if (!options.pauseOnBlur) {
53
55
  return;
54
56
  }
55
- if (document?.hidden) {
57
+ if (safeDocument().hidden) {
56
58
  container.pageHidden = true;
57
59
  container.pause();
58
60
  }
59
61
  else {
60
62
  container.pageHidden = false;
61
63
  if (container.animationStatus) {
62
- void container.play(true);
64
+ container.play(true);
63
65
  }
64
66
  else {
65
- void container.draw(true);
67
+ container.draw(true);
66
68
  }
67
69
  }
68
70
  };
@@ -73,9 +75,9 @@ class EventListeners {
73
75
  }
74
76
  const handleResize = async () => {
75
77
  const canvas = this.container.canvas;
76
- await canvas?.windowResize();
78
+ await canvas.windowResize();
77
79
  };
78
- this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.interactivity.events.resize.delay * Constants_js_1.millisecondsToSeconds);
80
+ this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.interactivity.events.resize.delay * millisecondsToSeconds);
79
81
  };
80
82
  this._manageInteractivityListeners = (mouseLeaveTmpEvent, add) => {
81
83
  const handlers = this._handlers, container = this.container, options = container.actualOptions, interactivityEl = container.interactivity.element;
@@ -87,28 +89,28 @@ class EventListeners {
87
89
  if (!(options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable)) {
88
90
  return;
89
91
  }
90
- manageListener(interactivityEl, Constants_js_1.mouseMoveEvent, handlers.mouseMove, add);
91
- manageListener(interactivityEl, Constants_js_1.touchStartEvent, handlers.touchStart, add);
92
- manageListener(interactivityEl, Constants_js_1.touchMoveEvent, handlers.touchMove, add);
93
- if (!options.interactivity.events.onClick.enable) {
94
- manageListener(interactivityEl, Constants_js_1.touchEndEvent, handlers.touchEnd, add);
92
+ manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
93
+ manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
94
+ manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
95
+ if (options.interactivity.events.onClick.enable) {
96
+ manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add);
97
+ manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
98
+ manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
95
99
  }
96
100
  else {
97
- manageListener(interactivityEl, Constants_js_1.touchEndEvent, handlers.touchEndClick, add);
98
- manageListener(interactivityEl, Constants_js_1.mouseUpEvent, handlers.mouseUp, add);
99
- manageListener(interactivityEl, Constants_js_1.mouseDownEvent, handlers.mouseDown, add);
101
+ manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add);
100
102
  }
101
103
  manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
102
- manageListener(interactivityEl, Constants_js_1.touchCancelEvent, handlers.touchCancel, add);
104
+ manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
103
105
  };
104
106
  this._manageListeners = add => {
105
107
  const handlers = this._handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn, canvasEl = container.canvas.element;
106
- let mouseLeaveTmpEvent = Constants_js_1.mouseLeaveEvent;
107
- if (detectType === InteractivityDetect_js_1.InteractivityDetect.window) {
108
+ let mouseLeaveTmpEvent = mouseLeaveEvent;
109
+ if (detectType === InteractivityDetect.window) {
108
110
  container.interactivity.element = window;
109
- mouseLeaveTmpEvent = Constants_js_1.mouseOutEvent;
111
+ mouseLeaveTmpEvent = mouseOutEvent;
110
112
  }
111
- else if (detectType === InteractivityDetect_js_1.InteractivityDetect.parent && canvasEl) {
113
+ else if (detectType === InteractivityDetect.parent && canvasEl) {
112
114
  container.interactivity.element = canvasEl.parentElement ?? canvasEl.parentNode;
113
115
  }
114
116
  else {
@@ -117,36 +119,22 @@ class EventListeners {
117
119
  this._manageMediaMatch(add);
118
120
  this._manageResize(add);
119
121
  this._manageInteractivityListeners(mouseLeaveTmpEvent, add);
120
- if (document) {
121
- manageListener(document, Constants_js_1.visibilityChangeEvent, handlers.visibilityChange, add, false);
122
- }
122
+ manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
123
123
  };
124
124
  this._manageMediaMatch = add => {
125
- const handlers = this._handlers, mediaMatch = (0, Utils_js_1.safeMatchMedia)("(prefers-color-scheme: dark)");
126
- if (!mediaMatch) {
127
- return;
128
- }
129
- if (mediaMatch.addEventListener !== undefined) {
130
- manageListener(mediaMatch, "change", handlers.themeChange, add);
131
- return;
132
- }
133
- if (mediaMatch.addListener === undefined) {
125
+ const handlers = this._handlers;
126
+ if (!this._matchMedia) {
134
127
  return;
135
128
  }
136
- if (add) {
137
- mediaMatch.addListener(handlers.oldThemeChange);
138
- }
139
- else {
140
- mediaMatch.removeListener(handlers.oldThemeChange);
141
- }
129
+ manageListener(this._matchMedia, "change", handlers.themeChange, add);
142
130
  };
143
131
  this._manageResize = add => {
144
132
  const handlers = this._handlers, container = this.container, options = container.actualOptions;
145
- if (!options.interactivity.events.resize) {
133
+ if (!options.interactivity.events.resize.enable) {
146
134
  return;
147
135
  }
148
136
  if (typeof ResizeObserver === "undefined") {
149
- manageListener(window, Constants_js_1.resizeEvent, handlers.resize, add);
137
+ manageListener(globalThis, resizeEvent, handlers.resize, add);
150
138
  return;
151
139
  }
152
140
  const canvasEl = container.canvas.element;
@@ -169,11 +157,7 @@ class EventListeners {
169
157
  }
170
158
  };
171
159
  this._mouseDown = () => {
172
- const { interactivity } = this.container;
173
- if (!interactivity) {
174
- return;
175
- }
176
- const { mouse } = interactivity;
160
+ const { interactivity } = this.container, { mouse } = interactivity;
177
161
  mouse.clicking = true;
178
162
  mouse.downPosition = mouse.position;
179
163
  };
@@ -200,21 +184,17 @@ class EventListeners {
200
184
  mouse.clicking = false;
201
185
  };
202
186
  this._mouseTouchFinish = () => {
203
- const interactivity = this.container.interactivity;
204
- if (!interactivity) {
205
- return;
206
- }
207
- const mouse = interactivity.mouse;
187
+ const { interactivity } = this.container, { mouse } = interactivity;
208
188
  delete mouse.position;
209
189
  delete mouse.clickPosition;
210
190
  delete mouse.downPosition;
211
- interactivity.status = Constants_js_1.mouseLeaveEvent;
191
+ interactivity.status = mouseLeaveEvent;
212
192
  mouse.inside = false;
213
193
  mouse.clicking = false;
214
194
  };
215
195
  this._mouseTouchMove = e => {
216
196
  const container = this.container, options = container.actualOptions, interactivity = container.interactivity, canvasEl = container.canvas.element;
217
- if (!interactivity?.element) {
197
+ if (!interactivity.element) {
218
198
  return;
219
199
  }
220
200
  interactivity.mouse.inside = true;
@@ -231,36 +211,39 @@ class EventListeners {
231
211
  };
232
212
  }
233
213
  }
234
- else if (options.interactivity.detectsOn === InteractivityDetect_js_1.InteractivityDetect.parent) {
214
+ else if (options.interactivity.detectsOn === InteractivityDetect.parent) {
235
215
  const source = mouseEvent.target, target = mouseEvent.currentTarget;
236
- if (source && target && canvasEl) {
216
+ if (canvasEl) {
237
217
  const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
238
218
  pos = {
239
- x: mouseEvent.offsetX + Constants_js_1.double * sourceRect.left - (targetRect.left + canvasRect.left),
240
- y: mouseEvent.offsetY + Constants_js_1.double * sourceRect.top - (targetRect.top + canvasRect.top),
219
+ x: mouseEvent.offsetX + double * sourceRect.left - (targetRect.left + canvasRect.left),
220
+ y: mouseEvent.offsetY + double * sourceRect.top - (targetRect.top + canvasRect.top),
241
221
  };
242
222
  }
243
223
  else {
244
224
  pos = {
245
- x: mouseEvent.offsetX ?? mouseEvent.clientX,
246
- y: mouseEvent.offsetY ?? mouseEvent.clientY,
225
+ x: mouseEvent.offsetX,
226
+ y: mouseEvent.offsetY,
247
227
  };
248
228
  }
249
229
  }
250
230
  else if (mouseEvent.target === canvasEl) {
251
231
  pos = {
252
- x: mouseEvent.offsetX ?? mouseEvent.clientX,
253
- y: mouseEvent.offsetY ?? mouseEvent.clientY,
232
+ x: mouseEvent.offsetX,
233
+ y: mouseEvent.offsetY,
254
234
  };
255
235
  }
256
236
  }
257
237
  else {
258
238
  this._canPush = e.type !== "touchmove";
259
239
  if (canvasEl) {
260
- const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - Constants_js_1.lengthOffset], canvasRect = canvasEl.getBoundingClientRect();
240
+ const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - lengthOffset], canvasRect = canvasEl.getBoundingClientRect();
241
+ if (!lastTouch) {
242
+ return;
243
+ }
261
244
  pos = {
262
- x: lastTouch.clientX - (canvasRect.left ?? Constants_js_1.minCoordinate),
263
- y: lastTouch.clientY - (canvasRect.top ?? Constants_js_1.minCoordinate),
245
+ x: lastTouch.clientX - canvasRect.left,
246
+ y: lastTouch.clientY - canvasRect.top,
264
247
  };
265
248
  }
266
249
  }
@@ -270,7 +253,7 @@ class EventListeners {
270
253
  pos.y *= pxRatio;
271
254
  }
272
255
  interactivity.mouse.position = pos;
273
- interactivity.status = Constants_js_1.mouseMoveEvent;
256
+ interactivity.status = mouseMoveEvent;
274
257
  };
275
258
  this._touchEnd = e => {
276
259
  const evt = e, touches = Array.from(evt.changedTouches);
@@ -293,21 +276,45 @@ class EventListeners {
293
276
  }
294
277
  this._mouseTouchMove(e);
295
278
  };
296
- this._canPush = true;
279
+ this._matchMedia = safeMatchMedia("(prefers-color-scheme: dark)");
297
280
  this._touches = new Map();
298
281
  this._handlers = {
299
- mouseDown: () => this._mouseDown(),
300
- mouseLeave: () => this._mouseTouchFinish(),
301
- mouseMove: (e) => this._mouseTouchMove(e),
302
- mouseUp: (e) => this._mouseTouchClick(e),
303
- touchStart: (e) => this._touchStart(e),
304
- touchMove: (e) => this._mouseTouchMove(e),
305
- touchEnd: (e) => this._touchEnd(e),
306
- touchCancel: (e) => this._touchEnd(e),
307
- touchEndClick: (e) => this._touchEndClick(e),
308
- visibilityChange: () => this._handleVisibilityChange(),
309
- themeChange: (e) => this._handleThemeChange(e),
310
- oldThemeChange: (e) => this._handleThemeChange(e),
282
+ mouseDown: () => {
283
+ this._mouseDown();
284
+ },
285
+ mouseLeave: () => {
286
+ this._mouseTouchFinish();
287
+ },
288
+ mouseMove: (e) => {
289
+ this._mouseTouchMove(e);
290
+ },
291
+ mouseUp: (e) => {
292
+ this._mouseTouchClick(e);
293
+ },
294
+ touchStart: (e) => {
295
+ this._touchStart(e);
296
+ },
297
+ touchMove: (e) => {
298
+ this._mouseTouchMove(e);
299
+ },
300
+ touchEnd: (e) => {
301
+ this._touchEnd(e);
302
+ },
303
+ touchCancel: (e) => {
304
+ this._touchEnd(e);
305
+ },
306
+ touchEndClick: (e) => {
307
+ this._touchEndClick(e);
308
+ },
309
+ visibilityChange: () => {
310
+ this._handleVisibilityChange();
311
+ },
312
+ themeChange: (e) => {
313
+ this._handleThemeChange(e);
314
+ },
315
+ oldThemeChange: (e) => {
316
+ this._handleThemeChange(e);
317
+ },
311
318
  resize: () => {
312
319
  this._handleWindowResize();
313
320
  },
@@ -320,4 +327,3 @@ class EventListeners {
320
327
  this._manageListeners(false);
321
328
  }
322
329
  }
323
- exports.EventListeners = EventListeners;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExternalInteractorBase = void 0;
4
- const InteractorType_js_1 = require("../../Enums/Types/InteractorType.js");
5
- class ExternalInteractorBase {
1
+ import { InteractorType } from "../../Enums/Types/InteractorType.js";
2
+ export class ExternalInteractorBase {
6
3
  constructor(container) {
7
- this.type = InteractorType_js_1.InteractorType.external;
4
+ this.type = InteractorType.external;
8
5
  this.container = container;
9
6
  }
10
7
  }
11
- exports.ExternalInteractorBase = ExternalInteractorBase;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InteractionManager = void 0;
4
- const InteractorType_js_1 = require("../../Enums/Types/InteractorType.js");
5
- class InteractionManager {
1
+ import { InteractorType } from "../../Enums/Types/InteractorType.js";
2
+ export class InteractionManager {
6
3
  constructor(engine, container) {
7
4
  this.container = container;
8
5
  this._engine = engine;
@@ -28,10 +25,10 @@ class InteractionManager {
28
25
  this._particleInteractors = [];
29
26
  for (const interactor of this._interactors) {
30
27
  switch (interactor.type) {
31
- case InteractorType_js_1.InteractorType.external:
28
+ case InteractorType.external:
32
29
  this._externalInteractors.push(interactor);
33
30
  break;
34
- case InteractorType_js_1.InteractorType.particles:
31
+ case InteractorType.particles:
35
32
  this._particleInteractors.push(interactor);
36
33
  break;
37
34
  }
@@ -61,4 +58,3 @@ class InteractionManager {
61
58
  }
62
59
  }
63
60
  }
64
- exports.InteractionManager = InteractionManager;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParticlesInteractorBase = void 0;
4
- const InteractorType_js_1 = require("../../Enums/Types/InteractorType.js");
5
- class ParticlesInteractorBase {
1
+ import { InteractorType } from "../../Enums/Types/InteractorType.js";
2
+ export class ParticlesInteractorBase {
6
3
  constructor(container) {
7
- this.type = InteractorType_js_1.InteractorType.particles;
4
+ this.type = InteractorType.particles;
8
5
  this.container = container;
9
6
  }
10
7
  }
11
- exports.ParticlesInteractorBase = ParticlesInteractorBase;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Point = void 0;
4
- class Point {
1
+ export class Point {
5
2
  constructor(position, particle) {
6
3
  this.position = position;
7
4
  this.particle = particle;
8
5
  }
9
6
  }
10
- exports.Point = Point;
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuadTree = void 0;
4
- const Ranges_js_1 = require("./Ranges.js");
5
- const Constants_js_1 = require("./Constants.js");
6
- const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
7
- class QuadTree {
1
+ import { Circle, Rectangle } from "./Ranges.js";
2
+ import { double, half, subdivideCount } from "./Constants.js";
3
+ import { getDistance } from "../../Utils/MathUtils.js";
4
+ export class QuadTree {
8
5
  constructor(rectangle, capacity) {
9
6
  this.rectangle = rectangle;
10
7
  this.capacity = capacity;
11
8
  this._subdivide = () => {
12
9
  const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
13
- for (let i = 0; i < Constants_js_1.subdivideCount; i++) {
14
- const fixedIndex = i % Constants_js_1.double;
15
- this._subs.push(new QuadTree(new Ranges_js_1.Rectangle(x + width * Constants_js_1.half * fixedIndex, y + height * Constants_js_1.half * (Math.round(i * Constants_js_1.half) - fixedIndex), width * Constants_js_1.half, height * Constants_js_1.half), capacity));
10
+ for (let i = 0; i < subdivideCount; i++) {
11
+ const fixedIndex = i % double;
12
+ this._subs.push(new QuadTree(new Rectangle(x + width * half * fixedIndex, y + height * half * (Math.round(i * half) - fixedIndex), width * half, height * half), capacity));
16
13
  }
17
14
  this._divided = true;
18
15
  };
@@ -40,7 +37,7 @@ class QuadTree {
40
37
  }
41
38
  for (const p of this._points) {
42
39
  if (!range.contains(p.position) &&
43
- (0, NumberUtils_js_1.getDistance)(range.position, p.position) > p.particle.getRadius() &&
40
+ getDistance(range.position, p.position) > p.particle.getRadius() &&
44
41
  (!check || check(p.particle))) {
45
42
  continue;
46
43
  }
@@ -54,10 +51,9 @@ class QuadTree {
54
51
  return res;
55
52
  }
56
53
  queryCircle(position, radius, check) {
57
- return this.query(new Ranges_js_1.Circle(position.x, position.y, radius), check);
54
+ return this.query(new Circle(position.x, position.y, radius), check);
58
55
  }
59
56
  queryRectangle(position, size, check) {
60
- return this.query(new Ranges_js_1.Rectangle(position.x, position.y, size.width, size.height), check);
57
+ return this.query(new Rectangle(position.x, position.y, size.width, size.height), check);
61
58
  }
62
59
  }
63
- exports.QuadTree = QuadTree;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Rectangle = exports.Circle = exports.BaseRange = void 0;
4
- const RangeType_js_1 = require("../../Types/RangeType.js");
5
- const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
6
- const Constants_js_1 = require("./Constants.js");
7
- class BaseRange {
1
+ import { RangeType } from "../../Enums/RangeType.js";
2
+ import { getDistance } from "../../Utils/MathUtils.js";
3
+ import { squareExp } from "./Constants.js";
4
+ export class BaseRange {
8
5
  constructor(x, y, type) {
9
6
  this.position = {
10
7
  x: x,
@@ -13,24 +10,23 @@ class BaseRange {
13
10
  this.type = type;
14
11
  }
15
12
  }
16
- exports.BaseRange = BaseRange;
17
- class Circle extends BaseRange {
13
+ export class Circle extends BaseRange {
18
14
  constructor(x, y, radius) {
19
- super(x, y, RangeType_js_1.RangeType.circle);
15
+ super(x, y, RangeType.circle);
20
16
  this.radius = radius;
21
17
  }
22
18
  contains(point) {
23
- return (0, NumberUtils_js_1.getDistance)(point, this.position) <= this.radius;
19
+ return getDistance(point, this.position) <= this.radius;
24
20
  }
25
21
  intersects(range) {
26
22
  const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
27
- if (range instanceof Circle || range.type === RangeType_js_1.RangeType.circle) {
28
- const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** Constants_js_1.squareExp + distPos.y ** Constants_js_1.squareExp);
23
+ if (range instanceof Circle || range.type === RangeType.circle) {
24
+ const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
29
25
  return rSum > dist;
30
26
  }
31
- else if (range instanceof Rectangle || range.type === RangeType_js_1.RangeType.rectangle) {
32
- const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, Constants_js_1.squareExp) + Math.pow(distPos.y - height, Constants_js_1.squareExp);
33
- return (edges <= r ** Constants_js_1.squareExp ||
27
+ else if (range instanceof Rectangle || range.type === RangeType.rectangle) {
28
+ const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
29
+ return (edges <= r ** squareExp ||
34
30
  (distPos.x <= r + width && distPos.y <= r + height) ||
35
31
  distPos.x <= width ||
36
32
  distPos.y <= height);
@@ -38,10 +34,9 @@ class Circle extends BaseRange {
38
34
  return false;
39
35
  }
40
36
  }
41
- exports.Circle = Circle;
42
- class Rectangle extends BaseRange {
37
+ export class Rectangle extends BaseRange {
43
38
  constructor(x, y, width, height) {
44
- super(x, y, RangeType_js_1.RangeType.rectangle);
39
+ super(x, y, RangeType.rectangle);
45
40
  this.size = {
46
41
  height: height,
47
42
  width: width,
@@ -59,4 +54,3 @@ class Rectangle extends BaseRange {
59
54
  return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
60
55
  }
61
56
  }
62
- exports.Rectangle = Rectangle;
@@ -1,31 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vector = exports.Vector3d = void 0;
4
- const Constants_js_1 = require("./Constants.js");
5
- const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
6
- class Vector3d {
7
- constructor(xOrCoords, y, z) {
1
+ import { inverseFactorNumerator, none, originPoint, squareExp } from "./Constants.js";
2
+ export class Vector3d {
3
+ constructor(x = originPoint.x, y = originPoint.y, z = originPoint.z) {
8
4
  this._updateFromAngle = (angle, length) => {
9
5
  this.x = Math.cos(angle) * length;
10
6
  this.y = Math.sin(angle) * length;
11
7
  };
12
- if (!(0, TypeUtils_js_1.isNumber)(xOrCoords) && xOrCoords) {
13
- this.x = xOrCoords.x;
14
- this.y = xOrCoords.y;
15
- const coords3d = xOrCoords;
16
- this.z = coords3d.z ? coords3d.z : Constants_js_1.originPoint.z;
17
- }
18
- else if (xOrCoords !== undefined && y !== undefined) {
19
- this.x = xOrCoords;
20
- this.y = y;
21
- this.z = z ?? Constants_js_1.originPoint.z;
22
- }
23
- else {
24
- throw new Error(`${Constants_js_1.errorPrefix} Vector3d not initialized correctly`);
25
- }
8
+ this.x = x;
9
+ this.y = y;
10
+ this.z = z;
26
11
  }
27
12
  static get origin() {
28
- return Vector3d.create(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, Constants_js_1.originPoint.z);
13
+ return Vector3d.create(originPoint.x, originPoint.y, originPoint.z);
29
14
  }
30
15
  get angle() {
31
16
  return Math.atan2(this.y, this.x);
@@ -43,7 +28,10 @@ class Vector3d {
43
28
  return Vector3d.create(source.x, source.y, source.z);
44
29
  }
45
30
  static create(x, y, z) {
46
- return new Vector3d(x, y, z);
31
+ if (typeof x === "number") {
32
+ return new Vector3d(x, y ?? originPoint.y, z ?? originPoint.z);
33
+ }
34
+ return new Vector3d(x.x, x.y, Object.hasOwn(x, "z") ? x.z : originPoint.z);
47
35
  }
48
36
  add(v) {
49
37
  return Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z);
@@ -71,7 +59,7 @@ class Vector3d {
71
59
  this.z /= n;
72
60
  }
73
61
  getLengthSq() {
74
- return this.x ** Constants_js_1.squareExp + this.y ** Constants_js_1.squareExp;
62
+ return this.x ** squareExp + this.y ** squareExp;
75
63
  }
76
64
  mult(n) {
77
65
  return Vector3d.create(this.x * n, this.y * n, this.z * n);
@@ -83,18 +71,18 @@ class Vector3d {
83
71
  }
84
72
  normalize() {
85
73
  const length = this.length;
86
- if (length != Constants_js_1.none) {
87
- this.multTo(Constants_js_1.inverseFactorNumerator / length);
74
+ if (length != none) {
75
+ this.multTo(inverseFactorNumerator / length);
88
76
  }
89
77
  }
90
78
  rotate(angle) {
91
- return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), Constants_js_1.originPoint.z);
79
+ return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), originPoint.z);
92
80
  }
93
81
  setTo(c) {
94
82
  this.x = c.x;
95
83
  this.y = c.y;
96
84
  const v3d = c;
97
- this.z = v3d.z ? v3d.z : Constants_js_1.originPoint.z;
85
+ this.z = v3d.z ? v3d.z : originPoint.z;
98
86
  }
99
87
  sub(v) {
100
88
  return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z);
@@ -105,19 +93,20 @@ class Vector3d {
105
93
  this.z -= v.z;
106
94
  }
107
95
  }
108
- exports.Vector3d = Vector3d;
109
- class Vector extends Vector3d {
110
- constructor(xOrCoords, y) {
111
- super(xOrCoords, y, Constants_js_1.originPoint.z);
96
+ export class Vector extends Vector3d {
97
+ constructor(x = originPoint.x, y = originPoint.y) {
98
+ super(x, y, originPoint.z);
112
99
  }
113
100
  static get origin() {
114
- return Vector.create(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y);
101
+ return Vector.create(originPoint.x, originPoint.y);
115
102
  }
116
103
  static clone(source) {
117
104
  return Vector.create(source.x, source.y);
118
105
  }
119
106
  static create(x, y) {
120
- return new Vector(x, y);
107
+ if (typeof x === "number") {
108
+ return new Vector(x, y ?? originPoint.y);
109
+ }
110
+ return new Vector(x.x, x.y);
121
111
  }
122
112
  }
123
- exports.Vector = Vector;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AnimationStatus = void 0;
4
- var AnimationStatus;
1
+ export var AnimationStatus;
5
2
  (function (AnimationStatus) {
6
3
  AnimationStatus["increasing"] = "increasing";
7
4
  AnimationStatus["decreasing"] = "decreasing";
8
- })(AnimationStatus || (exports.AnimationStatus = AnimationStatus = {}));
5
+ })(AnimationStatus || (AnimationStatus = {}));
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MoveDirection = void 0;
4
- var MoveDirection;
1
+ export var MoveDirection;
5
2
  (function (MoveDirection) {
6
3
  MoveDirection["bottom"] = "bottom";
7
4
  MoveDirection["bottomLeft"] = "bottom-left";
@@ -14,4 +11,4 @@ var MoveDirection;
14
11
  MoveDirection["topRight"] = "top-right";
15
12
  MoveDirection["outside"] = "outside";
16
13
  MoveDirection["inside"] = "inside";
17
- })(MoveDirection || (exports.MoveDirection = MoveDirection = {}));
14
+ })(MoveDirection || (MoveDirection = {}));