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