@tsparticles/engine 4.0.0-alpha.8 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/155.min.js +1 -0
  2. package/README.md +41 -28
  3. package/browser/Core/CanvasManager.js +303 -0
  4. package/browser/Core/Container.js +134 -101
  5. package/browser/Core/Engine.js +29 -162
  6. package/browser/Core/Particle.js +197 -183
  7. package/browser/Core/ParticlesManager.js +363 -0
  8. package/browser/Core/RenderManager.js +303 -0
  9. package/browser/Core/Retina.js +6 -6
  10. package/browser/Core/Utils/Constants.js +2 -2
  11. package/browser/Core/Utils/EventListeners.js +67 -63
  12. package/browser/Core/Utils/PluginManager.js +145 -0
  13. package/browser/Core/Utils/Ranges.js +29 -10
  14. package/browser/Core/Utils/SpatialHashGrid.js +102 -0
  15. package/browser/Core/Utils/Vectors.js +17 -18
  16. package/browser/Options/Classes/AnimatableColor.js +1 -0
  17. package/browser/Options/Classes/AnimationOptions.js +8 -0
  18. package/browser/Options/Classes/Background/Background.js +6 -0
  19. package/browser/Options/Classes/ColorAnimation.js +12 -1
  20. package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
  21. package/browser/Options/Classes/HslAnimation.js +4 -5
  22. package/browser/Options/Classes/Options.js +67 -8
  23. package/browser/Options/Classes/OptionsColor.js +1 -0
  24. package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  25. package/browser/Options/Classes/Particles/Effect/Effect.js +3 -4
  26. package/browser/Options/Classes/Particles/Fill.js +28 -0
  27. package/browser/Options/Classes/Particles/Move/Move.js +17 -3
  28. package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  29. package/browser/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  30. package/browser/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  31. package/browser/Options/Classes/Particles/Move/OutModes.js +5 -0
  32. package/browser/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  33. package/browser/Options/Classes/Particles/Move/Spin.js +3 -0
  34. package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  35. package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  36. package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  37. package/browser/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  38. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  39. package/browser/Options/Classes/Particles/ParticlesOptions.js +29 -9
  40. package/browser/Options/Classes/Particles/Shape/Shape.js +3 -4
  41. package/browser/Options/Classes/Particles/Size/Size.js +1 -0
  42. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  43. package/browser/Options/Classes/Particles/Stroke.js +3 -0
  44. package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  45. package/browser/Options/Classes/ResizeEvent.js +2 -0
  46. package/browser/Options/Classes/ValueWithRandom.js +3 -4
  47. package/browser/Utils/CanvasUtils.js +44 -51
  48. package/browser/Utils/ColorUtils.js +51 -40
  49. package/browser/Utils/EventDispatcher.js +1 -0
  50. package/browser/Utils/LogUtils.js +1 -0
  51. package/browser/Utils/MathUtils.js +12 -7
  52. package/browser/Utils/OptionsUtils.js +2 -2
  53. package/browser/Utils/Utils.js +109 -31
  54. package/browser/exports.js +1 -2
  55. package/cjs/Core/CanvasManager.js +303 -0
  56. package/cjs/Core/Container.js +134 -101
  57. package/cjs/Core/Engine.js +29 -162
  58. package/cjs/Core/Particle.js +197 -183
  59. package/cjs/Core/ParticlesManager.js +363 -0
  60. package/cjs/Core/RenderManager.js +303 -0
  61. package/cjs/Core/Retina.js +6 -6
  62. package/cjs/Core/Utils/Constants.js +2 -2
  63. package/cjs/Core/Utils/EventListeners.js +67 -63
  64. package/cjs/Core/Utils/PluginManager.js +145 -0
  65. package/cjs/Core/Utils/Ranges.js +29 -10
  66. package/cjs/Core/Utils/SpatialHashGrid.js +102 -0
  67. package/cjs/Core/Utils/Vectors.js +17 -18
  68. package/cjs/Options/Classes/AnimatableColor.js +1 -0
  69. package/cjs/Options/Classes/AnimationOptions.js +8 -0
  70. package/cjs/Options/Classes/Background/Background.js +6 -0
  71. package/cjs/Options/Classes/ColorAnimation.js +12 -1
  72. package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
  73. package/cjs/Options/Classes/HslAnimation.js +4 -5
  74. package/cjs/Options/Classes/Options.js +67 -8
  75. package/cjs/Options/Classes/OptionsColor.js +1 -0
  76. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  77. package/cjs/Options/Classes/Particles/Effect/Effect.js +3 -4
  78. package/cjs/Options/Classes/Particles/Fill.js +28 -0
  79. package/cjs/Options/Classes/Particles/Move/Move.js +17 -3
  80. package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  81. package/cjs/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  82. package/cjs/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  83. package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -0
  84. package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  85. package/cjs/Options/Classes/Particles/Move/Spin.js +3 -0
  86. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  87. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  88. package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  89. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  90. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  91. package/cjs/Options/Classes/Particles/ParticlesOptions.js +29 -9
  92. package/cjs/Options/Classes/Particles/Shape/Shape.js +3 -4
  93. package/cjs/Options/Classes/Particles/Size/Size.js +1 -0
  94. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  95. package/cjs/Options/Classes/Particles/Stroke.js +3 -0
  96. package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  97. package/cjs/Options/Classes/ResizeEvent.js +2 -0
  98. package/cjs/Options/Classes/ValueWithRandom.js +3 -4
  99. package/cjs/Utils/CanvasUtils.js +44 -51
  100. package/cjs/Utils/ColorUtils.js +51 -40
  101. package/cjs/Utils/EventDispatcher.js +1 -0
  102. package/cjs/Utils/LogUtils.js +1 -0
  103. package/cjs/Utils/MathUtils.js +12 -7
  104. package/cjs/Utils/OptionsUtils.js +2 -2
  105. package/cjs/Utils/Utils.js +109 -31
  106. package/cjs/exports.js +1 -2
  107. package/dist_browser_Core_Container_js.js +30 -20
  108. package/esm/Core/CanvasManager.js +303 -0
  109. package/esm/Core/Container.js +134 -101
  110. package/esm/Core/Engine.js +29 -162
  111. package/esm/Core/Particle.js +197 -183
  112. package/esm/Core/ParticlesManager.js +363 -0
  113. package/esm/Core/RenderManager.js +303 -0
  114. package/esm/Core/Retina.js +6 -6
  115. package/esm/Core/Utils/Constants.js +2 -2
  116. package/esm/Core/Utils/EventListeners.js +67 -63
  117. package/esm/Core/Utils/PluginManager.js +145 -0
  118. package/esm/Core/Utils/Ranges.js +29 -10
  119. package/esm/Core/Utils/SpatialHashGrid.js +102 -0
  120. package/esm/Core/Utils/Vectors.js +17 -18
  121. package/esm/Options/Classes/AnimatableColor.js +1 -0
  122. package/esm/Options/Classes/AnimationOptions.js +8 -0
  123. package/esm/Options/Classes/Background/Background.js +6 -0
  124. package/esm/Options/Classes/ColorAnimation.js +12 -1
  125. package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
  126. package/esm/Options/Classes/HslAnimation.js +4 -5
  127. package/esm/Options/Classes/Options.js +67 -8
  128. package/esm/Options/Classes/OptionsColor.js +1 -0
  129. package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  130. package/esm/Options/Classes/Particles/Effect/Effect.js +3 -4
  131. package/esm/Options/Classes/Particles/Fill.js +28 -0
  132. package/esm/Options/Classes/Particles/Move/Move.js +17 -3
  133. package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  134. package/esm/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  135. package/esm/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  136. package/esm/Options/Classes/Particles/Move/OutModes.js +5 -0
  137. package/esm/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  138. package/esm/Options/Classes/Particles/Move/Spin.js +3 -0
  139. package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  140. package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  141. package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  142. package/esm/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  143. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  144. package/esm/Options/Classes/Particles/ParticlesOptions.js +29 -9
  145. package/esm/Options/Classes/Particles/Shape/Shape.js +3 -4
  146. package/esm/Options/Classes/Particles/Size/Size.js +1 -0
  147. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  148. package/esm/Options/Classes/Particles/Stroke.js +3 -0
  149. package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  150. package/esm/Options/Classes/ResizeEvent.js +2 -0
  151. package/esm/Options/Classes/ValueWithRandom.js +3 -4
  152. package/esm/Utils/CanvasUtils.js +44 -51
  153. package/esm/Utils/ColorUtils.js +51 -40
  154. package/esm/Utils/EventDispatcher.js +1 -0
  155. package/esm/Utils/LogUtils.js +1 -0
  156. package/esm/Utils/MathUtils.js +12 -7
  157. package/esm/Utils/OptionsUtils.js +2 -2
  158. package/esm/Utils/Utils.js +109 -31
  159. package/esm/exports.js +1 -2
  160. package/package.json +1 -1
  161. package/report.html +84 -29
  162. package/scripts/install.js +4 -20
  163. package/tsparticles.engine.js +98 -86
  164. package/tsparticles.engine.min.js +2 -2
  165. package/types/Core/CanvasManager.d.ts +39 -0
  166. package/types/Core/Container.d.ts +29 -14
  167. package/types/Core/Engine.d.ts +2 -61
  168. package/types/Core/Interfaces/IColorManager.d.ts +0 -1
  169. package/types/Core/Interfaces/IContainerPlugin.d.ts +10 -8
  170. package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
  171. package/types/Core/Interfaces/IPalette.d.ts +7 -0
  172. package/types/Core/Interfaces/IParticleOpacityData.d.ts +1 -0
  173. package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
  174. package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
  175. package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -3
  176. package/types/Core/Interfaces/IShapeDrawData.d.ts +10 -1
  177. package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
  178. package/types/Core/Interfaces/IShapeValues.d.ts +0 -1
  179. package/types/Core/Particle.d.ts +7 -11
  180. package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +15 -14
  181. package/types/Core/RenderManager.d.ts +49 -0
  182. package/types/Core/Retina.d.ts +0 -2
  183. package/types/Core/Utils/Constants.d.ts +2 -2
  184. package/types/Core/Utils/PluginManager.d.ts +62 -0
  185. package/types/Core/Utils/Ranges.d.ts +4 -1
  186. package/types/Core/Utils/SpatialHashGrid.d.ts +25 -0
  187. package/types/Core/Utils/Vectors.d.ts +8 -10
  188. package/types/Options/Classes/ColorAnimation.d.ts +3 -1
  189. package/types/Options/Classes/HslAnimation.d.ts +3 -4
  190. package/types/Options/Classes/Options.d.ts +5 -3
  191. package/types/Options/Classes/Particles/Effect/Effect.d.ts +0 -1
  192. package/types/Options/Classes/Particles/Fill.d.ts +12 -0
  193. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
  194. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +5 -5
  195. package/types/Options/Classes/Particles/Shape/Shape.d.ts +0 -1
  196. package/types/Options/Classes/ValueWithRandom.d.ts +0 -1
  197. package/types/Options/Interfaces/IColorAnimation.d.ts +2 -0
  198. package/types/Options/Interfaces/IOptions.d.ts +1 -0
  199. package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +0 -1
  200. package/types/Options/Interfaces/Particles/IFill.d.ts +9 -0
  201. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -2
  202. package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -2
  203. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
  204. package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +0 -1
  205. package/types/Types/CanvasContextType.d.ts +1 -0
  206. package/types/Types/EngineInitializers.d.ts +6 -3
  207. package/types/Utils/CanvasUtils.d.ts +13 -16
  208. package/types/Utils/ColorUtils.d.ts +11 -10
  209. package/types/Utils/LogUtils.d.ts +1 -0
  210. package/types/Utils/MathUtils.d.ts +2 -0
  211. package/types/Utils/OptionsUtils.d.ts +2 -2
  212. package/types/Utils/Utils.d.ts +8 -1
  213. package/types/export-types.d.ts +7 -7
  214. package/types/exports.d.ts +1 -2
  215. package/umd/Core/CanvasManager.js +317 -0
  216. package/umd/Core/Container.js +134 -101
  217. package/umd/Core/Engine.js +28 -161
  218. package/umd/Core/Particle.js +198 -184
  219. package/umd/Core/{Particles.js → ParticlesManager.js} +186 -167
  220. package/umd/Core/RenderManager.js +317 -0
  221. package/umd/Core/Retina.js +6 -6
  222. package/umd/Core/Utils/Constants.js +3 -3
  223. package/umd/Core/Utils/EventListeners.js +67 -63
  224. package/umd/Core/Utils/PluginManager.js +159 -0
  225. package/umd/Core/Utils/Ranges.js +28 -9
  226. package/umd/Core/Utils/SpatialHashGrid.js +116 -0
  227. package/umd/Core/Utils/Vectors.js +17 -18
  228. package/umd/Options/Classes/AnimatableColor.js +1 -0
  229. package/umd/Options/Classes/AnimationOptions.js +8 -0
  230. package/umd/Options/Classes/Background/Background.js +6 -0
  231. package/umd/Options/Classes/ColorAnimation.js +12 -1
  232. package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
  233. package/umd/Options/Classes/HslAnimation.js +5 -6
  234. package/umd/Options/Classes/Options.js +67 -8
  235. package/umd/Options/Classes/OptionsColor.js +1 -0
  236. package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  237. package/umd/Options/Classes/Particles/Effect/Effect.js +3 -4
  238. package/umd/Options/Classes/Particles/Fill.js +42 -0
  239. package/umd/Options/Classes/Particles/Move/Move.js +18 -4
  240. package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  241. package/umd/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  242. package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  243. package/umd/Options/Classes/Particles/Move/OutModes.js +5 -0
  244. package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  245. package/umd/Options/Classes/Particles/Move/Spin.js +3 -0
  246. package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  247. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  248. package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  249. package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  250. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  251. package/umd/Options/Classes/Particles/ParticlesOptions.js +30 -10
  252. package/umd/Options/Classes/Particles/Shape/Shape.js +3 -4
  253. package/umd/Options/Classes/Particles/Size/Size.js +1 -0
  254. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  255. package/umd/Options/Classes/Particles/Stroke.js +3 -0
  256. package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  257. package/umd/Options/Classes/ResizeEvent.js +2 -0
  258. package/umd/Options/Classes/ValueWithRandom.js +3 -4
  259. package/umd/Utils/CanvasUtils.js +44 -53
  260. package/umd/Utils/ColorUtils.js +51 -39
  261. package/umd/Utils/EventDispatcher.js +1 -0
  262. package/umd/Utils/LogUtils.js +1 -0
  263. package/umd/Utils/MathUtils.js +14 -7
  264. package/umd/Utils/OptionsUtils.js +2 -2
  265. package/umd/Utils/Utils.js +111 -32
  266. package/umd/exports.js +2 -3
  267. package/794.min.js +0 -2
  268. package/794.min.js.LICENSE.txt +0 -1
  269. package/browser/Core/Canvas.js +0 -469
  270. package/browser/Core/Particles.js +0 -344
  271. package/browser/Core/Utils/Point.js +0 -6
  272. package/browser/Core/Utils/QuadTree.js +0 -59
  273. package/browser/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  274. package/cjs/Core/Canvas.js +0 -469
  275. package/cjs/Core/Particles.js +0 -344
  276. package/cjs/Core/Utils/Point.js +0 -6
  277. package/cjs/Core/Utils/QuadTree.js +0 -59
  278. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  279. package/esm/Core/Canvas.js +0 -469
  280. package/esm/Core/Particles.js +0 -344
  281. package/esm/Core/Utils/Point.js +0 -6
  282. package/esm/Core/Utils/QuadTree.js +0 -59
  283. package/esm/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  284. package/tsparticles.engine.min.js.LICENSE.txt +0 -1
  285. package/types/Core/Canvas.d.ts +0 -55
  286. package/types/Core/Interfaces/IMovePathGenerator.d.ts +0 -10
  287. package/types/Core/Interfaces/IParticleMover.d.ts +0 -7
  288. package/types/Core/Utils/Point.d.ts +0 -7
  289. package/types/Core/Utils/QuadTree.d.ts +0 -18
  290. package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -12
  291. package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -7
  292. package/umd/Core/Canvas.js +0 -483
  293. package/umd/Core/Utils/Point.js +0 -20
  294. package/umd/Core/Utils/QuadTree.js +0 -73
  295. package/umd/Options/Classes/Particles/Move/MoveAttract.js +0 -47
  296. /package/browser/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  297. /package/browser/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  298. /package/browser/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
  299. /package/cjs/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  300. /package/cjs/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  301. /package/cjs/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
  302. /package/esm/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  303. /package/esm/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  304. /package/esm/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
  305. /package/umd/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  306. /package/umd/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  307. /package/umd/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
package/794.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 794.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[794],{8794(t,i,e){e.d(i,{Container:()=>T});var s=e(1680),n=e(7642),a=e(6754),r=e(302),o=e(9599);function h(t,i,e){const s=i[e];void 0!==s&&(t[e]=(t[e]??n.zs)*s)}function c(t,i,e=!1){if(!i)return;const s=t.style,n=new Set;for(let t=0;t<s.length;t++){const i=s.item(t);i&&n.add(i)}for(let t=0;t<i.length;t++){const e=i.item(t);e&&n.add(e)}for(const t of n){const n=i.getPropertyValue(t);n?s.setProperty(t,n,e?"important":""):s.removeProperty(t)}}class l{constructor(t,i){this.container=t,this._reusableColorStyles={},this._reusablePluginColors=[void 0,void 0],this._reusableTransform={},this._applyPostDrawUpdaters=t=>{for(const i of this._postDrawUpdaters)i.afterDraw?.(t)},this._applyPreDrawUpdaters=(t,i,e,s,n,a)=>{for(const r of this._preDrawUpdaters){if(r.getColorStyles){const{fill:a,stroke:o}=r.getColorStyles(i,t,e,s);a&&(n.fill=a),o&&(n.stroke=o)}if(r.getTransformValues){const t=r.getTransformValues(i);for(const i in t)h(a,t,i)}r.beforeDraw?.(i)}},this._applyResizePlugins=()=>{for(const t of this._resizePlugins)t.resize?.()},this._getPluginParticleColors=t=>{let i,e;for(const s of this._colorPlugins)if(!i&&s.particleFillColor&&(i=(0,o.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,o.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors},this._initStyle=()=>{const t=this.element,i=this.container.actualOptions;if(t){this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle();for(const e in i.style){if(!e||!Object.hasOwn(i.style,e))continue;const s=i.style[e];s&&t.style.setProperty(e,s,"important")}}},this._repairStyle=()=>{const t=this.element;if(!t)return;this._safeMutationObserver((t=>{t.disconnect()})),this._initStyle(),this.initBackground();const i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver((i=>{t instanceof Node&&i.observe(t,{attributes:!0})}))},this._resetOriginalStyle=()=>{const t=this.element,i=this._originalStyle;t&&i&&c(t,i,!0)},this._safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)},this._setFullScreenStyle=()=>{const t=this.element;t&&c(t,(0,r.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)},this._engine=i,this._standardSize={height:0,width:0};const e=t.retina.pixelRatio,s=this._standardSize;this.size={height:s.height*e,width:s.width*e},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._pointerEvents="none"}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw((t=>{(0,a.IU)(t,this.size)}))}clear(){let t=!1;for(const i of this.container.plugins)!t&&i.canvasClear&&(t=i.canvasClear());t||this.canvasClear()}destroy(){if(this.stop(),this._generated){const t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}draw(t){const i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;const e=t.getRadius();if(e<=n.w2)return;const s=t.getFillColor(),r=t.getStrokeColor()??s;let[h,c]=this._getPluginParticleColors(t);if(h??=s,c??=r,!h&&!c)return;const l=this.container,d=t.options.zIndex,p=n.RV-t.zIndexFactor,{opacity:u,strokeOpacity:f}=t.getOpacity(),_=this._reusableTransform,g=this._reusableColorStyles,y=h?(0,o.LC)(h,l.hdr,u):void 0,m=c?(0,o.LC)(c,l.hdr,f):y;_.a=_.b=_.c=_.d=void 0,g.fill=y,g.stroke=m,this.draw((s=>{for(const e of l.plugins)e.drawParticleSetup&&e.drawParticleSetup(s,t,i);this._applyPreDrawUpdaters(s,t,e,u,g,_),(0,a.p0)({container:l,context:s,particle:t,delta:i,colorStyles:g,radius:e*p**d.sizeRate,opacity:u,transform:_}),this._applyPostDrawUpdaters(t);for(const e of l.plugins)e.drawParticleCleanup&&e.drawParticleCleanup(s,t,i)}))}drawParticlePlugin(t,i,e){this.draw((s=>{(0,a.Wb)(s,t,i,e)}))}drawParticles(t){const{particles:i,plugins:e}=this.container;this.clear(),i.update(t),this.draw((s=>{for(const i of e)i.drawSettingsSetup?.(s,t);for(const i of e)i.draw?.(s,t);i.drawParticles(t);for(const i of e)i.clearDraw?.(s,t);for(const i of e)i.drawSettingsCleanup?.(s,t)}))}init(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=(0,r.tG)((t=>{for(const i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()})),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})})),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){const{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;const s=e.style,n=(0,o.BN)(this._engine,i.color);s.backgroundColor=n?(0,o.xx)(n,t.hdr,i.opacity):"",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){this._resizePlugins=[];for(const t of this.container.plugins)t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t)}initUpdaters(){this._preDrawUpdaters=[],this._postDrawUpdaters=[];for(const t of this.container.particles.updaters)t.afterDraw&&this._postDrawUpdaters.push(t),(t.getColorStyles??t.getTransformValues??t.beforeDraw)&&this._preDrawUpdaters.push(t)}loadCanvas(t){this._generated&&this.element&&this.element.remove();const i=this.container;this._generated=n.eb in t.dataset?"true"===t.dataset[n.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,r.td)(this.element.style);const e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;const s=this.container.retina.pixelRatio,a=this.size;t.height=a.height=e.height*s,t.width=a.width=e.width*s;const o=(0,r.lV)("(color-gamut: p3)");this._context=this.element.getContext("2d",{alpha:!0,colorSpace:o?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1}),this._safeMutationObserver((t=>{t.disconnect()})),i.retina.init(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}))}paint(){let t=!1;for(const i of this.container.plugins){if(t)break;t=i.canvasPaint?.()??!1}t||this.paintBase()}paintBase(t){this.draw((i=>{(0,a.Sn)(i,this.size,t)}))}paintImage(t,i){this.draw((e=>{(0,a.Md)(e,this.size,t,i)}))}resize(){if(!this.element)return!1;const t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,n={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&n.height===this.element.height&&n.width===this.element.width)return!1;const a={...i};i.height=e.height,i.width=e.width;const r=this.size;return this.element.width=r.width=n.width,this.element.height=r.height=n.height,this.container.started&&t.particles.setResizeFactor({width:i.width/a.width,height:i.height/a.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}stop(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=void 0,this.draw((t=>{(0,a.IU)(t,this.size)}))}async windowResize(){if(!this.element||!this.resize())return;const t=this.container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}}class d{constructor(t){this.container=t,this._handleVisibilityChange=()=>{const t=this.container;t.actualOptions.pauseOnBlur&&((0,r.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))},this._handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);const t=async()=>{const t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout((()=>{t()}),this.container.actualOptions.resize.delay*n.Xu)},this._manageListeners=t=>{const i=this._handlers;this._manageResize(t),(0,r.Kp)(document,n.nK,i.visibilityChange,t,!1)},this._manageResize=t=>{const i=this._handlers,e=this.container;if(!e.actualOptions.resize.enable)return;if("undefined"==typeof ResizeObserver)return void(0,r.Kp)(globalThis,n.NF,i.resize,t);const s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver((t=>{t.find((t=>t.target===s))&&this._handleWindowResize()})),this._resizeObserver.observe(s))},this._handlers={visibilityChange:()=>{this._handleVisibilityChange()},resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}}var p=e(3838),u=e(2037),f=e(6423),_=e(8095),g=e(1953),y=e(1640),m=e(6312),v=e(9176);function w(t){if(!(0,r.hn)(t.outMode,t.checkModes))return;const i=t.radius*n.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class b{constructor(t,i){this.container=i,this._cachedOpacityData={opacity:n.hv,strokeOpacity:n.hv},this._cachedPosition=_.p.origin,this._cachedRotateData={sin:0,cos:0},this._cachedTransform={a:1,b:0,c:0,d:1},this._calcPosition=(t,i)=>{let e=n.rq,a=t?_.p.create(t.x,t.y,i):void 0;const r=this.container,o=Array.from(r.plugins),h=this.options.move.outModes,c=this.getRadius(),l=r.canvas.size,d=new AbortController,{signal:p}=d;for(;!p.aborted;){for(const t of o){const e=t.particlePosition?.(a,this);if(e)return _.p.create(e.x,e.y,i)}const t=(0,s.Nx)({size:l,position:a}),r=_.p.create(t.x,t.y,i);this._fixHorizontal(r,c,h.left??h.default),this._fixHorizontal(r,c,h.right??h.default),this._fixVertical(r,c,h.top??h.default),this._fixVertical(r,c,h.bottom??h.default);let d=!0;for(const t of o)if(d=t.checkParticlePosition?.(this,r,e)??!0,!d)break;if(d)return r;e+=n.Eo,a=void 0}return a},this._calculateVelocity=()=>{const t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===g.F.inside||i.direction===g.F.outside)return t;const e=(0,s.pu)((0,s.VG)(i.angle.value)),a=(0,s.pu)((0,s.VG)(i.angle.offset)),r={left:a-e*n.MX,right:a+e*n.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(r.left,r.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t},this._fixHorizontal=(t,i,e)=>{w({outMode:e,checkModes:[y.Y.bounce],coord:t.x,maxCoord:this.container.canvas.size.width,setCb:i=>t.x+=i,radius:i})},this._fixVertical=(t,i,e)=>{w({outMode:e,checkModes:[y.Y.bounce],coord:t.y,maxCoord:this.container.canvas.size.height,setCb:i=>t.y+=i,radius:i})},this._getRollColor=t=>t&&this.roll&&(this.backColor||this.roll.alter)&&this.isShowingBack()?this.backColor?this.backColor:this.roll.alter?(0,a.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t,this._initPosition=t=>{const i=this.container,e=(0,s.VG)(this.options.zIndex.value),a=this._calcPosition(t,(0,s.qE)(e,n.X_,i.zLayers));if(!a)throw new Error("a valid position cannot be found for particle");this.position=a,this.initialPosition=this.position.copy();const o=i.canvas.size;switch(this.moveCenter={...(0,r.E9)(this.options.move.center,o),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case g.F.inside:this.outType=m.x.inside;break;case g.F.outside:this.outType=m.x.outside}this.offset=_.M.origin},this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;const i=this.container,e=this.pathGenerator,s=this.shape?i.shapeDrawers.get(this.shape):void 0;s?.particleDestroy?.(this);for(const e of i.plugins)e.particleDestroyed?.(this,t);for(const e of i.particles.updaters)e.particleDestroyed?.(this,t);e?.reset(this),this._engine.dispatchEvent(p.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){const i=this.container,e=i.canvas;for(const s of i.plugins)e.drawParticlePlugin(s,this,t);e.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:n.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.color))}getMass(){return this.getRadius()**n.dm*Math.PI*n.MX}getOpacity(){const t=this.options.zIndex,i=(n.RV-this.zIndexFactor)**t.opacityRate,e=this.bubble.opacity??(0,s.VG)(this.opacity?.value??n.hv),a=this.strokeOpacity??e;return this._cachedOpacityData.opacity=e*i,this._cachedOpacityData.strokeOpacity=a*i,this._cachedOpacityData}getPosition(){return this._cachedPosition.x=this.position.x+this.offset.x,this._cachedPosition.y=this.position.y+this.offset.y,this._cachedPosition.z=this.position.z,this._cachedPosition}getRadius(){return this.bubble.radius??this.size.value}getRotateData(){const t=this.getAngle();return this._cachedRotateData.sin=Math.sin(t),this._cachedRotateData.cos=Math.cos(t),this._cachedRotateData}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.strokeColor))}getTransformData(t){const i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??n.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??n.D_):t.b??n.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??n.D_):t.c??n.Ug.c,this._cachedTransform.d=i.cos*(t.d??n.Ug.d),this._cachedTransform}init(t,i,e,a){const o=this.container;this.id=t,this.group=a,this.effectClose=!0,this.effectFill=!0,this.shapeClose=!0,this.shapeFill=!0,this.pathRotation=!1,this.lastPathTime=0,this.destroyed=!1,this.unbreakable=!1,this.isRotating=!1,this.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType=m.x.normal,this.ignoresResizeRatio=!0;const h=o.retina.pixelRatio,c=o.actualOptions,l=(0,v.y)(this._engine,o,c.particles),d=l.reduceDuplicates,p=l.effect.type,u=l.shape.type;this.effect=(0,r.TA)(p,this.id,d),this.shape=(0,r.TA)(u,this.id,d);const f=l.effect,_=l.shape;if(e){if(e.effect?.type){const t=e.effect.type,i=(0,r.TA)(t,this.id,d);i&&(this.effect=i,f.load(e.effect))}if(e.shape?.type){const t=e.shape.type,i=(0,r.TA)(t,this.id,d);i&&(this.shape=i,_.load(e.shape))}}if(this.effect===n.mR){const t=[...this.container.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===n.mR){const t=[...this.container.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?function(t,i,e,s){const n=i.options[t];return(0,r.zw)({close:i.close,fill:i.fill},(0,r.TA)(n,e,s))}(this.effect,f,this.id,d):void 0,this.shapeData=this.shape?function(t,i,e,s){const n=i.options[t];return(0,r.zw)({close:i.close,fill:i.fill},(0,r.TA)(n,e,s))}(this.shape,_,this.id,d):void 0,l.load(e);const g=this.effectData;g&&l.load(g.particles);const y=this.shapeData;y&&l.load(y.particles),this.effectFill=g?.fill??l.effect.fill,this.effectClose=g?.close??l.effect.close,this.shapeFill=y?.fill??l.shape.fill,this.shapeClose=y?.close??l.shape.close,this.options=l;const w=this.options.move.path;this.pathDelay=(0,s.VG)(w.delay.value)*n.Xu,w.generator&&(this.pathGenerator=this._engine.getPathGenerator(w.generator),this.pathGenerator&&o.addPath(w.generator,this.pathGenerator)&&this.pathGenerator.init(o)),o.retina.initParticle(this),this.size=(0,r.Xs)(this.options.size,h),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy(),this.moveDecay=n.WH-(0,s.VG)(this.options.move.decay);const b=o.particles;let z,P;b.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/o.zLayers,this.sides=24,this.effect&&(z=o.effectDrawers.get(this.effect),z||(z=this._engine.getEffectDrawer(this.effect),z&&o.effectDrawers.set(this.effect,z))),z?.loadEffect&&z.loadEffect(this),this.shape&&(P=o.shapeDrawers.get(this.shape),P||(P=this._engine.getShapeDrawer(this.shape),P&&o.shapeDrawers.set(this.shape,P))),P?.loadShape&&P.loadShape(this);const S=P?.getSidesCount;S&&(this.sides=S(this)),this.spawning=!1;for(const t of b.updaters)t.init(this);for(const t of b.movers)t.init(this);z?.particleInit?.(o,this),P?.particleInit?.(o,this);for(const t of o.plugins)t.particleCreated?.(this)}isInsideCanvas(){const t=this.getRadius(),i=this.container.canvas.size,e=this.position;return e.x>=-t&&e.y>=-t&&e.y<=i.height+t&&e.x<=i.width+t}isShowingBack(){if(!this.roll)return!1;const t=this.roll.angle;if(this.roll.horizontal&&this.roll.vertical){const i=t%n.R1,e=i<n.tA?i+n.R1:i;return e>=Math.PI*n.MX&&e<Math.PI*n.Nu*n.MX}if(this.roll.horizontal){const i=(t+Math.PI*n.MX)%(Math.PI*n.gd),e=i<n.tA?i+Math.PI*n.gd:i;return e>=Math.PI&&e<Math.PI*n.gd}if(this.roll.vertical){const i=t%(Math.PI*n.gd),e=i<n.tA?i+Math.PI*n.gd:i;return e>=Math.PI&&e<Math.PI*n.gd}return!1}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){for(const t of this.container.particles.updaters)t.reset?.(this)}}var z=e(8229),P=e(2984);class S{constructor(t,i){this.rectangle=t,this.capacity=i,this._subdivide=()=>{const{x:t,y:i}=this.rectangle.position,{width:e,height:s}=this.rectangle.size,{capacity:a}=this;for(let r=0;r<n.Pg;r++){const o=r%n.gd;this._subs.push(new S(new P.M_(t+e*n.MX*o,i+s*n.MX*(Math.round(r*n.MX)-o),e*n.MX,s*n.MX),a))}this._divided=!0},this._points=[],this._divided=!1,this._subs=[]}insert(t){return!!this.rectangle.contains(t.position)&&(this._points.length<this.capacity?(this._points.push(t),!0):(this._divided||this._subdivide(),this._subs.some((i=>i.insert(t)))))}query(t,i){const e=[];if(!t.intersects(this.rectangle))return[];for(const n of this._points)!t.contains(n.position)&&(0,s.Yf)(t.position,n.position)>n.particle.getRadius()&&(!i||i(n.particle))||e.push(n.particle);if(this._divided)for(const s of this._subs)e.push(...s.query(t,i));return e}queryCircle(t,i,e){return this.query(new P.jl(t.x,t.y,i),e)}queryRectangle(t,i,e){return this.query(new P.M_(t.x,t.y,i.width,i.height),e)}}var x=e(7932);const D=t=>{const{height:i,width:e}=t;return new P.M_(n.un*e,n.un*i,n.Rh*e,n.Rh*i)};class O{constructor(t,i){this._addToPool=(...t)=>{this._pool.push(...t)},this._applyDensity=(t,i,e,s)=>{const a=t.number;if(!a.density.enable)return void(void 0===e?this._limit=a.limit.value:(s?.number.limit.value??a.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??a.limit.value));const r=this._initDensityFactor(a.density),o=a.value,h=a.limit.value>n.ou?a.limit.value:o,c=Math.min(o,h)*r+i,l=Math.min(this.count,this.filter((t=>t.group===e)).length);void 0===e?this._limit=a.limit.value*r:this._groupLimits.set(e,a.limit.value*r),l<c?this.push(Math.abs(c-l),void 0,t,e):l>c&&this.removeQuantity(l-c,e)},this._initDensityFactor=t=>{const i=this._container;if(!i.canvas.element||!t.enable)return n.lA;const e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**n.dm)},this._pushParticle=(t,i,e,s)=>{try{const n=this._pool.pop()??new b(this._engine,this._container);n.init(this._nextId,t,i,e);let a=!0;if(s&&(a=s(n)),!a)return;return this._array.push(n),this._zArray.push(n),this._nextId++,this._engine.dispatchEvent(p.B.particleAdded,{container:this._container,data:{particle:n}}),n}catch(t){(0,x.t)().warning(`error adding particle: ${t}`)}},this._removeParticle=(t,i,e)=>{const s=this._array[t];if(!s)return!1;if(s.group!==i)return!1;const a=this._zArray.indexOf(s);return this._array.splice(t,n.LD),this._zArray.splice(a,n.LD),s.destroy(e),this._engine.dispatchEvent(p.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0},this._engine=t,this._container=i,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._lastZIndex=0,this._pluginsInitialized=!1;const e=i.canvas.size;this.quadTree=new S(D(e),n.Kw),this.movers=[],this.updaters=[]}get count(){return this._array.length}addParticle(t,i,e,s){const a=this._container.actualOptions.particles.number.limit.mode,r=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,o=this.count;if(r>n.ou)switch(a){case f.d.delete:{const t=o+n.nq-r;t>n.wM&&this.removeQuantity(t);break}case f.d.wait:if(o>=r)return}return this._pushParticle(t,i,e,s)}clear(){this._array=[],this._zArray=[],this._pluginsInitialized=!1}destroy(){this._array=[],this._zArray=[],this.movers=[],this.updaters=[]}drawParticles(t){for(const i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}async init(){const t=this._container,i=t.actualOptions;this._lastZIndex=0,this._needsSort=!1;for(const i of t.plugins)i.redrawInit&&await i.redrawInit();await this.initPlugins();let e=!1;for(const i of t.plugins)if(e=i.particlesInitialization?.()??e,e)break;if(!e){const t=i.particles,e=t.groups;for(const i in e){const s=e[i];if(s)for(let e=this.count,n=0;n<s.number.value&&e<t.number.value;e++,n++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){if(this._pluginsInitialized)return;const t=this._container;this.movers=await this._engine.getMovers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0);for(const i of t.pathGenerators.values())i.init(t)}push(t,i,e,s){for(let n=0;n<t;n++)this.addParticle(i,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=n.xd,e,s){if(t<n.z9||t>this.count)return;let a=0;for(let n=t;a<i&&n<this.count;n++)this._removeParticle(n,e,s)&&(n--,a++)}removeQuantity(t,i){this.removeAt(n.z9,t,i)}setDensity(){const t=this._container.actualOptions,i=t.particles.groups;let e=0;for(const t of this._container.plugins)t.particlesDensityCount&&(e+=t.particlesDensityCount());for(const t in i){const s=i[t];if(!s)continue;const n=(0,v.y)(this._engine,this._container,s);this._applyDensity(n,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._lastZIndex=t,this._needsSort=this._needsSort||this._lastZIndex<t}setResizeFactor(t){this._resizeFactor=t}update(t){const i=this._container,e=new Set;this.quadTree=new S(D(i.canvas.size),n.Kw);for(const t of i.pathGenerators.values())t.update();for(const e of i.plugins)e.update?.(t);const s=this._resizeFactor;for(const i of this._array){s&&!i.ignoresResizeRatio&&(i.position.x*=s.width,i.position.y*=s.height,i.initialPosition.x*=s.width,i.initialPosition.y*=s.height),i.ignoresResizeRatio=!1;for(const t of this._container.plugins)t.particleReset&&t.particleReset(i);for(const e of this._container.plugins){if(i.destroyed)break;e.particleUpdate?.(i,t)}for(const e of this.movers)e.isEnabled(i)&&e.move(i,t);i.destroyed?e.add(i):this.quadTree.insert(new z.b(i.getPosition(),i))}if(e.size){const t=t=>!e.has(t);this._array=this.filter(t),this._zArray=this._zArray.filter(t);for(const t of e)this._engine.dispatchEvent(p.B.particleRemoved,{container:this._container,data:{particle:t}});this._addToPool(...e)}for(const e of i.plugins)e.postUpdate&&e.postUpdate(t);for(const e of this._array){for(const i of this.updaters)i.update(e,t);if(!e.destroyed&&!e.spawning)for(const s of i.plugins)s.postParticleUpdate&&s.postParticleUpdate(e,t)}if(delete this._resizeFactor,this._needsSort){const t=this._zArray;t.sort(((t,i)=>i.position.z-t.position.z||t.id-i.id));const i=t[t.length-n.K3];if(!i)return;this._lastZIndex=i.position.z,this._needsSort=!1}}}class R{constructor(t){this.container=t,this.pixelRatio=n.$x,this.reduceFactor=n.Zp}init(){const t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:n.$x,this.reduceFactor=n.Zp;const e=this.pixelRatio,a=t.canvas;if(a.element){const t=a.element;a.size.width=t.offsetWidth*e,a.size.height=t.offsetHeight*e}const r=i.particles,o=r.move;this.maxSpeed=(0,s.VG)(o.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(r.size.animation.speed)*e}initParticle(t){const i=t.options,e=this.pixelRatio,n=i.move,a=n.distance,r=t.retina;r.moveDrift=(0,s.VG)(n.drift)*e,r.moveSpeed=(0,s.VG)(n.speed)*e,r.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;const o=r.maxDistance;o.horizontal=void 0!==a.horizontal?a.horizontal*e:void 0,o.vertical=void 0!==a.vertical?a.vertical*e:void 0,r.maxSpeed=(0,s.VG)(n.gravity.maxSpeed)*e}}function C(t){return!t.destroyed}function M(t,i,...e){const s=new u.J(t,i);return(0,v.Z)(s,...e),s}class T{constructor(t,i,e){this._delta={value:0,factor:0},this._nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+n.Xu/this.fpsLimit)return void this.draw(!1);if(this._lastFrameTime??=t,function(t,i,e=n.z$,s=!1){t.value=i,t.factor=s?n.z$/e:n.z$*i/n.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>n.Xu)return void this.draw(!1);if(this.canvas.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,x.t)().error("error in animation loop",t)}},this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new R(this),this.canvas=new l(this,this._engine),this.particles=new O(this._engine,this),this.pathGenerators=new Map,this.plugins=[],this.effectDrawers=new Map,this.shapeDrawers=new Map,this._options=M(this._engine,this),this.actualOptions=M(this._engine,this),this._eventListeners=new d(this),this._engine.dispatchEvent(p.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&C(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addLifeTime(t){this._lifeTime+=t}addPath(t,i,e=!1){return!(!C(this)||!e&&this.pathGenerators.has(t))&&(this.pathGenerators.set(t,i),!0)}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(t=!0){if(C(this)){this.stop(),this.particles.destroy(),this.canvas.destroy();for(const t of this.effectDrawers.values())t.destroy?.(this);this.effectDrawers.clear();for(const t of this.shapeDrawers.values())t.destroy?.(this);this.shapeDrawers.clear();for(const t of this.plugins)t.destroy?.();if(this.plugins.length=0,this._engine.clearPlugins(this),this.destroyed=!0,t){const t=this._engine.items,i=t.indexOf(this);i>=n.vF&&t.splice(i,n.JC)}this._engine.dispatchEvent(p.B.containerDestroyed,{container:this})}}draw(t){if(!C(this))return;let i=t;const e=t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)};this._drawAnimationFrame=(0,s.i0)((t=>{e(t)}))}async export(t,i={}){for(const e of this.plugins){if(!e.export)continue;const s=await e.export(t,i);if(s.supported)return s.blob}(0,x.t)().error(`Export plugin with type ${t} not found`)}async init(){if(!C(this))return;const t=this._engine.getSupportedEffects();for(const i of t){const t=this._engine.getEffectDrawer(i);t&&this.effectDrawers.set(i,t)}const i=this._engine.getSupportedShapes();for(const t of i){const i=this._engine.getShapeDrawer(t);i&&this.shapeDrawers.set(t,i)}const e=new Map;for(const t of this._engine.plugins){const i=await t.getPlugin(this);i.preInit&&await i.preInit(),e.set(t,i)}await this.particles.initPlugins(),this._options=M(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=M(this._engine,this,this._options);for(const[t,i]of e)t.needsPlugin(this.actualOptions)&&this.plugins.push(i);this.retina.init(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();const{delay:a,duration:r,fpsLimit:o,hdr:h,smooth:c,zLayers:l}=this.actualOptions;this.hdr=h,this.zLayers=l,this._duration=(0,s.VG)(r)*n.Xu,this._delay=(0,s.VG)(a)*n.Xu,this._lifeTime=0,this.fpsLimit=o>n.DN?o:n.i8,this._smooth=c;for(const t of this.plugins)await(t.init?.());for(const t of this.effectDrawers.values())await(t.init?.(this));for(const t of this.shapeDrawers.values())await(t.init?.(this));this._engine.dispatchEvent(p.B.containerInit,{container:this}),await this.particles.init(),this.particles.setDensity();for(const t of this.plugins)t.particlesSetup?.();this._engine.dispatchEvent(p.B.particlesSetup,{container:this})}pause(){if(C(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(const t of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(p.B.containerPaused,{container:this})}}play(t){if(!C(this))return;const i=this._paused||t;if(!this._firstStart||this.actualOptions.autoPlay){if(this._paused&&(this._paused=!1),i)for(const t of this.plugins)t.play&&t.play();this._engine.dispatchEvent(p.B.containerPlay,{container:this}),this.draw(i??!1)}else this._firstStart=!1}async refresh(){if(C(this))return this.stop(),this.start()}async reset(t){if(C(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=M(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=M(this._engine,this,this._options),this.refresh()}async start(){C(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise((t=>{const i=async()=>{this._eventListeners.addListeners();for(const t of this.plugins)await(t.start?.());this._engine.dispatchEvent(p.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout((()=>{i()}),this._delay)})))}stop(){if(C(this)&&this.started){this._delayTimeout&&(clearTimeout(this._delayTimeout),delete this._delayTimeout),this._firstStart=!0,this.started=!1,this._eventListeners.removeListeners(),this.pause(),this.particles.clear(),this.canvas.stop();for(const t of this.plugins)t.stop?.();this.plugins.length=0,this._sourceOptions=this._options,this._engine.dispatchEvent(p.B.containerStopped,{container:this})}}updateActualOptions(){let t=!1;for(const i of this.plugins)i.updateActualOptions&&(t=i.updateActualOptions()||t);return t}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Engine v4.0.0-alpha.8 by Matteo Bruni */
@@ -1,469 +0,0 @@
1
- import { clear, drawParticle, drawParticlePlugin, paintBase, paintImage } from "../Utils/CanvasUtils.js";
2
- import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
3
- import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
4
- import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
5
- const fColorIndex = 0, sColorIndex = 1;
6
- function setTransformValue(factor, newFactor, key) {
7
- const newValue = newFactor[key];
8
- if (newValue !== undefined) {
9
- factor[key] = (factor[key] ?? defaultTransformValue) * newValue;
10
- }
11
- }
12
- function setStyle(canvas, style, important = false) {
13
- if (!style) {
14
- return;
15
- }
16
- const element = canvas, elementStyle = element.style, keys = new Set();
17
- for (let i = 0; i < elementStyle.length; i++) {
18
- const key = elementStyle.item(i);
19
- if (!key) {
20
- continue;
21
- }
22
- keys.add(key);
23
- }
24
- for (let i = 0; i < style.length; i++) {
25
- const key = style.item(i);
26
- if (!key) {
27
- continue;
28
- }
29
- keys.add(key);
30
- }
31
- for (const key of keys) {
32
- const value = style.getPropertyValue(key);
33
- if (value) {
34
- elementStyle.setProperty(key, value, important ? "important" : "");
35
- }
36
- else {
37
- elementStyle.removeProperty(key);
38
- }
39
- }
40
- }
41
- export class Canvas {
42
- constructor(container, engine) {
43
- this.container = container;
44
- this._reusableColorStyles = {};
45
- this._reusablePluginColors = [undefined, undefined];
46
- this._reusableTransform = {};
47
- this._applyPostDrawUpdaters = particle => {
48
- for (const updater of this._postDrawUpdaters) {
49
- updater.afterDraw?.(particle);
50
- }
51
- };
52
- this._applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
53
- for (const updater of this._preDrawUpdaters) {
54
- if (updater.getColorStyles) {
55
- const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
56
- if (fill) {
57
- colorStyles.fill = fill;
58
- }
59
- if (stroke) {
60
- colorStyles.stroke = stroke;
61
- }
62
- }
63
- if (updater.getTransformValues) {
64
- const updaterTransform = updater.getTransformValues(particle);
65
- for (const key in updaterTransform) {
66
- setTransformValue(transform, updaterTransform, key);
67
- }
68
- }
69
- updater.beforeDraw?.(particle);
70
- }
71
- };
72
- this._applyResizePlugins = () => {
73
- for (const plugin of this._resizePlugins) {
74
- plugin.resize?.();
75
- }
76
- };
77
- this._getPluginParticleColors = particle => {
78
- let fColor, sColor;
79
- for (const plugin of this._colorPlugins) {
80
- if (!fColor && plugin.particleFillColor) {
81
- fColor = rangeColorToHsl(this._engine, plugin.particleFillColor(particle));
82
- }
83
- if (!sColor && plugin.particleStrokeColor) {
84
- sColor = rangeColorToHsl(this._engine, plugin.particleStrokeColor(particle));
85
- }
86
- if (fColor && sColor) {
87
- break;
88
- }
89
- }
90
- this._reusablePluginColors[fColorIndex] = fColor;
91
- this._reusablePluginColors[sColorIndex] = sColor;
92
- return this._reusablePluginColors;
93
- };
94
- this._initStyle = () => {
95
- const element = this.element, options = this.container.actualOptions;
96
- if (!element) {
97
- return;
98
- }
99
- if (this._fullScreen) {
100
- this._setFullScreenStyle();
101
- }
102
- else {
103
- this._resetOriginalStyle();
104
- }
105
- for (const key in options.style) {
106
- if (!key || !Object.hasOwn(options.style, key)) {
107
- continue;
108
- }
109
- const value = options.style[key];
110
- if (!value) {
111
- continue;
112
- }
113
- element.style.setProperty(key, value, "important");
114
- }
115
- };
116
- this._repairStyle = () => {
117
- const element = this.element;
118
- if (!element) {
119
- return;
120
- }
121
- this._safeMutationObserver(observer => {
122
- observer.disconnect();
123
- });
124
- this._initStyle();
125
- this.initBackground();
126
- const pointerEvents = this._pointerEvents;
127
- element.style.pointerEvents = pointerEvents;
128
- element.setAttribute("pointer-events", pointerEvents);
129
- this._safeMutationObserver(observer => {
130
- if (!(element instanceof Node)) {
131
- return;
132
- }
133
- observer.observe(element, { attributes: true });
134
- });
135
- };
136
- this._resetOriginalStyle = () => {
137
- const element = this.element, originalStyle = this._originalStyle;
138
- if (!element || !originalStyle) {
139
- return;
140
- }
141
- setStyle(element, originalStyle, true);
142
- };
143
- this._safeMutationObserver = callback => {
144
- if (!this._mutationObserver) {
145
- return;
146
- }
147
- callback(this._mutationObserver);
148
- };
149
- this._setFullScreenStyle = () => {
150
- const element = this.element;
151
- if (!element) {
152
- return;
153
- }
154
- setStyle(element, getFullScreenStyle(this.container.actualOptions.fullScreen.zIndex), true);
155
- };
156
- this._engine = engine;
157
- this._standardSize = {
158
- height: 0,
159
- width: 0,
160
- };
161
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
162
- this.size = {
163
- height: stdSize.height * pxRatio,
164
- width: stdSize.width * pxRatio,
165
- };
166
- this._context = null;
167
- this._generated = false;
168
- this._preDrawUpdaters = [];
169
- this._postDrawUpdaters = [];
170
- this._resizePlugins = [];
171
- this._colorPlugins = [];
172
- this._pointerEvents = "none";
173
- }
174
- get _fullScreen() {
175
- return this.container.actualOptions.fullScreen.enable;
176
- }
177
- canvasClear() {
178
- if (!this.container.actualOptions.clear) {
179
- return;
180
- }
181
- this.draw(ctx => {
182
- clear(ctx, this.size);
183
- });
184
- }
185
- clear() {
186
- let pluginHandled = false;
187
- for (const plugin of this.container.plugins) {
188
- if (!pluginHandled && plugin.canvasClear) {
189
- pluginHandled = plugin.canvasClear();
190
- }
191
- }
192
- if (pluginHandled) {
193
- return;
194
- }
195
- this.canvasClear();
196
- }
197
- destroy() {
198
- this.stop();
199
- if (this._generated) {
200
- const element = this.element;
201
- element?.remove();
202
- this.element = undefined;
203
- }
204
- else {
205
- this._resetOriginalStyle();
206
- }
207
- this._preDrawUpdaters = [];
208
- this._postDrawUpdaters = [];
209
- this._resizePlugins = [];
210
- this._colorPlugins = [];
211
- }
212
- draw(cb) {
213
- const ctx = this._context;
214
- if (!ctx) {
215
- return;
216
- }
217
- return cb(ctx);
218
- }
219
- drawParticle(particle, delta) {
220
- if (particle.spawning || particle.destroyed) {
221
- return;
222
- }
223
- const radius = particle.getRadius();
224
- if (radius <= minimumSize) {
225
- return;
226
- }
227
- const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor() ?? pfColor;
228
- let [fColor, sColor] = this._getPluginParticleColors(particle);
229
- fColor ??= pfColor;
230
- sColor ??= psColor;
231
- if (!fColor && !sColor) {
232
- return;
233
- }
234
- const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? getStyleFromHsl(fColor, container.hdr, opacity) : undefined, stroke = sColor ? getStyleFromHsl(sColor, container.hdr, strokeOpacity) : fill;
235
- transform.a = transform.b = transform.c = transform.d = undefined;
236
- colorStyles.fill = fill;
237
- colorStyles.stroke = stroke;
238
- this.draw((context) => {
239
- for (const plugin of container.plugins) {
240
- if (plugin.drawParticleSetup) {
241
- plugin.drawParticleSetup(context, particle, delta);
242
- }
243
- }
244
- this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
245
- drawParticle({
246
- container,
247
- context,
248
- particle,
249
- delta,
250
- colorStyles,
251
- radius: radius * zIndexFactor ** zIndexOptions.sizeRate,
252
- opacity: opacity,
253
- transform,
254
- });
255
- this._applyPostDrawUpdaters(particle);
256
- for (const plugin of container.plugins) {
257
- if (plugin.drawParticleCleanup) {
258
- plugin.drawParticleCleanup(context, particle, delta);
259
- }
260
- }
261
- });
262
- }
263
- drawParticlePlugin(plugin, particle, delta) {
264
- this.draw(ctx => {
265
- drawParticlePlugin(ctx, plugin, particle, delta);
266
- });
267
- }
268
- drawParticles(delta) {
269
- const { particles, plugins } = this.container;
270
- this.clear();
271
- particles.update(delta);
272
- this.draw(ctx => {
273
- for (const plugin of plugins) {
274
- plugin.drawSettingsSetup?.(ctx, delta);
275
- }
276
- for (const plugin of plugins) {
277
- plugin.draw?.(ctx, delta);
278
- }
279
- particles.drawParticles(delta);
280
- for (const plugin of plugins) {
281
- plugin.clearDraw?.(ctx, delta);
282
- }
283
- for (const plugin of plugins) {
284
- plugin.drawSettingsCleanup?.(ctx, delta);
285
- }
286
- });
287
- }
288
- init() {
289
- this._safeMutationObserver(obs => {
290
- obs.disconnect();
291
- });
292
- this._mutationObserver = safeMutationObserver(records => {
293
- for (const record of records) {
294
- if (record.type === "attributes" && record.attributeName === "style") {
295
- this._repairStyle();
296
- }
297
- }
298
- });
299
- this.resize();
300
- this._initStyle();
301
- this.initBackground();
302
- this._safeMutationObserver(obs => {
303
- if (!this.element || !(this.element instanceof Node)) {
304
- return;
305
- }
306
- obs.observe(this.element, { attributes: true });
307
- });
308
- this.initUpdaters();
309
- this.initPlugins();
310
- this.paint();
311
- }
312
- initBackground() {
313
- const { container } = this, options = container.actualOptions, background = options.background, element = this.element;
314
- if (!element) {
315
- return;
316
- }
317
- const elementStyle = element.style, color = rangeColorToRgb(this._engine, background.color);
318
- if (color) {
319
- elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
320
- }
321
- else {
322
- elementStyle.backgroundColor = "";
323
- }
324
- elementStyle.backgroundImage = background.image || "";
325
- elementStyle.backgroundPosition = background.position || "";
326
- elementStyle.backgroundRepeat = background.repeat || "";
327
- elementStyle.backgroundSize = background.size || "";
328
- }
329
- initPlugins() {
330
- this._resizePlugins = [];
331
- for (const plugin of this.container.plugins) {
332
- if (plugin.resize) {
333
- this._resizePlugins.push(plugin);
334
- }
335
- if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
336
- this._colorPlugins.push(plugin);
337
- }
338
- }
339
- }
340
- initUpdaters() {
341
- this._preDrawUpdaters = [];
342
- this._postDrawUpdaters = [];
343
- for (const updater of this.container.particles.updaters) {
344
- if (updater.afterDraw) {
345
- this._postDrawUpdaters.push(updater);
346
- }
347
- if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
348
- this._preDrawUpdaters.push(updater);
349
- }
350
- }
351
- }
352
- loadCanvas(canvas) {
353
- if (this._generated && this.element) {
354
- this.element.remove();
355
- }
356
- const container = this.container;
357
- this._generated =
358
- generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
359
- this.element = canvas;
360
- this.element.ariaHidden = "true";
361
- this._originalStyle = cloneStyle(this.element.style);
362
- const standardSize = this._standardSize;
363
- standardSize.height = canvas.offsetHeight;
364
- standardSize.width = canvas.offsetWidth;
365
- const pxRatio = this.container.retina.pixelRatio, retinaSize = this.size;
366
- canvas.height = retinaSize.height = standardSize.height * pxRatio;
367
- canvas.width = retinaSize.width = standardSize.width * pxRatio;
368
- const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
369
- this._context = this.element.getContext("2d", {
370
- alpha: true,
371
- colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
372
- desynchronized: true,
373
- willReadFrequently: false,
374
- });
375
- this._safeMutationObserver(obs => {
376
- obs.disconnect();
377
- });
378
- container.retina.init();
379
- this.initBackground();
380
- this._safeMutationObserver(obs => {
381
- if (!this.element || !(this.element instanceof Node)) {
382
- return;
383
- }
384
- obs.observe(this.element, { attributes: true });
385
- });
386
- }
387
- paint() {
388
- let handled = false;
389
- for (const plugin of this.container.plugins) {
390
- if (handled) {
391
- break;
392
- }
393
- handled = plugin.canvasPaint?.() ?? false;
394
- }
395
- if (handled) {
396
- return;
397
- }
398
- this.paintBase();
399
- }
400
- paintBase(baseColor) {
401
- this.draw(ctx => {
402
- paintBase(ctx, this.size, baseColor);
403
- });
404
- }
405
- paintImage(image, opacity) {
406
- this.draw(ctx => {
407
- paintImage(ctx, this.size, image, opacity);
408
- });
409
- }
410
- resize() {
411
- if (!this.element) {
412
- return false;
413
- }
414
- const container = this.container, currentSize = container.canvas._standardSize, newSize = {
415
- width: this.element.offsetWidth,
416
- height: this.element.offsetHeight,
417
- }, pxRatio = container.retina.pixelRatio, retinaSize = {
418
- width: newSize.width * pxRatio,
419
- height: newSize.height * pxRatio,
420
- };
421
- if (newSize.height === currentSize.height &&
422
- newSize.width === currentSize.width &&
423
- retinaSize.height === this.element.height &&
424
- retinaSize.width === this.element.width) {
425
- return false;
426
- }
427
- const oldSize = { ...currentSize };
428
- currentSize.height = newSize.height;
429
- currentSize.width = newSize.width;
430
- const canvasSize = this.size;
431
- this.element.width = canvasSize.width = retinaSize.width;
432
- this.element.height = canvasSize.height = retinaSize.height;
433
- if (this.container.started) {
434
- container.particles.setResizeFactor({
435
- width: currentSize.width / oldSize.width,
436
- height: currentSize.height / oldSize.height,
437
- });
438
- }
439
- return true;
440
- }
441
- setPointerEvents(type) {
442
- const element = this.element;
443
- if (!element) {
444
- return;
445
- }
446
- this._pointerEvents = type;
447
- this._repairStyle();
448
- }
449
- stop() {
450
- this._safeMutationObserver(obs => {
451
- obs.disconnect();
452
- });
453
- this._mutationObserver = undefined;
454
- this.draw(ctx => {
455
- clear(ctx, this.size);
456
- });
457
- }
458
- async windowResize() {
459
- if (!this.element || !this.resize()) {
460
- return;
461
- }
462
- const container = this.container, needsRefresh = container.updateActualOptions();
463
- container.particles.setDensity();
464
- this._applyResizePlugins();
465
- if (needsRefresh) {
466
- await container.refresh();
467
- }
468
- }
469
- }