@tsparticles/engine 3.0.0-alpha.0 → 3.0.0-beta.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 (336) hide show
  1. package/README.md +246 -211
  2. package/browser/Core/Canvas.js +271 -241
  3. package/browser/Core/Container.js +90 -106
  4. package/browser/Core/Engine.js +271 -0
  5. package/browser/Core/Particle.js +158 -162
  6. package/browser/Core/Particles.js +148 -134
  7. package/browser/Core/Retina.js +15 -13
  8. package/browser/Core/Utils/Circle.js +10 -6
  9. package/browser/Core/Utils/Constants.js +4 -3
  10. package/browser/Core/Utils/EventListeners.js +259 -220
  11. package/browser/Core/Utils/InteractionManager.js +6 -16
  12. package/browser/Core/Utils/QuadTree.js +14 -20
  13. package/browser/Core/Utils/Vector3d.js +17 -9
  14. package/browser/Options/Classes/AnimatableColor.js +2 -1
  15. package/browser/Options/Classes/AnimationOptions.js +7 -2
  16. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
  17. package/browser/Options/Classes/ColorAnimation.js +4 -0
  18. package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  19. package/browser/Options/Classes/Interactivity/Events/Events.js +5 -24
  20. package/browser/Options/Classes/Interactivity/Interactivity.js +1 -8
  21. package/browser/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  22. package/browser/Options/Classes/ManualParticle.js +5 -5
  23. package/browser/Options/Classes/Options.js +19 -39
  24. package/browser/Options/Classes/OptionsColor.js +3 -2
  25. package/browser/Options/Classes/Particles/Collisions/Collisions.js +5 -0
  26. package/browser/Options/Classes/Particles/Move/Move.js +11 -41
  27. package/browser/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  28. package/browser/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  29. package/browser/Options/Classes/Particles/Move/OutModes.js +4 -5
  30. package/browser/Options/Classes/Particles/Move/Spin.js +3 -1
  31. package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  32. package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  33. package/browser/Options/Classes/Particles/Opacity/Opacity.js +11 -7
  34. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  35. package/browser/Options/Classes/Particles/ParticlesOptions.js +6 -11
  36. package/browser/Options/Classes/Particles/Shape/Shape.js +9 -2
  37. package/browser/Options/Classes/Particles/Size/Size.js +11 -7
  38. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  39. package/browser/Options/Classes/ValueWithRandom.js +4 -17
  40. package/browser/Utils/CanvasUtils.js +18 -54
  41. package/browser/Utils/ColorUtils.js +17 -19
  42. package/browser/Utils/EventDispatcher.js +7 -6
  43. package/browser/Utils/HslColorManager.js +2 -4
  44. package/browser/Utils/NumberUtils.js +41 -45
  45. package/browser/Utils/RgbColorManager.js +2 -4
  46. package/browser/Utils/Utils.js +150 -59
  47. package/browser/bundle.js +4 -96
  48. package/browser/export-types.js +97 -0
  49. package/browser/exports.js +89 -0
  50. package/browser/index.js +8 -198
  51. package/browser/init.js +12 -0
  52. package/cjs/Core/Canvas.js +269 -239
  53. package/cjs/Core/Container.js +90 -106
  54. package/cjs/Core/Engine.js +275 -0
  55. package/cjs/Core/Particle.js +157 -161
  56. package/cjs/Core/Particles.js +148 -134
  57. package/cjs/Core/Retina.js +15 -13
  58. package/cjs/Core/Utils/Circle.js +10 -6
  59. package/cjs/Core/Utils/Constants.js +5 -4
  60. package/cjs/Core/Utils/EventListeners.js +258 -219
  61. package/cjs/Core/Utils/InteractionManager.js +6 -16
  62. package/cjs/Core/Utils/QuadTree.js +14 -20
  63. package/cjs/Core/Utils/Vector3d.js +17 -9
  64. package/cjs/Options/Classes/AnimatableColor.js +2 -1
  65. package/cjs/Options/Classes/AnimationOptions.js +7 -2
  66. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
  67. package/cjs/Options/Classes/ColorAnimation.js +4 -0
  68. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  69. package/cjs/Options/Classes/Interactivity/Events/Events.js +5 -24
  70. package/cjs/Options/Classes/Interactivity/Interactivity.js +1 -8
  71. package/cjs/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  72. package/cjs/Options/Classes/ManualParticle.js +5 -5
  73. package/cjs/Options/Classes/Options.js +18 -38
  74. package/cjs/Options/Classes/OptionsColor.js +3 -2
  75. package/cjs/Options/Classes/Particles/Collisions/Collisions.js +5 -0
  76. package/cjs/Options/Classes/Particles/Move/Move.js +11 -41
  77. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  78. package/cjs/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  79. package/cjs/Options/Classes/Particles/Move/OutModes.js +4 -5
  80. package/cjs/Options/Classes/Particles/Move/Spin.js +3 -1
  81. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  82. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  83. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +10 -6
  84. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  85. package/cjs/Options/Classes/Particles/ParticlesOptions.js +6 -11
  86. package/cjs/Options/Classes/Particles/Shape/Shape.js +9 -2
  87. package/cjs/Options/Classes/Particles/Size/Size.js +11 -7
  88. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  89. package/cjs/Options/Classes/ValueWithRandom.js +4 -17
  90. package/cjs/Utils/CanvasUtils.js +21 -58
  91. package/cjs/Utils/ColorUtils.js +16 -18
  92. package/cjs/Utils/EventDispatcher.js +7 -6
  93. package/cjs/Utils/HslColorManager.js +2 -4
  94. package/cjs/Utils/NumberUtils.js +41 -45
  95. package/cjs/Utils/RgbColorManager.js +2 -4
  96. package/cjs/Utils/Utils.js +163 -63
  97. package/cjs/bundle.js +4 -96
  98. package/cjs/export-types.js +113 -0
  99. package/cjs/exports.js +105 -0
  100. package/cjs/index.js +8 -198
  101. package/cjs/init.js +16 -0
  102. package/esm/Core/Canvas.js +271 -241
  103. package/esm/Core/Container.js +90 -106
  104. package/esm/Core/Engine.js +271 -0
  105. package/esm/Core/Particle.js +158 -162
  106. package/esm/Core/Particles.js +148 -134
  107. package/esm/Core/Retina.js +15 -13
  108. package/esm/Core/Utils/Circle.js +10 -6
  109. package/esm/Core/Utils/Constants.js +4 -3
  110. package/esm/Core/Utils/EventListeners.js +259 -220
  111. package/esm/Core/Utils/InteractionManager.js +6 -16
  112. package/esm/Core/Utils/QuadTree.js +14 -20
  113. package/esm/Core/Utils/Vector3d.js +17 -9
  114. package/esm/Options/Classes/AnimatableColor.js +2 -1
  115. package/esm/Options/Classes/AnimationOptions.js +7 -2
  116. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
  117. package/esm/Options/Classes/ColorAnimation.js +4 -0
  118. package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  119. package/esm/Options/Classes/Interactivity/Events/Events.js +5 -24
  120. package/esm/Options/Classes/Interactivity/Interactivity.js +1 -8
  121. package/esm/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  122. package/esm/Options/Classes/ManualParticle.js +5 -5
  123. package/esm/Options/Classes/Options.js +19 -39
  124. package/esm/Options/Classes/OptionsColor.js +3 -2
  125. package/esm/Options/Classes/Particles/Collisions/Collisions.js +5 -0
  126. package/esm/Options/Classes/Particles/Move/Move.js +11 -41
  127. package/esm/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  128. package/esm/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  129. package/esm/Options/Classes/Particles/Move/OutModes.js +4 -5
  130. package/esm/Options/Classes/Particles/Move/Spin.js +3 -1
  131. package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  132. package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  133. package/esm/Options/Classes/Particles/Opacity/Opacity.js +11 -7
  134. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  135. package/esm/Options/Classes/Particles/ParticlesOptions.js +6 -11
  136. package/esm/Options/Classes/Particles/Shape/Shape.js +9 -2
  137. package/esm/Options/Classes/Particles/Size/Size.js +11 -7
  138. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  139. package/esm/Options/Classes/ValueWithRandom.js +4 -17
  140. package/esm/Utils/CanvasUtils.js +18 -54
  141. package/esm/Utils/ColorUtils.js +17 -19
  142. package/esm/Utils/EventDispatcher.js +7 -6
  143. package/esm/Utils/HslColorManager.js +2 -4
  144. package/esm/Utils/NumberUtils.js +41 -45
  145. package/esm/Utils/RgbColorManager.js +2 -4
  146. package/esm/Utils/Utils.js +150 -59
  147. package/esm/bundle.js +4 -96
  148. package/esm/export-types.js +97 -0
  149. package/esm/exports.js +89 -0
  150. package/esm/index.js +8 -198
  151. package/esm/init.js +12 -0
  152. package/package.json +17 -2
  153. package/report.html +4 -4
  154. package/scripts/install.js +90 -33
  155. package/tsparticles.engine.js +1848 -1961
  156. package/tsparticles.engine.min.js +1 -1
  157. package/tsparticles.engine.min.js.LICENSE.txt +1 -10
  158. package/types/Core/Canvas.d.ts +20 -16
  159. package/types/Core/Container.d.ts +10 -14
  160. package/types/Core/Engine.d.ts +71 -0
  161. package/types/Core/Interfaces/IContainerPlugin.d.ts +2 -0
  162. package/types/Core/Interfaces/ICoordinates.d.ts +5 -3
  163. package/types/Core/Interfaces/IDimension.d.ts +4 -0
  164. package/types/Core/Interfaces/IMovePathGenerator.d.ts +2 -1
  165. package/types/Core/Interfaces/IParticleUpdater.d.ts +0 -2
  166. package/types/Core/Interfaces/IParticleValueAnimation.d.ts +2 -0
  167. package/types/Core/Interfaces/IPlugin.d.ts +4 -3
  168. package/types/Core/Particle.d.ts +7 -7
  169. package/types/Core/Particles.d.ts +14 -10
  170. package/types/Core/Utils/Constants.d.ts +4 -3
  171. package/types/Core/Utils/EventListeners.d.ts +20 -14
  172. package/types/Core/Utils/InteractionManager.d.ts +1 -1
  173. package/types/Core/Utils/QuadTree.d.ts +2 -5
  174. package/types/Core/Utils/Vector3d.d.ts +2 -1
  175. package/types/Enums/Modes/AnimationMode.d.ts +6 -0
  176. package/types/Enums/Modes/{SizeMode.d.ts → PixelMode.d.ts} +1 -1
  177. package/types/Options/Classes/AnimationOptions.d.ts +3 -1
  178. package/types/Options/Classes/ColorAnimation.d.ts +1 -0
  179. package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -6
  180. package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -6
  181. package/types/Options/Classes/Interactivity/Interactivity.d.ts +1 -3
  182. package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +1 -1
  183. package/types/Options/Classes/ManualParticle.d.ts +2 -2
  184. package/types/Options/Classes/Options.d.ts +5 -12
  185. package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +2 -0
  186. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -11
  187. package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -4
  188. package/types/Options/Classes/Particles/Move/MoveCenter.d.ts +2 -2
  189. package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +0 -3
  190. package/types/Options/Classes/Particles/Move/Spin.d.ts +2 -2
  191. package/types/Options/Classes/Particles/Number/ParticlesDensity.d.ts +0 -6
  192. package/types/Options/Classes/Particles/Number/ParticlesNumber.d.ts +0 -2
  193. package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +4 -4
  194. package/types/Options/Classes/Particles/Opacity/OpacityAnimation.d.ts +0 -2
  195. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +1 -1
  196. package/types/Options/Classes/Particles/Shape/Shape.d.ts +2 -0
  197. package/types/Options/Classes/Particles/Size/Size.d.ts +4 -4
  198. package/types/Options/Classes/Particles/Size/SizeAnimation.d.ts +0 -2
  199. package/types/Options/Classes/Responsive.d.ts +3 -3
  200. package/types/Options/Classes/Theme/Theme.d.ts +2 -2
  201. package/types/Options/Classes/ValueWithRandom.d.ts +2 -6
  202. package/types/Options/Interfaces/IAnimation.d.ts +3 -1
  203. package/types/Options/Interfaces/IManualParticle.d.ts +2 -2
  204. package/types/Options/Interfaces/IOptions.d.ts +1 -4
  205. package/types/Options/Interfaces/IResponsive.d.ts +4 -3
  206. package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -3
  207. package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -3
  208. package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -1
  209. package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -1
  210. package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +2 -0
  211. package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -1
  212. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -5
  213. package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -2
  214. package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +0 -2
  215. package/types/Options/Interfaces/Particles/Move/ISpin.d.ts +2 -2
  216. package/types/Options/Interfaces/Particles/Number/IParticlesDensity.d.ts +0 -3
  217. package/types/Options/Interfaces/Particles/Number/IParticlesNumber.d.ts +0 -1
  218. package/types/Options/Interfaces/Particles/Opacity/IOpacity.d.ts +0 -1
  219. package/types/Options/Interfaces/Particles/Opacity/IOpacityAnimation.d.ts +0 -1
  220. package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +2 -0
  221. package/types/Options/Interfaces/Particles/Size/ISize.d.ts +0 -1
  222. package/types/Options/Interfaces/Particles/Size/ISizeAnimation.d.ts +0 -1
  223. package/types/Options/Interfaces/Theme/ITheme.d.ts +3 -2
  224. package/types/Types/ExportResult.d.ts +5 -0
  225. package/types/Utils/CanvasUtils.d.ts +2 -5
  226. package/types/Utils/OptionsUtils.d.ts +1 -1
  227. package/types/Utils/Utils.d.ts +22 -4
  228. package/types/bundle.d.ts +2 -90
  229. package/types/export-types.d.ts +107 -0
  230. package/types/exports.d.ts +89 -0
  231. package/types/index.d.ts +3 -203
  232. package/types/init.d.ts +2 -0
  233. package/umd/Core/Canvas.js +269 -239
  234. package/umd/Core/Container.js +91 -107
  235. package/umd/Core/Engine.js +285 -0
  236. package/umd/Core/Particle.js +158 -162
  237. package/umd/Core/Particles.js +149 -135
  238. package/umd/Core/Retina.js +15 -13
  239. package/umd/Core/Utils/Circle.js +11 -7
  240. package/umd/Core/Utils/Constants.js +5 -4
  241. package/umd/Core/Utils/EventListeners.js +258 -219
  242. package/umd/Core/Utils/InteractionManager.js +6 -16
  243. package/umd/Core/Utils/QuadTree.js +14 -20
  244. package/umd/Core/Utils/Vector3d.js +18 -10
  245. package/umd/Options/Classes/AnimatableColor.js +3 -2
  246. package/umd/Options/Classes/AnimationOptions.js +7 -2
  247. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +3 -2
  248. package/umd/Options/Classes/ColorAnimation.js +4 -0
  249. package/umd/Options/Classes/Interactivity/Events/DivEvent.js +1 -25
  250. package/umd/Options/Classes/Interactivity/Events/Events.js +6 -25
  251. package/umd/Options/Classes/Interactivity/Interactivity.js +1 -8
  252. package/umd/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  253. package/umd/Options/Classes/ManualParticle.js +5 -5
  254. package/umd/Options/Classes/Options.js +18 -38
  255. package/umd/Options/Classes/OptionsColor.js +4 -3
  256. package/umd/Options/Classes/Particles/Collisions/Collisions.js +6 -1
  257. package/umd/Options/Classes/Particles/Move/Move.js +12 -42
  258. package/umd/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  259. package/umd/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  260. package/umd/Options/Classes/Particles/Move/OutModes.js +4 -5
  261. package/umd/Options/Classes/Particles/Move/Spin.js +3 -1
  262. package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  263. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  264. package/umd/Options/Classes/Particles/Opacity/Opacity.js +10 -6
  265. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  266. package/umd/Options/Classes/Particles/ParticlesOptions.js +6 -11
  267. package/umd/Options/Classes/Particles/Shape/Shape.js +9 -2
  268. package/umd/Options/Classes/Particles/Size/Size.js +12 -8
  269. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  270. package/umd/Options/Classes/ValueWithRandom.js +5 -18
  271. package/umd/Utils/CanvasUtils.js +21 -58
  272. package/umd/Utils/ColorUtils.js +16 -18
  273. package/umd/Utils/EventDispatcher.js +7 -6
  274. package/umd/Utils/HslColorManager.js +2 -4
  275. package/umd/Utils/NumberUtils.js +42 -46
  276. package/umd/Utils/RgbColorManager.js +2 -4
  277. package/umd/Utils/Utils.js +163 -63
  278. package/umd/bundle.js +5 -97
  279. package/umd/export-types.js +123 -0
  280. package/umd/exports.js +115 -0
  281. package/umd/index.js +9 -199
  282. package/umd/init.js +26 -0
  283. package/browser/Core/Utils/FrameManager.js +0 -42
  284. package/browser/Core/Utils/Plugins.js +0 -112
  285. package/browser/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
  286. package/browser/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
  287. package/browser/engine.js +0 -175
  288. package/cjs/Core/Utils/FrameManager.js +0 -46
  289. package/cjs/Core/Utils/Plugins.js +0 -116
  290. package/cjs/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -2
  291. package/cjs/Options/Interfaces/Particles/Shape/IImageShape.js +0 -2
  292. package/cjs/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -2
  293. package/cjs/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -17
  294. package/cjs/Options/Interfaces/Particles/Shape/IStarShape.js +0 -2
  295. package/cjs/engine.js +0 -179
  296. package/esm/Core/Interfaces/IParticleOverride.js +0 -1
  297. package/esm/Core/Interfaces/IParticlesMover.js +0 -1
  298. package/esm/Core/Utils/FrameManager.js +0 -42
  299. package/esm/Core/Utils/Plugins.js +0 -112
  300. package/esm/Enums/Modes/SizeMode.js +0 -1
  301. package/esm/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -1
  302. package/esm/Options/Interfaces/Particles/Shape/IImageShape.js +0 -1
  303. package/esm/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -1
  304. package/esm/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
  305. package/esm/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
  306. package/esm/engine.js +0 -175
  307. package/types/Core/Interfaces/IParticleOverride.d.ts +0 -6
  308. package/types/Core/Interfaces/IParticlesMover.d.ts +0 -7
  309. package/types/Core/Utils/FrameManager.d.ts +0 -6
  310. package/types/Core/Utils/Plugins.d.ts +0 -51
  311. package/types/Options/Interfaces/Particles/Shape/ICharacterShape.d.ts +0 -8
  312. package/types/Options/Interfaces/Particles/Shape/IImageShape.d.ts +0 -8
  313. package/types/Options/Interfaces/Particles/Shape/IPolygonShape.d.ts +0 -5
  314. package/types/Options/Interfaces/Particles/Shape/IShapeValues.d.ts +0 -1
  315. package/types/Options/Interfaces/Particles/Shape/IStarShape.d.ts +0 -6
  316. package/types/engine.d.ts +0 -39
  317. package/umd/Core/Utils/FrameManager.js +0 -56
  318. package/umd/Core/Utils/Plugins.js +0 -126
  319. package/umd/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -12
  320. package/umd/Options/Interfaces/Particles/Shape/IImageShape.js +0 -12
  321. package/umd/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -12
  322. package/umd/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -27
  323. package/umd/Options/Interfaces/Particles/Shape/IStarShape.js +0 -12
  324. package/umd/engine.js +0 -189
  325. /package/browser/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
  326. /package/browser/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
  327. /package/browser/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
  328. /package/cjs/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
  329. /package/cjs/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
  330. /package/cjs/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
  331. /package/{browser/Options/Interfaces/Particles/Shape/ICharacterShape.js → esm/Enums/Modes/AnimationMode.js} +0 -0
  332. /package/{browser/Options/Interfaces/Particles/Shape/IImageShape.js → esm/Enums/Modes/PixelMode.js} +0 -0
  333. /package/{browser/Options/Interfaces/Particles/Shape/IPolygonShape.js → esm/Types/ExportResult.js} +0 -0
  334. /package/umd/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
  335. /package/umd/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
  336. /package/umd/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
@@ -1,17 +1,180 @@
1
- import { clear, clearCanvas, drawParticle, drawParticlePlugin, drawPlugin, getContext, paintCanvas, } from "../Utils/CanvasUtils";
2
- import { deepExtend, isSsr } from "../Utils/Utils";
1
+ import { clear, drawParticle, drawParticlePlugin, drawPlugin, paintBase, paintImage } from "../Utils/CanvasUtils";
2
+ import { deepExtend, getLogger, safeMutationObserver } from "../Utils/Utils";
3
3
  import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils";
4
4
  import { generatedAttribute } from "./Utils/Constants";
5
5
  function setTransformValue(factor, newFactor, key) {
6
- var _a;
7
6
  const newValue = newFactor[key];
8
7
  if (newValue !== undefined) {
9
- factor[key] = ((_a = factor[key]) !== null && _a !== void 0 ? _a : 1) * newValue;
8
+ factor[key] = (factor[key] ?? 1) * newValue;
10
9
  }
11
10
  }
12
11
  export class Canvas {
13
12
  constructor(container) {
14
13
  this.container = container;
14
+ this._applyPostDrawUpdaters = (particle) => {
15
+ for (const updater of this._postDrawUpdaters) {
16
+ updater.afterDraw && updater.afterDraw(particle);
17
+ }
18
+ };
19
+ this._applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
20
+ for (const updater of this._preDrawUpdaters) {
21
+ if (updater.getColorStyles) {
22
+ const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
23
+ if (fill) {
24
+ colorStyles.fill = fill;
25
+ }
26
+ if (stroke) {
27
+ colorStyles.stroke = stroke;
28
+ }
29
+ }
30
+ if (updater.getTransformValues) {
31
+ const updaterTransform = updater.getTransformValues(particle);
32
+ for (const key in updaterTransform) {
33
+ setTransformValue(transform, updaterTransform, key);
34
+ }
35
+ }
36
+ updater.beforeDraw && updater.beforeDraw(particle);
37
+ }
38
+ };
39
+ this._applyResizePlugins = () => {
40
+ for (const plugin of this._resizePlugins) {
41
+ plugin.resize && plugin.resize();
42
+ }
43
+ };
44
+ this._getPluginParticleColors = (particle) => {
45
+ let fColor, sColor;
46
+ for (const plugin of this._colorPlugins) {
47
+ if (!fColor && plugin.particleFillColor) {
48
+ fColor = rangeColorToHsl(plugin.particleFillColor(particle));
49
+ }
50
+ if (!sColor && plugin.particleStrokeColor) {
51
+ sColor = rangeColorToHsl(plugin.particleStrokeColor(particle));
52
+ }
53
+ if (fColor && sColor) {
54
+ break;
55
+ }
56
+ }
57
+ return [fColor, sColor];
58
+ };
59
+ this._initCover = () => {
60
+ const options = this.container.actualOptions, cover = options.backgroundMask.cover, color = cover.color, coverRgb = rangeColorToRgb(color);
61
+ if (coverRgb) {
62
+ const coverColor = {
63
+ ...coverRgb,
64
+ a: cover.opacity,
65
+ };
66
+ this._coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
67
+ }
68
+ };
69
+ this._initStyle = () => {
70
+ const element = this.element, options = this.container.actualOptions;
71
+ if (!element) {
72
+ return;
73
+ }
74
+ if (this._fullScreen) {
75
+ this._originalStyle = deepExtend({}, element.style);
76
+ this._setFullScreenStyle();
77
+ }
78
+ else {
79
+ this._resetOriginalStyle();
80
+ }
81
+ for (const key in options.style) {
82
+ if (!key || !options.style) {
83
+ continue;
84
+ }
85
+ const value = options.style[key];
86
+ if (!value) {
87
+ continue;
88
+ }
89
+ element.style.setProperty(key, value, "important");
90
+ }
91
+ };
92
+ this._initTrail = async () => {
93
+ const options = this.container.actualOptions, trail = options.particles.move.trail, trailFill = trail.fill;
94
+ if (!trail.enable) {
95
+ return;
96
+ }
97
+ if (trailFill.color) {
98
+ const fillColor = rangeColorToRgb(trailFill.color);
99
+ if (!fillColor) {
100
+ return;
101
+ }
102
+ const trail = options.particles.move.trail;
103
+ this._trailFill = {
104
+ color: {
105
+ ...fillColor,
106
+ },
107
+ opacity: 1 / trail.length,
108
+ };
109
+ }
110
+ else {
111
+ await new Promise((resolve, reject) => {
112
+ if (!trailFill.image) {
113
+ return;
114
+ }
115
+ const img = document.createElement("img");
116
+ img.addEventListener("load", () => {
117
+ this._trailFill = {
118
+ image: img,
119
+ opacity: 1 / trail.length,
120
+ };
121
+ resolve();
122
+ });
123
+ img.addEventListener("error", (evt) => {
124
+ reject(evt.error);
125
+ });
126
+ img.src = trailFill.image;
127
+ });
128
+ }
129
+ };
130
+ this._paintBase = (baseColor) => {
131
+ this.draw((ctx) => paintBase(ctx, this.size, baseColor));
132
+ };
133
+ this._paintImage = (image, opacity) => {
134
+ this.draw((ctx) => paintImage(ctx, this.size, image, opacity));
135
+ };
136
+ this._repairStyle = () => {
137
+ const element = this.element;
138
+ if (!element) {
139
+ return;
140
+ }
141
+ this._safeMutationObserver((observer) => observer.disconnect());
142
+ this._initStyle();
143
+ this.initBackground();
144
+ this._safeMutationObserver((observer) => observer.observe(element, { attributes: true }));
145
+ };
146
+ this._resetOriginalStyle = () => {
147
+ const element = this.element, originalStyle = this._originalStyle;
148
+ if (!(element && originalStyle)) {
149
+ return;
150
+ }
151
+ const style = element.style;
152
+ style.position = originalStyle.position;
153
+ style.zIndex = originalStyle.zIndex;
154
+ style.top = originalStyle.top;
155
+ style.left = originalStyle.left;
156
+ style.width = originalStyle.width;
157
+ style.height = originalStyle.height;
158
+ };
159
+ this._safeMutationObserver = (callback) => {
160
+ if (!this._mutationObserver) {
161
+ return;
162
+ }
163
+ callback(this._mutationObserver);
164
+ };
165
+ this._setFullScreenStyle = () => {
166
+ const element = this.element;
167
+ if (!element) {
168
+ return;
169
+ }
170
+ const priority = "important", style = element.style;
171
+ style.setProperty("position", "fixed", priority);
172
+ style.setProperty("z-index", this.container.actualOptions.fullScreen.zIndex.toString(10), priority);
173
+ style.setProperty("top", "0", priority);
174
+ style.setProperty("left", "0", priority);
175
+ style.setProperty("width", "100%", priority);
176
+ style.setProperty("height", "100%", priority);
177
+ };
15
178
  this.size = {
16
179
  height: 0,
17
180
  width: 0,
@@ -22,50 +185,51 @@ export class Canvas {
22
185
  this._postDrawUpdaters = [];
23
186
  this._resizePlugins = [];
24
187
  this._colorPlugins = [];
25
- this._mutationObserver =
26
- !isSsr() && typeof MutationObserver !== "undefined"
27
- ? new MutationObserver((records) => {
28
- for (const record of records) {
29
- if (record.type === "attributes" && record.attributeName === "style") {
30
- this._repairStyle();
31
- }
32
- }
33
- })
34
- : undefined;
35
188
  }
36
189
  get _fullScreen() {
37
190
  return this.container.actualOptions.fullScreen.enable;
38
191
  }
39
192
  clear() {
40
- this.draw((ctx) => {
41
- clearCanvas(ctx, this.size, this.container.actualOptions, this._trailFill, this._coverColorStyle);
42
- });
193
+ const options = this.container.actualOptions, trail = options.particles.move.trail, trailFill = this._trailFill;
194
+ if (options.backgroundMask.enable) {
195
+ this.paint();
196
+ }
197
+ else if (trail.enable && trail.length > 0 && trailFill) {
198
+ if (trailFill.color) {
199
+ this._paintBase(getStyleFromRgb(trailFill.color, trailFill.opacity));
200
+ }
201
+ else if (trailFill.image) {
202
+ this._paintImage(trailFill.image, trailFill.opacity);
203
+ }
204
+ }
205
+ else {
206
+ this.draw((ctx) => {
207
+ clear(ctx, this.size);
208
+ });
209
+ }
43
210
  }
44
211
  destroy() {
45
- var _a, _b;
46
- (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
212
+ this.stop();
47
213
  if (this._generated) {
48
- (_b = this.element) === null || _b === void 0 ? void 0 : _b.remove();
214
+ const element = this.element;
215
+ element && element.remove();
49
216
  }
50
217
  else {
51
218
  this._resetOriginalStyle();
52
219
  }
53
- this.draw((ctx) => {
54
- clear(ctx, this.size);
55
- });
56
220
  this._preDrawUpdaters = [];
57
221
  this._postDrawUpdaters = [];
58
222
  this._resizePlugins = [];
59
223
  this._colorPlugins = [];
60
224
  }
61
225
  draw(cb) {
62
- if (!this._context) {
226
+ const ctx = this._context;
227
+ if (!ctx) {
63
228
  return;
64
229
  }
65
- return cb(this._context);
230
+ return cb(ctx);
66
231
  }
67
232
  drawParticle(particle, delta) {
68
- var _a;
69
233
  if (particle.spawning || particle.destroyed) {
70
234
  return;
71
235
  }
@@ -73,7 +237,7 @@ export class Canvas {
73
237
  if (radius <= 0) {
74
238
  return;
75
239
  }
76
- const pfColor = particle.getFillColor(), psColor = (_a = particle.getStrokeColor()) !== null && _a !== void 0 ? _a : pfColor;
240
+ const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor() ?? pfColor;
77
241
  let [fColor, sColor] = this._getPluginParticleColors(particle);
78
242
  if (!fColor) {
79
243
  fColor = pfColor;
@@ -85,14 +249,13 @@ export class Canvas {
85
249
  return;
86
250
  }
87
251
  this.draw((ctx) => {
88
- var _a, _b, _c, _d;
89
- const options = this.container.actualOptions, zIndexOptions = particle.options.zIndex, zOpacityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.opacityRate, opacity = (_c = (_a = particle.bubble.opacity) !== null && _a !== void 0 ? _a : (_b = particle.opacity) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 1, strokeOpacity = (_d = particle.strokeOpacity) !== null && _d !== void 0 ? _d : opacity, zOpacity = opacity * zOpacityFactor, zStrokeOpacity = strokeOpacity * zOpacityFactor, transform = {}, colorStyles = {
252
+ const container = this.container, options = container.actualOptions, zIndexOptions = particle.options.zIndex, zOpacityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.opacityRate, opacity = particle.bubble.opacity ?? particle.opacity?.value ?? 1, strokeOpacity = particle.strokeOpacity ?? opacity, zOpacity = opacity * zOpacityFactor, zStrokeOpacity = strokeOpacity * zOpacityFactor, transform = {}, colorStyles = {
90
253
  fill: fColor ? getStyleFromHsl(fColor, zOpacity) : undefined,
91
254
  };
92
255
  colorStyles.stroke = sColor ? getStyleFromHsl(sColor, zStrokeOpacity) : colorStyles.fill;
93
256
  this._applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform);
94
257
  drawParticle({
95
- container: this.container,
258
+ container,
96
259
  context: ctx,
97
260
  particle,
98
261
  delta,
@@ -108,119 +271,46 @@ export class Canvas {
108
271
  });
109
272
  }
110
273
  drawParticlePlugin(plugin, particle, delta) {
111
- this.draw((ctx) => {
112
- drawParticlePlugin(ctx, plugin, particle, delta);
113
- });
274
+ this.draw((ctx) => drawParticlePlugin(ctx, plugin, particle, delta));
114
275
  }
115
276
  drawPlugin(plugin, delta) {
116
- this.draw((ctx) => {
117
- drawPlugin(ctx, plugin, delta);
118
- });
277
+ this.draw((ctx) => drawPlugin(ctx, plugin, delta));
119
278
  }
120
279
  async init() {
121
- var _a;
122
- this._resize();
280
+ this._safeMutationObserver((obs) => obs.disconnect());
281
+ this._mutationObserver = safeMutationObserver((records) => {
282
+ for (const record of records) {
283
+ if (record.type === "attributes" && record.attributeName === "style") {
284
+ this._repairStyle();
285
+ }
286
+ }
287
+ });
288
+ this.resize();
123
289
  this._initStyle();
124
290
  this._initCover();
125
291
  try {
126
292
  await this._initTrail();
127
293
  }
128
294
  catch (e) {
129
- console.error(e);
295
+ getLogger().error(e);
130
296
  }
131
- this._initBackground();
132
- if (this.element) {
133
- (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.element, { attributes: true });
134
- }
135
- this._initUpdaters();
136
- this._initPlugins();
137
- this._paint();
138
- this.container.updateActualOptions();
139
- this._resize();
140
- this._initBackground();
141
- }
142
- loadCanvas(canvas) {
143
- var _a, _b;
144
- if (this._generated) {
145
- (_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
146
- }
147
- this._generated =
148
- canvas.dataset && generatedAttribute in canvas.dataset
149
- ? canvas.dataset[generatedAttribute] === "true"
150
- : this._generated;
151
- this.element = canvas;
152
- this.element.ariaHidden = "true";
153
- this._originalStyle = deepExtend({}, this.element.style);
154
- this.size.height = canvas.offsetHeight;
155
- this.size.width = canvas.offsetWidth;
156
- this._context = getContext(canvas);
157
- (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(this.element, { attributes: true });
158
- this.container.retina.init();
159
- this._initBackground();
160
- }
161
- async windowResize() {
162
- if (!this.element) {
163
- return;
164
- }
165
- this._resize();
166
- const container = this.container, needsRefresh = container.updateActualOptions();
167
- container.particles.setDensity();
168
- this._applyResizePlugins();
169
- if (needsRefresh) {
170
- await container.refresh();
171
- }
172
- }
173
- _applyPostDrawUpdaters(particle) {
174
- var _a;
175
- for (const updater of this._postDrawUpdaters) {
176
- (_a = updater.afterDraw) === null || _a === void 0 ? void 0 : _a.call(updater, particle);
177
- }
178
- }
179
- _applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform) {
180
- var _a;
181
- for (const updater of this._preDrawUpdaters) {
182
- if (updater.getColorStyles) {
183
- const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
184
- if (fill) {
185
- colorStyles.fill = fill;
186
- }
187
- if (stroke) {
188
- colorStyles.stroke = stroke;
189
- }
190
- }
191
- if (updater.getTransformValues) {
192
- const updaterTransform = updater.getTransformValues(particle);
193
- for (const key in updaterTransform) {
194
- setTransformValue(transform, updaterTransform, key);
195
- }
196
- }
197
- (_a = updater.beforeDraw) === null || _a === void 0 ? void 0 : _a.call(updater, particle);
198
- }
199
- }
200
- _applyResizePlugins() {
201
- for (const plugin of this._resizePlugins) {
202
- if (plugin.resize) {
203
- plugin.resize();
297
+ this.initBackground();
298
+ this._safeMutationObserver((obs) => {
299
+ if (!this.element) {
300
+ return;
204
301
  }
205
- }
302
+ obs.observe(this.element, { attributes: true });
303
+ });
304
+ this.initUpdaters();
305
+ this.initPlugins();
306
+ this.paint();
206
307
  }
207
- _getPluginParticleColors(particle) {
208
- let fColor, sColor;
209
- for (const plugin of this._colorPlugins) {
210
- if (!fColor && plugin.particleFillColor) {
211
- fColor = rangeColorToHsl(plugin.particleFillColor(particle));
212
- }
213
- if (!sColor && plugin.particleStrokeColor) {
214
- sColor = rangeColorToHsl(plugin.particleStrokeColor(particle));
215
- }
216
- if (fColor && sColor) {
217
- break;
218
- }
308
+ initBackground() {
309
+ const options = this.container.actualOptions, background = options.background, element = this.element;
310
+ if (!element) {
311
+ return;
219
312
  }
220
- return [fColor, sColor];
221
- }
222
- _initBackground() {
223
- const options = this.container.actualOptions, background = options.background, element = this.element, elementStyle = element === null || element === void 0 ? void 0 : element.style;
313
+ const elementStyle = element.style;
224
314
  if (!elementStyle) {
225
315
  return;
226
316
  }
@@ -236,19 +326,7 @@ export class Canvas {
236
326
  elementStyle.backgroundRepeat = background.repeat || "";
237
327
  elementStyle.backgroundSize = background.size || "";
238
328
  }
239
- _initCover() {
240
- const options = this.container.actualOptions, cover = options.backgroundMask.cover, color = cover.color, coverRgb = rangeColorToRgb(color);
241
- if (coverRgb) {
242
- const coverColor = {
243
- r: coverRgb.r,
244
- g: coverRgb.g,
245
- b: coverRgb.b,
246
- a: cover.opacity,
247
- };
248
- this._coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
249
- }
250
- }
251
- _initPlugins() {
329
+ initPlugins() {
252
330
  this._resizePlugins = [];
253
331
  for (const [, plugin] of this.container.plugins) {
254
332
  if (plugin.resize) {
@@ -259,66 +337,7 @@ export class Canvas {
259
337
  }
260
338
  }
261
339
  }
262
- _initStyle() {
263
- const element = this.element, options = this.container.actualOptions;
264
- if (!element) {
265
- return;
266
- }
267
- if (this._fullScreen) {
268
- this._originalStyle = deepExtend({}, element.style);
269
- this._setFullScreenStyle();
270
- }
271
- else {
272
- this._resetOriginalStyle();
273
- }
274
- for (const key in options.style) {
275
- if (!key || !options.style) {
276
- continue;
277
- }
278
- const value = options.style[key];
279
- if (!value) {
280
- continue;
281
- }
282
- element.style.setProperty(key, value, "important");
283
- }
284
- }
285
- async _initTrail() {
286
- const options = this.container.actualOptions, trail = options.particles.move.trail, trailFill = trail.fill;
287
- if (!trail.enable) {
288
- return;
289
- }
290
- if (trailFill.color) {
291
- const fillColor = rangeColorToRgb(trailFill.color);
292
- if (!fillColor) {
293
- return;
294
- }
295
- const trail = options.particles.move.trail;
296
- this._trailFill = {
297
- color: Object.assign({}, fillColor),
298
- opacity: 1 / trail.length,
299
- };
300
- }
301
- else {
302
- await new Promise((resolve, reject) => {
303
- if (!trailFill.image) {
304
- return;
305
- }
306
- const img = document.createElement("img");
307
- img.addEventListener("load", () => {
308
- this._trailFill = {
309
- image: img,
310
- opacity: 1 / trail.length,
311
- };
312
- resolve();
313
- });
314
- img.addEventListener("error", (evt) => {
315
- reject(evt.error);
316
- });
317
- img.src = trailFill.image;
318
- });
319
- }
320
- }
321
- _initUpdaters() {
340
+ initUpdaters() {
322
341
  this._preDrawUpdaters = [];
323
342
  this._postDrawUpdaters = [];
324
343
  for (const updater of this.container.particles.updaters) {
@@ -330,37 +349,44 @@ export class Canvas {
330
349
  }
331
350
  }
332
351
  }
333
- _paint() {
334
- this.draw((ctx) => {
335
- paintCanvas(ctx, this.size, this.container.actualOptions, this._coverColorStyle);
336
- });
337
- }
338
- _repairStyle() {
339
- var _a, _b;
340
- const element = this.element;
341
- if (!element) {
342
- return;
352
+ loadCanvas(canvas) {
353
+ if (this._generated && this.element) {
354
+ this.element.remove();
343
355
  }
344
- (_a = this._mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
345
- this._initStyle();
346
- this._initBackground();
347
- (_b = this._mutationObserver) === null || _b === void 0 ? void 0 : _b.observe(element, { attributes: true });
356
+ this._generated =
357
+ canvas.dataset && generatedAttribute in canvas.dataset
358
+ ? canvas.dataset[generatedAttribute] === "true"
359
+ : this._generated;
360
+ this.element = canvas;
361
+ this.element.ariaHidden = "true";
362
+ this._originalStyle = deepExtend({}, this.element.style);
363
+ this.size.height = canvas.offsetHeight;
364
+ this.size.width = canvas.offsetWidth;
365
+ this._context = this.element.getContext("2d");
366
+ this._safeMutationObserver((obs) => {
367
+ if (!this.element) {
368
+ return;
369
+ }
370
+ obs.observe(this.element, { attributes: true });
371
+ });
372
+ this.container.retina.init();
373
+ this.initBackground();
348
374
  }
349
- _resetOriginalStyle() {
350
- const element = this.element, originalStyle = this._originalStyle;
351
- if (!(element && originalStyle)) {
352
- return;
353
- }
354
- element.style.position = originalStyle.position;
355
- element.style.zIndex = originalStyle.zIndex;
356
- element.style.top = originalStyle.top;
357
- element.style.left = originalStyle.left;
358
- element.style.width = originalStyle.width;
359
- element.style.height = originalStyle.height;
375
+ paint() {
376
+ const options = this.container.actualOptions;
377
+ this.draw((ctx) => {
378
+ if (options.backgroundMask.enable && options.backgroundMask.cover) {
379
+ clear(ctx, this.size);
380
+ this._paintBase(this._coverColorStyle);
381
+ }
382
+ else {
383
+ this._paintBase();
384
+ }
385
+ });
360
386
  }
361
- _resize() {
387
+ resize() {
362
388
  if (!this.element) {
363
- return;
389
+ return false;
364
390
  }
365
391
  const container = this.container, pxRatio = container.retina.pixelRatio, size = container.canvas.size, newSize = {
366
392
  width: this.element.offsetWidth * pxRatio,
@@ -370,9 +396,9 @@ export class Canvas {
370
396
  newSize.width === size.width &&
371
397
  newSize.height === this.element.height &&
372
398
  newSize.width === this.element.width) {
373
- return;
399
+ return false;
374
400
  }
375
- const oldSize = Object.assign({}, size);
401
+ const oldSize = { ...size };
376
402
  this.element.width = size.width = this.element.offsetWidth * pxRatio;
377
403
  this.element.height = size.height = this.element.offsetHeight * pxRatio;
378
404
  if (this.container.started) {
@@ -381,18 +407,22 @@ export class Canvas {
381
407
  height: size.height / oldSize.height,
382
408
  };
383
409
  }
410
+ return true;
384
411
  }
385
- _setFullScreenStyle() {
386
- const element = this.element;
387
- if (!element) {
412
+ stop() {
413
+ this._safeMutationObserver((obs) => obs.disconnect());
414
+ this._mutationObserver = undefined;
415
+ this.draw((ctx) => clear(ctx, this.size));
416
+ }
417
+ async windowResize() {
418
+ if (!this.element || !this.resize()) {
388
419
  return;
389
420
  }
390
- const priority = "important";
391
- element.style.setProperty("position", "fixed", priority);
392
- element.style.setProperty("z-index", this.container.actualOptions.fullScreen.zIndex.toString(10), priority);
393
- element.style.setProperty("top", "0", priority);
394
- element.style.setProperty("left", "0", priority);
395
- element.style.setProperty("width", "100%", priority);
396
- element.style.setProperty("height", "100%", priority);
421
+ const container = this.container, needsRefresh = container.updateActualOptions();
422
+ container.particles.setDensity();
423
+ this._applyResizePlugins();
424
+ if (needsRefresh) {
425
+ await container.refresh();
426
+ }
397
427
  }
398
428
  }