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