@tsparticles/engine 4.0.0-beta.0 → 4.0.0-beta.2
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.
- package/155.min.js +1 -0
- package/README.md +0 -21
- package/browser/Core/CanvasManager.js +303 -0
- package/browser/Core/Container.js +64 -34
- package/browser/Core/Engine.js +26 -138
- package/browser/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/browser/Core/Particle.js +29 -28
- package/{cjs/Core/Particles.js → browser/Core/ParticlesManager.js} +28 -57
- package/browser/Core/RenderManager.js +303 -0
- package/browser/Core/Retina.js +3 -8
- package/browser/Core/Utils/PluginManager.js +145 -0
- package/browser/Options/Classes/Options.js +7 -7
- package/browser/Options/Classes/Particles/ParticlesOptions.js +5 -5
- package/browser/Types/CanvasContextType.js +1 -0
- package/browser/Utils/CanvasUtils.js +1 -1
- package/browser/Utils/ColorUtils.js +21 -21
- package/browser/Utils/LogUtils.js +1 -0
- package/browser/Utils/OptionsUtils.js +2 -2
- package/cjs/Core/CanvasManager.js +303 -0
- package/cjs/Core/Container.js +64 -34
- package/cjs/Core/Engine.js +26 -138
- package/cjs/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/cjs/Core/Particle.js +29 -28
- package/{esm/Core/Particles.js → cjs/Core/ParticlesManager.js} +28 -57
- package/cjs/Core/RenderManager.js +303 -0
- package/cjs/Core/Retina.js +3 -8
- package/cjs/Core/Utils/PluginManager.js +145 -0
- package/cjs/Options/Classes/Options.js +7 -7
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +5 -5
- package/cjs/Types/CanvasContextType.js +1 -0
- package/cjs/Utils/CanvasUtils.js +1 -1
- package/cjs/Utils/ColorUtils.js +21 -21
- package/cjs/Utils/LogUtils.js +1 -0
- package/cjs/Utils/OptionsUtils.js +2 -2
- package/dist_browser_Core_Container_js.js +24 -14
- package/esm/Core/CanvasManager.js +303 -0
- package/esm/Core/Container.js +64 -34
- package/esm/Core/Engine.js +26 -138
- package/esm/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/esm/Core/Particle.js +29 -28
- package/{browser/Core/Particles.js → esm/Core/ParticlesManager.js} +28 -57
- package/esm/Core/RenderManager.js +303 -0
- package/esm/Core/Retina.js +3 -8
- package/esm/Core/Utils/PluginManager.js +145 -0
- package/esm/Options/Classes/Options.js +7 -7
- package/esm/Options/Classes/Particles/ParticlesOptions.js +5 -5
- package/esm/Types/CanvasContextType.js +1 -0
- package/esm/Utils/CanvasUtils.js +1 -1
- package/esm/Utils/ColorUtils.js +21 -21
- package/esm/Utils/LogUtils.js +1 -0
- package/esm/Utils/OptionsUtils.js +2 -2
- package/package.json +2 -3
- package/report.html +84 -29
- package/tsparticles.engine.js +18 -8
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/CanvasManager.d.ts +39 -0
- package/types/Core/Container.d.ts +26 -7
- package/types/Core/Engine.d.ts +2 -54
- package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -7
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
- package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
- package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -1
- package/types/Core/Particle.d.ts +4 -4
- package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +4 -11
- package/types/Core/{Canvas.d.ts → RenderManager.d.ts} +12 -33
- package/types/Core/Retina.d.ts +0 -2
- package/types/Core/Utils/PluginManager.d.ts +62 -0
- package/types/Options/Classes/Options.d.ts +3 -3
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +3 -3
- package/types/Types/CanvasContextType.d.ts +1 -0
- package/types/Utils/CanvasUtils.d.ts +8 -5
- package/types/Utils/ColorUtils.d.ts +8 -8
- package/types/Utils/LogUtils.d.ts +1 -0
- package/types/Utils/OptionsUtils.d.ts +2 -2
- package/types/export-types.d.ts +4 -2
- package/164.min.js +0 -1
- package/browser/Core/Canvas.js +0 -570
- package/cjs/Core/Canvas.js +0 -570
- package/esm/Core/Canvas.js +0 -570
- package/umd/Core/Canvas.js +0 -584
- package/umd/Core/Container.js +0 -356
- package/umd/Core/Engine.js +0 -295
- package/umd/Core/Interfaces/Colors.js +0 -12
- package/umd/Core/Interfaces/IBounds.js +0 -12
- package/umd/Core/Interfaces/IBubbleParticleData.js +0 -12
- package/umd/Core/Interfaces/ICircleBouncer.js +0 -12
- package/umd/Core/Interfaces/IColorManager.js +0 -12
- package/umd/Core/Interfaces/IContainerPlugin.js +0 -12
- package/umd/Core/Interfaces/ICoordinates.js +0 -12
- package/umd/Core/Interfaces/IDelta.js +0 -12
- package/umd/Core/Interfaces/IDimension.js +0 -12
- package/umd/Core/Interfaces/IDistance.js +0 -12
- package/umd/Core/Interfaces/IDrawParticleParams.js +0 -12
- package/umd/Core/Interfaces/IEffectDrawer.js +0 -12
- package/umd/Core/Interfaces/ILoadParams.js +0 -12
- package/umd/Core/Interfaces/IPalette.js +0 -12
- package/umd/Core/Interfaces/IParticleColorStyle.js +0 -12
- package/umd/Core/Interfaces/IParticleHslAnimation.js +0 -12
- package/umd/Core/Interfaces/IParticleLife.js +0 -12
- package/umd/Core/Interfaces/IParticleOpacityData.js +0 -12
- package/umd/Core/Interfaces/IParticleRetinaProps.js +0 -12
- package/umd/Core/Interfaces/IParticleRoll.js +0 -12
- package/umd/Core/Interfaces/IParticleRotateData.js +0 -12
- package/umd/Core/Interfaces/IParticleTransformValues.js +0 -12
- package/umd/Core/Interfaces/IParticleUpdater.js +0 -12
- package/umd/Core/Interfaces/IParticleValueAnimation.js +0 -12
- package/umd/Core/Interfaces/IPlugin.js +0 -12
- package/umd/Core/Interfaces/IPositionFromSizeParams.js +0 -12
- package/umd/Core/Interfaces/IRangeValue.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawData.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawer.js +0 -12
- package/umd/Core/Interfaces/IShapeValues.js +0 -12
- package/umd/Core/Interfaces/ISlowParticleData.js +0 -12
- package/umd/Core/Particle.js +0 -432
- package/umd/Core/Particles.js +0 -407
- package/umd/Core/Retina.js +0 -52
- package/umd/Core/Utils/Constants.js +0 -23
- package/umd/Core/Utils/EventListeners.js +0 -102
- package/umd/Core/Utils/Ranges.js +0 -91
- package/umd/Core/Utils/SpatialHashGrid.js +0 -116
- package/umd/Core/Utils/Vectors.js +0 -126
- package/umd/Enums/AnimationStatus.js +0 -18
- package/umd/Enums/Directions/MoveDirection.js +0 -27
- package/umd/Enums/Directions/OutModeDirection.js +0 -20
- package/umd/Enums/Directions/RotateDirection.js +0 -19
- package/umd/Enums/Modes/AnimationMode.js +0 -20
- package/umd/Enums/Modes/LimitMode.js +0 -18
- package/umd/Enums/Modes/OutMode.js +0 -21
- package/umd/Enums/Modes/PixelMode.js +0 -18
- package/umd/Enums/RangeType.js +0 -18
- package/umd/Enums/Types/AlterType.js +0 -18
- package/umd/Enums/Types/DestroyType.js +0 -19
- package/umd/Enums/Types/EasingType.js +0 -58
- package/umd/Enums/Types/EventType.js +0 -28
- package/umd/Enums/Types/GradientType.js +0 -19
- package/umd/Enums/Types/ParticleOutType.js +0 -19
- package/umd/Enums/Types/StartValueType.js +0 -19
- package/umd/Options/Classes/AnimatableColor.js +0 -52
- package/umd/Options/Classes/AnimationOptions.js +0 -79
- package/umd/Options/Classes/Background/Background.js +0 -56
- package/umd/Options/Classes/ColorAnimation.js +0 -44
- package/umd/Options/Classes/FullScreen/FullScreen.js +0 -34
- package/umd/Options/Classes/HslAnimation.js +0 -30
- package/umd/Options/Classes/Options.js +0 -171
- package/umd/Options/Classes/OptionsColor.js +0 -42
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +0 -31
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -21
- package/umd/Options/Classes/Particles/Effect/Effect.js +0 -46
- package/umd/Options/Classes/Particles/Fill.js +0 -42
- package/umd/Options/Classes/Particles/Move/Move.js +0 -120
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +0 -35
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +0 -45
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +0 -45
- package/umd/Options/Classes/Particles/Move/OutModes.js +0 -38
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +0 -46
- package/umd/Options/Classes/Particles/Move/Spin.js +0 -40
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +0 -41
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +0 -37
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -34
- package/umd/Options/Classes/Particles/ParticlesOptions.js +0 -116
- package/umd/Options/Classes/Particles/Shape/Shape.js +0 -46
- package/umd/Options/Classes/Particles/Size/Size.js +0 -35
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -34
- package/umd/Options/Classes/Particles/Stroke.js +0 -39
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +0 -42
- package/umd/Options/Classes/ResizeEvent.js +0 -34
- package/umd/Options/Classes/ValueWithRandom.js +0 -56
- package/umd/Options/Interfaces/Background/IBackground.js +0 -12
- package/umd/Options/Interfaces/FullScreen/IFullScreen.js +0 -12
- package/umd/Options/Interfaces/IAnimatable.js +0 -12
- package/umd/Options/Interfaces/IAnimatableColor.js +0 -12
- package/umd/Options/Interfaces/IAnimation.js +0 -12
- package/umd/Options/Interfaces/IColorAnimation.js +0 -12
- package/umd/Options/Interfaces/IHslAnimation.js +0 -12
- package/umd/Options/Interfaces/IOptionLoader.js +0 -12
- package/umd/Options/Interfaces/IOptions.js +0 -12
- package/umd/Options/Interfaces/IOptionsColor.js +0 -12
- package/umd/Options/Interfaces/IResizeEvent.js +0 -12
- package/umd/Options/Interfaces/IValueWithRandom.js +0 -12
- package/umd/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +0 -12
- package/umd/Options/Interfaces/Particles/Effect/IEffect.js +0 -12
- package/umd/Options/Interfaces/Particles/IFill.js +0 -12
- package/umd/Options/Interfaces/Particles/IParticlesOptions.js +0 -12
- package/umd/Options/Interfaces/Particles/IStroke.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMove.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveAngle.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveCenter.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveGravity.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IOutModes.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/ISpin.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/Path/IMovePath.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesDensity.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumber.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISize.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/ZIndex/IZIndex.js +0 -12
- package/umd/Types/CustomEventArgs.js +0 -12
- package/umd/Types/CustomEventListener.js +0 -12
- package/umd/Types/EasingFunction.js +0 -12
- package/umd/Types/EngineInitializers.js +0 -12
- package/umd/Types/ExportResult.js +0 -12
- package/umd/Types/ISourceOptions.js +0 -12
- package/umd/Types/ParticlesGroups.js +0 -12
- package/umd/Types/PathOptions.js +0 -12
- package/umd/Types/RangeValue.js +0 -12
- package/umd/Types/RecursivePartial.js +0 -12
- package/umd/Types/ShapeData.js +0 -12
- package/umd/Types/SingleOrMultiple.js +0 -12
- package/umd/Utils/CanvasUtils.js +0 -145
- package/umd/Utils/ColorUtils.js +0 -395
- package/umd/Utils/EventDispatcher.js +0 -63
- package/umd/Utils/LogUtils.js +0 -36
- package/umd/Utils/MathUtils.js +0 -203
- package/umd/Utils/OptionsUtils.js +0 -25
- package/umd/Utils/TypeUtils.js +0 -40
- package/umd/Utils/Utils.js +0 -484
- package/umd/bundle.js +0 -32
- package/umd/export-types.js +0 -12
- package/umd/exports.js +0 -82
- package/umd/index.js +0 -32
- package/umd/initEngine.js +0 -17
package/155.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[155],{2155(t,i,e){e.d(i,{Container:()=>O});var s=e(3404),a=e(7574),r=e(7818),n=e(3723),l=e(8862);class o{_canvasClearPlugins;_canvasManager;_canvasPaintPlugins;_clearDrawPlugins;_colorPlugins;_container;_context;_contextSettings;_drawParticlePlugins;_drawParticlesCleanupPlugins;_drawParticlesSetupPlugins;_drawPlugins;_drawSettingsCleanupPlugins;_drawSettingsSetupPlugins;_pluginManager;_postDrawUpdaters;_preDrawUpdaters;_reusableColorStyles={};_reusablePluginColors=[void 0,void 0];_reusableTransform={};constructor(t,i,e){this._pluginManager=t,this._container=i,this._canvasManager=e,this._context=null,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[]}get settings(){return this._contextSettings}canvasClear(){this._container.actualOptions.clear&&this.draw(t=>{(0,l.IU)(t,this._canvasManager.size)})}clear(){let t=!1;for(let i of this._canvasClearPlugins)if(t=i.canvasClear?.()??!1)break;t||this.canvasClear()}destroy(){this.stop(),this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[]}draw(t){let i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;let e=t.getRadius();if(e<=a.w2)return;let s=t.getFillColor(),r=t.getStrokeColor(),[o,h]=this._getPluginParticleColors(t);if(o??=s,h??=r,!o&&!h)return;let c=this._container,d=t.options.zIndex,p=a.RV-t.zIndexFactor,{fillOpacity:u,opacity:_,strokeOpacity:g}=t.getOpacity(),f=this._reusableTransform,P=this._reusableColorStyles,m=o?(0,n.LC)(o,c.hdr,u*_):void 0,y=h?(0,n.LC)(h,c.hdr,g*_):m;f.a=f.b=f.c=f.d=void 0,P.fill=m,P.stroke=y,this.draw(s=>{for(let e of this._drawParticlesSetupPlugins)e.drawParticleSetup?.(s,t,i);for(let a of(this._applyPreDrawUpdaters(s,t,e,_,P,f),(0,l.p0)({container:c,context:s,particle:t,delta:i,colorStyles:P,radius:e*p**d.sizeRate,opacity:_,transform:f}),this._applyPostDrawUpdaters(t),this._drawParticlesCleanupPlugins))a.drawParticleCleanup?.(s,t,i)})}drawParticlePlugins(t,i){this.draw(e=>{for(let s of this._drawParticlePlugins)(0,l.Wb)(e,s,t,i)})}drawParticles(t){let{particles:i}=this._container;this.clear(),i.update(t),this.draw(e=>{for(let i of this._drawSettingsSetupPlugins)i.drawSettingsSetup?.(e,t);for(let i of this._drawPlugins)i.draw?.(e,t);for(let s of(i.drawParticles(t),this._clearDrawPlugins))s.clearDraw?.(e,t);for(let i of this._drawSettingsCleanupPlugins)i.drawSettingsCleanup?.(e,t)})}init(){this.initUpdaters(),this.initPlugins(),this.paint()}initPlugins(){for(let t of(this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesSetupPlugins=[],this._drawParticlesCleanupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this._container.plugins))(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t),t.canvasClear&&this._canvasClearPlugins.push(t),t.canvasPaint&&this._canvasPaintPlugins.push(t),t.drawParticle&&this._drawParticlePlugins.push(t),t.drawParticleSetup&&this._drawParticlesSetupPlugins.push(t),t.drawParticleCleanup&&this._drawParticlesCleanupPlugins.push(t),t.draw&&this._drawPlugins.push(t),t.drawSettingsSetup&&this._drawSettingsSetupPlugins.push(t),t.drawSettingsCleanup&&this._drawSettingsCleanupPlugins.push(t),t.clearDraw&&this._clearDrawPlugins.push(t)}initUpdaters(){for(let t of(this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._container.particleUpdaters))t.afterDraw&&this._postDrawUpdaters.push(t),(t.getColorStyles??t.getTransformValues??t.beforeDraw)&&this._preDrawUpdaters.push(t)}paint(){let t=!1;for(let i of this._canvasPaintPlugins)if(t=i.canvasPaint?.()??!1)break;t||this.paintBase()}paintBase(t){this.draw(i=>{(0,l.Sn)(i,this._canvasManager.size,t)})}paintImage(t,i){this.draw(e=>{(0,l.Md)(e,this._canvasManager.size,t,i)})}setContext(t){this._context=t,this._context&&(this._context.globalCompositeOperation=a.yj)}setContextSettings(t){this._contextSettings=t}stop(){this.draw(t=>{(0,l.IU)(t,this._canvasManager.size)})}_applyPostDrawUpdaters=t=>{for(let i of this._postDrawUpdaters)i.afterDraw?.(t)};_applyPreDrawUpdaters=(t,i,e,s,r,n)=>{for(let l of this._preDrawUpdaters){if(l.getColorStyles){let{fill:a,stroke:n}=l.getColorStyles(i,t,e,s);a&&(r.fill=a),n&&(r.stroke=n)}if(l.getTransformValues){let t=l.getTransformValues(i);for(let i in t)!function(t,i,e){let s=i[e];void 0!==s&&(t[e]=(t[e]??a.zs)*s)}(n,t,i)}l.beforeDraw?.(i)}};_getPluginParticleColors=t=>{let i,e;for(let s of this._colorPlugins)if(!i&&s.particleFillColor&&(i=(0,n.R5)(this._pluginManager,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,n.R5)(this._pluginManager,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors}}function h(t,i,e=!1){if(!i)return;let s=t.style,a=new Set;for(let t=0;t<s.length;t++){let i=s.item(t);i&&a.add(i)}for(let t=0;t<i.length;t++){let e=i.item(t);e&&a.add(e)}for(let t of a){let a=i.getPropertyValue(t);a?s.setProperty(t,a,e?"important":""):s.removeProperty(t)}}class c{element;render;size;zoom=a.Pf;_container;_generated;_mutationObserver;_originalStyle;_pluginManager;_pointerEvents;_resizePlugins;_standardSize;_zoomCenter;constructor(t,i){this._pluginManager=t,this._container=i,this.render=new o(t,i,this),this._standardSize={height:0,width:0};const e=i.retina.pixelRatio,s=this._standardSize;this.size={height:s.height*e,width:s.width*e},this._generated=!1,this._resizePlugins=[],this._pointerEvents="none"}get _fullScreen(){return this._container.actualOptions.fullScreen.enable}destroy(){if(this.stop(),this._generated){let t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this.render.destroy(),this._resizePlugins=[]}getZoomCenter(){let t=this._container.retina.pixelRatio,{width:i,height:e}=this.size;return this._zoomCenter?this._zoomCenter:{x:i*a.MX/t,y:e*a.MX/t}}init(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=(0,r.tG)(t=>{for(let 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.initPlugins(),this.render.init()}initBackground(){let{_container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;let s=e.style,a=(0,n.BN)(this._pluginManager,i.color);a?s.backgroundColor=(0,n.xx)(a,t.hdr,i.opacity):s.backgroundColor="",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){for(let t of(this._resizePlugins=[],this._container.plugins))t.resize&&this._resizePlugins.push(t)}loadCanvas(t){this._generated&&this.element&&this.element.remove();let i=this._container;this._generated=a.eb in t.dataset?"true"===t.dataset[a.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,r.td)(this.element.style);let e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;let s=this._container.retina.pixelRatio,n=this.size;t.height=n.height=e.height*s,t.width=n.width=e.width*s;let l=(0,r.lV)("(color-gamut: p3)");this.render.setContextSettings({alpha:!0,colorSpace:l?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1}),this.render.setContext(this.element.getContext("2d",this.render.settings)),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})})}resize(){if(!this.element)return!1;let t=this._container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,a={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&a.height===this.element.height&&a.width===this.element.width)return!1;let r={...i};i.height=e.height,i.width=e.width;let n=this.size;return this.element.width=n.width=a.width,this.element.height=n.height=a.height,this._container.started&&t.particles.setResizeFactor({width:i.width/r.width,height:i.height/r.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}setZoom(t,i){this.zoom=t,this._zoomCenter=i}stop(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=void 0,this.render.stop()}async windowResize(){if(!this.element||!this.resize())return;let t=this._container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}_applyResizePlugins=()=>{for(let t of this._resizePlugins)t.resize?.()};_initStyle=()=>{let t=this.element,i=this._container.actualOptions;if(t)for(let e in this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle(),i.style){if(!e||!(e in i.style))continue;let s=i.style[e];s&&t.style.setProperty(e,s,"important")}};_repairStyle=()=>{let t=this.element;if(!t)return;this._safeMutationObserver(t=>{t.disconnect()}),this._initStyle(),this.initBackground();let i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver(i=>{t instanceof Node&&i.observe(t,{attributes:!0})})};_resetOriginalStyle=()=>{let t=this.element,i=this._originalStyle;t&&i&&h(t,i,!0)};_safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)};_setFullScreenStyle=()=>{let t=this.element;t&&h(t,(0,r.hJ)(this._container.actualOptions.fullScreen.zIndex),!0)}}class d{container;_handlers;_resizeObserver;_resizeTimeout;constructor(t){this.container=t,this._handlers={visibilityChange:()=>{this._handleVisibilityChange()},resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}_handleVisibilityChange=()=>{let 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)))};_handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);let t=async()=>{let t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout(()=>void t(),this.container.actualOptions.resize.delay*a.Xu)};_manageListeners=t=>{let i=this._handlers;this._manageResize(t),(0,r.Kp)(document,a.nK,i.visibilityChange,t,!1)};_manageResize=t=>{let i=this._handlers,e=this.container;if(!e.actualOptions.resize.enable)return;if("u"<typeof ResizeObserver)return void(0,r.Kp)(globalThis,a.NF,i.resize,t);let 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))}}var p=e(9898),u=e(7849),_=e(7171),g=e(1859),f=e(1341),P=e(9300),m=e(6028),y=e(3468);function w(t){if(!(0,r.hn)(t.outMode,t.checkModes))return;let i=t.radius*a.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class v{backColor;bubble;destroyed;direction;effect;effectClose;effectData;fillColor;fillEnabled;fillOpacity;group;id;ignoresResizeRatio;initialPosition;initialVelocity;isRotating;lastPathTime;misplaced;moveCenter;offset;opacity;options;outType;pathRotation;position;randomIndexData;retina;roll;rotation;shape;shapeClose;shapeData;sides;size;slow;spawning;strokeColor;strokeOpacity;strokeWidth;unbreakable;velocity;zIndexFactor;_cachedOpacityData={fillOpacity:a.hv,opacity:a.hv,strokeOpacity:a.hv};_cachedPosition=g.p.origin;_cachedRotateData={sin:0,cos:0};_cachedTransform={a:1,b:0,c:0,d:1};_container;_pluginManager;constructor(t,i){this._pluginManager=t,this._container=i}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;let i=this._container,e=this.shape?i.shapeDrawers.get(this.shape):void 0;for(let s of(e?.particleDestroy?.(this),i.particleDestroyedPlugins))s.particleDestroyed?.(this,t);for(let e of i.particleUpdaters)e.particleDestroyed?.(this,t);this._container.dispatchEvent(p.B.particleDestroyed,{particle:this})}draw(t){let i=this._container.canvas.render;i.drawParticlePlugins(this,t),i.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:a.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,n.O_)(this.fillColor))}getMass(){return this.getRadius()**a.dm*Math.PI*a.MX}getOpacity(){let t=this.options.zIndex,i=a.RV-this.zIndexFactor,e=i**t.opacityRate,r=this.bubble.opacity??(0,s.VG)(this.opacity?.value??a.hv),n=this.fillOpacity??a.hv,l=this.strokeOpacity??a.hv;return this._cachedOpacityData.fillOpacity=r*n*e,this._cachedOpacityData.opacity=r*e,this._cachedOpacityData.strokeOpacity=r*l*e,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(){let 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,n.O_)(this.strokeColor))}getTransformData(t){let i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??a.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??a.D_):t.b??a.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??a.D_):t.c??a.Ug.c,this._cachedTransform.d=i.cos*(t.d??a.Ug.d),this._cachedTransform}init(t,i,e,n){var l,o,h,c;let d,p,u,_,g=this._container;this.id=t,this.group=n,this.effectClose=!0,this.shapeClose=!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:{},maxSpeed:0,moveDrift:0,moveSpeed:0,sizeAnimationSpeed:0},this.outType=m.x.normal,this.ignoresResizeRatio=!0;let f=g.retina.pixelRatio,P=g.actualOptions,w=(0,y.y)(this._pluginManager,g,P.particles),v=w.reduceDuplicates,z=w.effect.type,b=w.shape.type;this.effect=(0,r.TA)(z,this.id,v),this.shape=(0,r.TA)(b,this.id,v);let S=w.effect,C=w.shape;if(e){if(e.effect?.type){let t=e.effect.type,i=(0,r.TA)(t,this.id,v);i&&(this.effect=i,S.load(e.effect))}if(e.shape?.type){let t=e.shape.type,i=(0,r.TA)(t,this.id,v);i&&(this.shape=i,C.load(e.shape))}}if(this.effect===a.mR){let t=[...this._container.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===a.mR){let t=[...this._container.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?(l=this.effect,o=this.id,u=S.options[l],(0,r.zw)({close:S.close},(0,r.TA)(u,o,v))):void 0,this.shapeData=this.shape?(h=this.shape,c=this.id,_=C.options[h],(0,r.zw)({close:C.close},(0,r.TA)(_,c,v))):void 0,w.load(e);let x=this.effectData;x&&w.load(x.particles);let D=this.shapeData;D&&w.load(D.particles),this.effectClose=x?.close??w.effect.close,this.shapeClose=D?.close??w.shape.close,this.options=w,g.retina.initParticle(this),this.size=(0,r.Xs)(this.options.size,f),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy(),g.particles.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/g.zLayers,this.sides=24,this.effect&&(d=g.effectDrawers.get(this.effect)),d?.loadEffect&&d.loadEffect(this),this.shape&&(p=g.shapeDrawers.get(this.shape)),p?.loadShape&&p.loadShape(this);let M=p?.getSidesCount;for(let t of(M&&(this.sides=M(this)),this.spawning=!1,g.particleUpdaters))t.init(this);for(let t of(d?.particleInit?.(g,this),p?.particleInit?.(g,this),g.particleCreatedPlugins))t.particleCreated?.(this)}isInsideCanvas(){let 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;let t=this.roll.angle;if(this.roll.horizontal&&this.roll.vertical){let i=t%a.R1,e=i<a.tA?i+a.R1:i;return e>=Math.PI*a.MX&&e<Math.PI*a.Nu*a.MX}if(this.roll.horizontal){let i=(t+Math.PI*a.MX)%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}if(this.roll.vertical){let i=t%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}return!1}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){for(let t of this._container.particleUpdaters)t.reset?.(this)}_calcPosition=(t,i)=>{let e=a.rq,r=t?g.p.create(t.x,t.y,i):void 0,n=this._container,l=n.particlePositionPlugins,o=this.options.move.outModes,h=this.getRadius(),c=n.canvas.size,{signal:d}=new AbortController;for(;!d.aborted;){for(let t of l){let e=t.particlePosition?.(r,this);if(e)return g.p.create(e.x,e.y,i)}let t=(0,s.Nx)({size:c,position:r}),d=g.p.create(t.x,t.y,i);this._fixHorizontal(d,h,o.left??o.default),this._fixHorizontal(d,h,o.right??o.default),this._fixVertical(d,h,o.top??o.default),this._fixVertical(d,h,o.bottom??o.default);let p=!0;for(let t of n.particles.checkParticlePositionPlugins)if(!(p=t.checkParticlePosition?.(this,d,e)??!0))break;if(p)return d;e+=a.Eo,r=void 0}return r};_calculateVelocity=()=>{let t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===f.F.inside||i.direction===f.F.outside)return t;let e=(0,s.pu)((0,s.VG)(i.angle.value)),r=(0,s.pu)((0,s.VG)(i.angle.offset)),n={left:r-e*a.MX,right:r+e*a.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(n.left,n.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t};_fixHorizontal=(t,i,e)=>{w({outMode:e,checkModes:[P.Y.bounce],coord:t.x,maxCoord:this._container.canvas.size.width,setCb:i=>t.x+=i,radius:i})};_fixVertical=(t,i,e)=>{w({outMode:e,checkModes:[P.Y.bounce],coord:t.y,maxCoord:this._container.canvas.size.height,setCb:i=>t.y+=i,radius:i})};_getRollColor=t=>t&&this.roll&&(this.backColor||this.roll.alter)&&this.isShowingBack()?this.backColor?this.backColor:this.roll.alter?(0,n.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t;_initPosition=t=>{let i=this._container,e=(0,s.VG)(this.options.zIndex.value),n=this._calcPosition(t,(0,s.qE)(e,a.X_,i.zLayers));if(!n)throw Error("a valid position cannot be found for particle");this.position=n,this.initialPosition=this.position.copy();let l=i.canvas.size;switch(this.moveCenter={...(0,r.E9)(this.options.move.center,l),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 f.F.inside:this.outType=m.x.inside;break;case f.F.outside:this.outType=m.x.outside}this.offset=g.M.origin}}var z=e(8450);class b{_cellSize;_cells=new Map;_circlePool=[];_circlePoolIdx;_pendingCellSize;_rectanglePool=[];_rectanglePoolIdx;constructor(t){this._cellSize=t,this._circlePoolIdx=0,this._rectanglePoolIdx=0}clear(){this._cells.clear();let t=this._pendingCellSize;t&&(this._cellSize=t),this._pendingCellSize=void 0}insert(t){let{x:i,y:e}=t.getPosition(),s=this._cellKeyFromCoords(i,e);this._cells.has(s)||this._cells.set(s,[]),this._cells.get(s)?.push(t)}query(t,i,e=[]){let s=this._getRangeBounds(t);if(!s)return e;let a=Math.floor(s.minX/this._cellSize),r=Math.floor(s.maxX/this._cellSize),n=Math.floor(s.minY/this._cellSize),l=Math.floor(s.maxY/this._cellSize);for(let s=a;s<=r;s++)for(let a=n;a<=l;a++){let r=`${s}_${a}`,n=this._cells.get(r);if(n)for(let s of n)(!i||i(s))&&t.contains(s.getPosition())&&e.push(s)}return e}queryCircle(t,i,e,s=[]){let a=this._acquireCircle(t.x,t.y,i),r=this.query(a,e,s);return this._releaseShapes(),r}queryRectangle(t,i,e,s=[]){let a=this._acquireRectangle(t.x,t.y,i.width,i.height),r=this.query(a,e,s);return this._releaseShapes(),r}setCellSize(t){this._pendingCellSize=t}_acquireCircle(t,i,e){return(this._circlePool[this._circlePoolIdx++]??=new z.jl(t,i,e)).reset(t,i,e)}_acquireRectangle(t,i,e,s){return(this._rectanglePool[this._rectanglePoolIdx++]??=new z.M_(t,i,e,s)).reset(t,i,e,s)}_cellKeyFromCoords(t,i){let e=Math.floor(t/this._cellSize),s=Math.floor(i/this._cellSize);return`${e}_${s}`}_getRangeBounds(t){if(t instanceof z.jl){let i=t.radius,{x:e,y:s}=t.position;return{minX:e-i,maxX:e+i,minY:s-i,maxY:s+i}}if(t instanceof z.M_){let{x:i,y:e}=t.position,{width:s,height:a}=t.size;return{minX:i,maxX:i+s,minY:e,maxY:e+a}}return null}_releaseShapes(){this._circlePoolIdx=0,this._rectanglePoolIdx=0}}var S=e(5576);class C{checkParticlePositionPlugins;grid;_array;_container;_groupLimits;_limit;_maxZIndex;_minZIndex;_needsSort;_nextId;_particleResetPlugins;_particleUpdatePlugins;_pluginManager;_pool;_postParticleUpdatePlugins;_postUpdatePlugins;_resizeFactor;_updatePlugins;_zArray;constructor(t,i){this._pluginManager=t,this._container=i,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._minZIndex=0,this._maxZIndex=0,this.grid=new b(a.iX),this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}get count(){return this._array.length}addParticle(t,i,e,s){let r=this._container.actualOptions.particles.number.limit.mode,n=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,l=this.count;if(n>a.ou)switch(r){case _.d.delete:{let t=l+a.nq-n;t>a.wM&&this.removeQuantity(t);break}case _.d.wait:if(l>=n)return}try{let a=this._pool.pop()??new v(this._pluginManager,this._container);a.init(this._nextId,t,i,e);let r=!0;if(s&&(r=s(a)),!r)return void this._pool.push(a);return this._array.push(a),this._zArray.push(a),this._nextId++,this._container.dispatchEvent(p.B.particleAdded,{particle:a}),a}catch(t){(0,S.t)().warning(`error adding particle: ${t}`)}}clear(){this._array=[],this._zArray=[]}destroy(){this._array=[],this._pool.length=0,this._zArray=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}drawParticles(t){for(let 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(){let t=this._container,i=t.actualOptions;for(let i of(this._minZIndex=0,this._maxZIndex=0,this._needsSort=!1,this.checkParticlePositionPlugins=[],this._updatePlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._particleResetPlugins=[],this._postParticleUpdatePlugins=[],this.grid=new b(a.iX*t.retina.pixelRatio),t.plugins))i.redrawInit&&await i.redrawInit(),i.checkParticlePosition&&this.checkParticlePositionPlugins.push(i),i.update&&this._updatePlugins.push(i),i.particleUpdate&&this._particleUpdatePlugins.push(i),i.postUpdate&&this._postUpdatePlugins.push(i),i.particleReset&&this._particleResetPlugins.push(i),i.postParticleUpdate&&this._postParticleUpdatePlugins.push(i);for(let i of(await this._container.initDrawersAndUpdaters(),this._container.effectDrawers.values()))await i.init?.(t);for(let i of this._container.shapeDrawers.values())await i.init?.(t);let e=!1;for(let i of t.plugins)if(e=i.particlesInitialization?.()??e)break;if(!e){let t=i.particles,e=t.groups;for(let i in e){let s=e[i];if(s)for(let e=this.count,a=0;a<s.number.value&&e<t.number.value;e++,a++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}push(t,i,e,s){for(let a=0;a<t;a++)this.addParticle(i,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.render.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=a.xd,e,s){if(t<a.z9||t>this.count)return;let r=0;for(let a=t;r<i&&a<this.count;a++)this._removeParticle(a,e,s)&&(a--,r++)}removeQuantity(t,i){this.removeAt(a.z9,t,i)}setDensity(){let t=this._container.actualOptions,i=t.particles.groups,e=0;for(let t of this._container.plugins)t.particlesDensityCount&&(e+=t.particlesDensityCount());for(let t in i){let s=i[t];if(!s)continue;let a=(0,y.y)(this._pluginManager,this._container,s);this._applyDensity(a,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._needsSort||=t>=this._maxZIndex||t>this._minZIndex&&t<this._maxZIndex}setResizeFactor(t){this._resizeFactor=t}update(t){let i=new Set;for(let i of(this.grid.clear(),this._updatePlugins))i.update?.(t);let e=this._resizeFactor;for(let s of this._array){for(let t of(e&&!s.ignoresResizeRatio&&(s.position.x*=e.width,s.position.y*=e.height,s.initialPosition.x*=e.width,s.initialPosition.y*=e.height),s.ignoresResizeRatio=!1,this._particleResetPlugins))t.particleReset?.(s);for(let i of this._particleUpdatePlugins){if(s.destroyed)break;i.particleUpdate?.(s,t)}if(s.destroyed){i.add(s);continue}this.grid.insert(s)}for(let i of this._postUpdatePlugins)i.postUpdate?.(t);for(let e of this._array){if(e.destroyed){i.add(e);continue}for(let i of this._container.particleUpdaters)i.update(e,t);if(e.destroyed||e.spawning)e.destroyed&&i.add(e);else for(let i of this._postParticleUpdatePlugins)i.postParticleUpdate?.(e,t)}if(i.size)for(let t of i)this.remove(t);if(delete this._resizeFactor,this._needsSort){let t=this._zArray;t.sort((t,i)=>i.position.z-t.position.z||t.id-i.id);let i=t[a.z9],e=t[t.length-a.K3];if(!i||!e)return;this._maxZIndex=i.position.z,this._minZIndex=e.position.z,this._needsSort=!1}}_addToPool=(...t)=>{this._pool.push(...t)};_applyDensity=(t,i,e,s)=>{let r=t.number;if(!r.density.enable)return void(void 0===e?this._limit=r.limit.value:(s?.number.limit.value??r.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??r.limit.value));let n=this._initDensityFactor(r.density),l=r.value,o=r.limit.value>a.ou?r.limit.value:l,h=Math.min(l,o)*n+i,c=Math.min(this.count,this.filter(t=>t.group===e).length);void 0===e?this._limit=r.limit.value*n:this._groupLimits.set(e,r.limit.value*n),c<h?this.push(Math.abs(h-c),void 0,t,e):c>h&&this.removeQuantity(c-h,e)};_initDensityFactor=t=>{let i=this._container;if(!i.canvas.element||!t.enable)return a.lA;let e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**a.dm)};_removeParticle=(t,i,e)=>{let s=this._array[t];if(!s||s.group!==i)return!1;let r=this._zArray.indexOf(s);return this._array.splice(t,a.LD),this._zArray.splice(r,a.LD),s.destroy(e),this._container.dispatchEvent(p.B.particleRemoved,{particle:s}),this._addToPool(s),!0}}class x{container;pixelRatio;reduceFactor;constructor(t){this.container=t,this.pixelRatio=a.$x,this.reduceFactor=a.Zp}init(){let t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:a.$x,this.reduceFactor=a.Zp;let e=this.pixelRatio,s=t.canvas;if(s.element){let t=s.element;s.size.width=t.offsetWidth*e,s.size.height=t.offsetHeight*e}}initParticle(t){let i=t.options,e=this.pixelRatio,a=i.move,r=a.distance,n=t.retina;n.maxSpeed=(0,s.VG)(a.gravity.maxSpeed)*e,n.moveDrift=(0,s.VG)(a.drift)*e,n.moveSpeed=(0,s.VG)(a.speed)*e,n.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;let l=n.maxDistance;l.horizontal=void 0===r.horizontal?void 0:r.horizontal*e,l.vertical=void 0===r.vertical?void 0:r.vertical*e}}function D(t){return!t.destroyed}function M(t,i,...e){let s=new u.J(t,i);return(0,y.Z)(s,...e),s}class O{actualOptions;canvas;destroyed;effectDrawers;fpsLimit;hdr;id;pageHidden;particleCreatedPlugins;particleDestroyedPlugins;particlePositionPlugins;particleUpdaters;particles;plugins;retina;shapeDrawers;started;zLayers;_delay;_delayTimeout;_delta={value:0,factor:0};_dispatchCallback;_drawAnimationFrame;_duration;_eventListeners;_firstStart;_initialSourceOptions;_lastFrameTime;_lifeTime;_onDestroy;_options;_paused;_pluginManager;_smooth;_sourceOptions;constructor(t){const{dispatchCallback:i,pluginManager:e,id:s,onDestroy:a,sourceOptions:r}=t;this._pluginManager=e,this._dispatchCallback=i,this._onDestroy=a,this.id=Symbol(s),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=r,this._initialSourceOptions=r,this.effectDrawers=new Map,this.shapeDrawers=new Map,this.particleUpdaters=[],this.retina=new x(this),this.canvas=new c(this._pluginManager,this),this.particles=new C(this._pluginManager,this),this.plugins=[],this.particleDestroyedPlugins=[],this.particleCreatedPlugins=[],this.particlePositionPlugins=[],this._options=M(this._pluginManager,this),this.actualOptions=M(this._pluginManager,this),this._eventListeners=new d(this),this.dispatchEvent(p.B.containerBuilt)}get animationStatus(){return!this._paused&&!this.pageHidden&&D(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addLifeTime(t){this._lifeTime+=t}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(t=!0){if(D(this)){for(let[,t]of(this.stop(),this.particles.destroy(),this.canvas.destroy(),this.effectDrawers))t.destroy?.(this);for(let[,t]of this.shapeDrawers)t.destroy?.(this);for(let t of this.plugins)t.destroy?.();this.effectDrawers=new Map,this.shapeDrawers=new Map,this.particleUpdaters=[],this.plugins.length=0,this._pluginManager.clearPlugins(this),this.destroyed=!0,this._onDestroy(t),this.dispatchEvent(p.B.containerDestroyed)}}dispatchEvent(t,i){this._dispatchCallback(t,{container:this,data:i})}draw(t){if(!D(this))return;let i=t;this._drawAnimationFrame=(0,s.i0)(t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)})}async export(t,i={}){for(let e of this.plugins){if(!e.export)continue;let s=await e.export(t,i);if(s.supported)return s.blob}(0,S.t)().error(`Export plugin with type ${t} not found`)}async init(){if(!D(this))return;let t=new Map;for(let i of this._pluginManager.plugins){let e=await i.getPlugin(this);e.preInit&&await e.preInit(),t.set(i,e)}for(let[i,e]of(await this.initDrawersAndUpdaters(),this._options=M(this._pluginManager,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=M(this._pluginManager,this,this._options),this.plugins.length=0,this.particleDestroyedPlugins.length=0,this.particleCreatedPlugins.length=0,this.particlePositionPlugins.length=0,t))i.needsPlugin(this.actualOptions)&&(this.plugins.push(e),e.particleCreated&&this.particleCreatedPlugins.push(e),e.particleDestroyed&&this.particleDestroyedPlugins.push(e),e.particlePosition&&this.particlePositionPlugins.push(e));this.retina.init(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();let{delay:i,duration:e,fpsLimit:r,hdr:n,smooth:l,zLayers:o}=this.actualOptions;for(let t of(this.hdr=n,this.zLayers=o,this._duration=(0,s.VG)(e)*a.Xu,this._delay=(0,s.VG)(i)*a.Xu,this._lifeTime=0,this.fpsLimit=r>a.DN?r:a.i8,this._smooth=l,this.plugins))await t.init?.();for(let t of(await this.particles.init(),this.dispatchEvent(p.B.containerInit),this.particles.setDensity(),this.plugins))t.particlesSetup?.();this.dispatchEvent(p.B.particlesSetup)}async initDrawersAndUpdaters(){let t=this._pluginManager;this.effectDrawers=await t.getEffectDrawers(this,!0),this.shapeDrawers=await t.getShapeDrawers(this,!0),this.particleUpdaters=await t.getUpdaters(this,!0)}pause(){if(D(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(let t of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this.dispatchEvent(p.B.containerPaused)}}play(t){if(!D(this))return;let i=this._paused||t;if(this._firstStart&&!this.actualOptions.autoPlay){this._firstStart=!1;return}if(this._paused&&(this._paused=!1),i)for(let t of this.plugins)t.play&&t.play();this.dispatchEvent(p.B.containerPlay),this.draw(i??!1)}async refresh(){if(D(this))return this.stop(),this.start()}async reset(t){if(D(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=M(this._pluginManager,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=M(this._pluginManager,this,this._options),this.refresh()}async start(){D(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise(t=>{let i=async()=>{for(let t of(this._eventListeners.addListeners(),this.plugins))await t.start?.();this.dispatchEvent(p.B.containerStarted),this.play(),t()};this._delayTimeout=setTimeout(()=>void i(),this._delay)}))}stop(){if(D(this)&&this.started){for(let t of(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(),this.plugins))t.stop?.();this.particleCreatedPlugins.length=0,this.particleDestroyedPlugins.length=0,this.particlePositionPlugins.length=0,this._sourceOptions=this._options,this.dispatchEvent(p.B.containerStopped)}}updateActualOptions(){let t=!1;for(let i of this.plugins)i.updateActualOptions&&(t=i.updateActualOptions()||t);return t}_nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+a.Xu/this.fpsLimit||(this._lastFrameTime??=t,!function(t,i,e=a.z$,s=!1){t.value=i,t.factor=s?a.z$/e:a.z$*i/a.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>a.Xu))return void this.draw(!1);if(this.canvas.render.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,S.t)().error("error in animation loop",t)}}}}}]);
|
package/README.md
CHANGED
|
@@ -98,8 +98,6 @@ React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Riot.j
|
|
|
98
98
|
- [Migrating from Particles.js](#migrating-from-particlesjs)
|
|
99
99
|
- [Plugins/Customizations](#pluginscustomizations)
|
|
100
100
|
- [Dependency Graph](#dependency-graph)
|
|
101
|
-
- [Sponsors](#sponsors)
|
|
102
|
-
- [Huge thanks to JetBrains for the 2020-2022 Open Source Licenses!](#huge-thanks-to-jetbrains-for-the-2020-2022-open-source-licenses)
|
|
103
101
|
|
|
104
102
|
---
|
|
105
103
|
|
|
@@ -989,22 +987,3 @@ flowchart TD
|
|
|
989
987
|
|
|
990
988
|
bundle-full --> bundle-all
|
|
991
989
|
```
|
|
992
|
-
|
|
993
|
-
---
|
|
994
|
-
|
|
995
|
-
<p>
|
|
996
|
-
<a href="https://www.jetbrains.com/?from=tsParticles">
|
|
997
|
-
<img src="https://raw.githubusercontent.com/tsparticles/tsparticles/gh-pages/images/jetbrains-logos/jetbrains-variant-4.png" height="150" alt="JetBrains" />
|
|
998
|
-
</a>
|
|
999
|
-
<a href="https://www.jetbrains.com/webstorm/?from=tsParticles">
|
|
1000
|
-
<img src="https://raw.githubusercontent.com/tsparticles/tsparticles/gh-pages/images/jetbrains-logos/logo.png" height="150" alt="JetBrains" />
|
|
1001
|
-
</a>
|
|
1002
|
-
</p>
|
|
1003
|
-
|
|
1004
|
-
## Sponsors
|
|
1005
|
-
|
|
1006
|
-
### JetBrains
|
|
1007
|
-
|
|
1008
|
-
Huge thanks to [JetBrains](https://www.jetbrains.com/?from=tsParticles) for the 2020-2022 Open Source Licenses!
|
|
1009
|
-
|
|
1010
|
-
[JetBrains WebStorm](https://www.jetbrains.com/webstorm/?from=tsParticles) is used to maintain this project.
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
|
|
2
|
+
import { defaultZoom, generatedAttribute, half } from "./Utils/Constants.js";
|
|
3
|
+
import { getStyleFromRgb, rangeColorToRgb } from "../Utils/ColorUtils.js";
|
|
4
|
+
import { RenderManager } from "./RenderManager.js";
|
|
5
|
+
function setStyle(canvas, style, important = false) {
|
|
6
|
+
if (!style) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const element = canvas, elementStyle = element.style, keys = new Set();
|
|
10
|
+
for (let i = 0; i < elementStyle.length; i++) {
|
|
11
|
+
const key = elementStyle.item(i);
|
|
12
|
+
if (!key) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
keys.add(key);
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i < style.length; i++) {
|
|
18
|
+
const key = style.item(i);
|
|
19
|
+
if (!key) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
keys.add(key);
|
|
23
|
+
}
|
|
24
|
+
for (const key of keys) {
|
|
25
|
+
const value = style.getPropertyValue(key);
|
|
26
|
+
if (value) {
|
|
27
|
+
elementStyle.setProperty(key, value, important ? "important" : "");
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
elementStyle.removeProperty(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class CanvasManager {
|
|
35
|
+
element;
|
|
36
|
+
render;
|
|
37
|
+
size;
|
|
38
|
+
zoom = defaultZoom;
|
|
39
|
+
_container;
|
|
40
|
+
_generated;
|
|
41
|
+
_mutationObserver;
|
|
42
|
+
_originalStyle;
|
|
43
|
+
_pluginManager;
|
|
44
|
+
_pointerEvents;
|
|
45
|
+
_resizePlugins;
|
|
46
|
+
_standardSize;
|
|
47
|
+
_zoomCenter;
|
|
48
|
+
constructor(pluginManager, container) {
|
|
49
|
+
this._pluginManager = pluginManager;
|
|
50
|
+
this._container = container;
|
|
51
|
+
this.render = new RenderManager(pluginManager, container, this);
|
|
52
|
+
this._standardSize = {
|
|
53
|
+
height: 0,
|
|
54
|
+
width: 0,
|
|
55
|
+
};
|
|
56
|
+
const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
|
|
57
|
+
this.size = {
|
|
58
|
+
height: stdSize.height * pxRatio,
|
|
59
|
+
width: stdSize.width * pxRatio,
|
|
60
|
+
};
|
|
61
|
+
this._generated = false;
|
|
62
|
+
this._resizePlugins = [];
|
|
63
|
+
this._pointerEvents = "none";
|
|
64
|
+
}
|
|
65
|
+
get _fullScreen() {
|
|
66
|
+
return this._container.actualOptions.fullScreen.enable;
|
|
67
|
+
}
|
|
68
|
+
destroy() {
|
|
69
|
+
this.stop();
|
|
70
|
+
if (this._generated) {
|
|
71
|
+
const element = this.element;
|
|
72
|
+
element?.remove();
|
|
73
|
+
this.element = undefined;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this._resetOriginalStyle();
|
|
77
|
+
}
|
|
78
|
+
this.render.destroy();
|
|
79
|
+
this._resizePlugins = [];
|
|
80
|
+
}
|
|
81
|
+
getZoomCenter() {
|
|
82
|
+
const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
|
|
83
|
+
if (this._zoomCenter) {
|
|
84
|
+
return this._zoomCenter;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
x: (width * half) / pxRatio,
|
|
88
|
+
y: (height * half) / pxRatio,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
init() {
|
|
92
|
+
this._safeMutationObserver(obs => {
|
|
93
|
+
obs.disconnect();
|
|
94
|
+
});
|
|
95
|
+
this._mutationObserver = safeMutationObserver(records => {
|
|
96
|
+
for (const record of records) {
|
|
97
|
+
if (record.type === "attributes" && record.attributeName === "style") {
|
|
98
|
+
this._repairStyle();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
this.resize();
|
|
103
|
+
this._initStyle();
|
|
104
|
+
this.initBackground();
|
|
105
|
+
this._safeMutationObserver(obs => {
|
|
106
|
+
if (!this.element || !(this.element instanceof Node)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
obs.observe(this.element, { attributes: true });
|
|
110
|
+
});
|
|
111
|
+
this.initPlugins();
|
|
112
|
+
this.render.init();
|
|
113
|
+
}
|
|
114
|
+
initBackground() {
|
|
115
|
+
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.element;
|
|
116
|
+
if (!element) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
|
|
120
|
+
if (color) {
|
|
121
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
elementStyle.backgroundColor = "";
|
|
125
|
+
}
|
|
126
|
+
elementStyle.backgroundImage = background.image || "";
|
|
127
|
+
elementStyle.backgroundPosition = background.position || "";
|
|
128
|
+
elementStyle.backgroundRepeat = background.repeat || "";
|
|
129
|
+
elementStyle.backgroundSize = background.size || "";
|
|
130
|
+
}
|
|
131
|
+
initPlugins() {
|
|
132
|
+
this._resizePlugins = [];
|
|
133
|
+
for (const plugin of this._container.plugins) {
|
|
134
|
+
if (plugin.resize) {
|
|
135
|
+
this._resizePlugins.push(plugin);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
loadCanvas(canvas) {
|
|
140
|
+
if (this._generated && this.element) {
|
|
141
|
+
this.element.remove();
|
|
142
|
+
}
|
|
143
|
+
const container = this._container;
|
|
144
|
+
this._generated =
|
|
145
|
+
generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
|
|
146
|
+
this.element = canvas;
|
|
147
|
+
this.element.ariaHidden = "true";
|
|
148
|
+
this._originalStyle = cloneStyle(this.element.style);
|
|
149
|
+
const standardSize = this._standardSize;
|
|
150
|
+
standardSize.height = canvas.offsetHeight;
|
|
151
|
+
standardSize.width = canvas.offsetWidth;
|
|
152
|
+
const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
|
|
153
|
+
canvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
154
|
+
canvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
155
|
+
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
156
|
+
this.render.setContextSettings({
|
|
157
|
+
alpha: true,
|
|
158
|
+
colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
|
|
159
|
+
desynchronized: true,
|
|
160
|
+
willReadFrequently: false,
|
|
161
|
+
});
|
|
162
|
+
this.render.setContext(this.element.getContext("2d", this.render.settings));
|
|
163
|
+
this._safeMutationObserver(obs => {
|
|
164
|
+
obs.disconnect();
|
|
165
|
+
});
|
|
166
|
+
container.retina.init();
|
|
167
|
+
this.initBackground();
|
|
168
|
+
this._safeMutationObserver(obs => {
|
|
169
|
+
if (!this.element || !(this.element instanceof Node)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
obs.observe(this.element, { attributes: true });
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
resize() {
|
|
176
|
+
if (!this.element) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const container = this._container, currentSize = container.canvas._standardSize, newSize = {
|
|
180
|
+
width: this.element.offsetWidth,
|
|
181
|
+
height: this.element.offsetHeight,
|
|
182
|
+
}, pxRatio = container.retina.pixelRatio, retinaSize = {
|
|
183
|
+
width: newSize.width * pxRatio,
|
|
184
|
+
height: newSize.height * pxRatio,
|
|
185
|
+
};
|
|
186
|
+
if (newSize.height === currentSize.height &&
|
|
187
|
+
newSize.width === currentSize.width &&
|
|
188
|
+
retinaSize.height === this.element.height &&
|
|
189
|
+
retinaSize.width === this.element.width) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const oldSize = { ...currentSize };
|
|
193
|
+
currentSize.height = newSize.height;
|
|
194
|
+
currentSize.width = newSize.width;
|
|
195
|
+
const canvasSize = this.size;
|
|
196
|
+
this.element.width = canvasSize.width = retinaSize.width;
|
|
197
|
+
this.element.height = canvasSize.height = retinaSize.height;
|
|
198
|
+
if (this._container.started) {
|
|
199
|
+
container.particles.setResizeFactor({
|
|
200
|
+
width: currentSize.width / oldSize.width,
|
|
201
|
+
height: currentSize.height / oldSize.height,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
setPointerEvents(type) {
|
|
207
|
+
const element = this.element;
|
|
208
|
+
if (!element) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
this._pointerEvents = type;
|
|
212
|
+
this._repairStyle();
|
|
213
|
+
}
|
|
214
|
+
setZoom(zoomLevel, center) {
|
|
215
|
+
this.zoom = zoomLevel;
|
|
216
|
+
this._zoomCenter = center;
|
|
217
|
+
}
|
|
218
|
+
stop() {
|
|
219
|
+
this._safeMutationObserver(obs => {
|
|
220
|
+
obs.disconnect();
|
|
221
|
+
});
|
|
222
|
+
this._mutationObserver = undefined;
|
|
223
|
+
this.render.stop();
|
|
224
|
+
}
|
|
225
|
+
async windowResize() {
|
|
226
|
+
if (!this.element || !this.resize()) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const container = this._container, needsRefresh = container.updateActualOptions();
|
|
230
|
+
container.particles.setDensity();
|
|
231
|
+
this._applyResizePlugins();
|
|
232
|
+
if (needsRefresh) {
|
|
233
|
+
await container.refresh();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
_applyResizePlugins = () => {
|
|
237
|
+
for (const plugin of this._resizePlugins) {
|
|
238
|
+
plugin.resize?.();
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
_initStyle = () => {
|
|
242
|
+
const element = this.element, options = this._container.actualOptions;
|
|
243
|
+
if (!element) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (this._fullScreen) {
|
|
247
|
+
this._setFullScreenStyle();
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this._resetOriginalStyle();
|
|
251
|
+
}
|
|
252
|
+
for (const key in options.style) {
|
|
253
|
+
if (!key || !(key in options.style)) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const value = options.style[key];
|
|
257
|
+
if (!value) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
element.style.setProperty(key, value, "important");
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
_repairStyle = () => {
|
|
264
|
+
const element = this.element;
|
|
265
|
+
if (!element) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
this._safeMutationObserver(observer => {
|
|
269
|
+
observer.disconnect();
|
|
270
|
+
});
|
|
271
|
+
this._initStyle();
|
|
272
|
+
this.initBackground();
|
|
273
|
+
const pointerEvents = this._pointerEvents;
|
|
274
|
+
element.style.pointerEvents = pointerEvents;
|
|
275
|
+
element.setAttribute("pointer-events", pointerEvents);
|
|
276
|
+
this._safeMutationObserver(observer => {
|
|
277
|
+
if (!(element instanceof Node)) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
observer.observe(element, { attributes: true });
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
_resetOriginalStyle = () => {
|
|
284
|
+
const element = this.element, originalStyle = this._originalStyle;
|
|
285
|
+
if (!element || !originalStyle) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
setStyle(element, originalStyle, true);
|
|
289
|
+
};
|
|
290
|
+
_safeMutationObserver = callback => {
|
|
291
|
+
if (!this._mutationObserver) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
callback(this._mutationObserver);
|
|
295
|
+
};
|
|
296
|
+
_setFullScreenStyle = () => {
|
|
297
|
+
const element = this.element;
|
|
298
|
+
if (!element) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
|
|
302
|
+
};
|
|
303
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { animate, cancelAnimation, getRangeValue } from "../Utils/MathUtils.js";
|
|
2
|
-
import { defaultFps, defaultFpsLimit, millisecondsToSeconds, minFpsLimit
|
|
3
|
-
import {
|
|
2
|
+
import { defaultFps, defaultFpsLimit, millisecondsToSeconds, minFpsLimit } from "./Utils/Constants.js";
|
|
3
|
+
import { CanvasManager } from "./CanvasManager.js";
|
|
4
4
|
import { EventListeners } from "./Utils/EventListeners.js";
|
|
5
5
|
import { EventType } from "../Enums/Types/EventType.js";
|
|
6
|
+
import {} from "./Interfaces/IEffectDrawer.js";
|
|
7
|
+
import {} from "./Interfaces/IParticleUpdater.js";
|
|
8
|
+
import {} from "./Interfaces/IShapeDrawer.js";
|
|
6
9
|
import { Options } from "../Options/Classes/Options.js";
|
|
7
|
-
import {
|
|
10
|
+
import { ParticlesManager } from "./ParticlesManager.js";
|
|
8
11
|
import { Retina } from "./Retina.js";
|
|
9
12
|
import { getLogger } from "../Utils/LogUtils.js";
|
|
10
13
|
import { loadOptions } from "../Utils/OptionsUtils.js";
|
|
@@ -15,8 +18,8 @@ function updateDelta(delta, value, fpsLimit = defaultFps, smooth = false) {
|
|
|
15
18
|
delta.value = value;
|
|
16
19
|
delta.factor = smooth ? defaultFps / fpsLimit : (defaultFps * value) / millisecondsToSeconds;
|
|
17
20
|
}
|
|
18
|
-
function loadContainerOptions(
|
|
19
|
-
const options = new Options(
|
|
21
|
+
function loadContainerOptions(pluginManager, container, ...sourceOptionsArr) {
|
|
22
|
+
const options = new Options(pluginManager, container);
|
|
20
23
|
loadOptions(options, ...sourceOptionsArr);
|
|
21
24
|
return options;
|
|
22
25
|
}
|
|
@@ -24,6 +27,7 @@ export class Container {
|
|
|
24
27
|
actualOptions;
|
|
25
28
|
canvas;
|
|
26
29
|
destroyed;
|
|
30
|
+
effectDrawers;
|
|
27
31
|
fpsLimit;
|
|
28
32
|
hdr;
|
|
29
33
|
id;
|
|
@@ -31,28 +35,35 @@ export class Container {
|
|
|
31
35
|
particleCreatedPlugins;
|
|
32
36
|
particleDestroyedPlugins;
|
|
33
37
|
particlePositionPlugins;
|
|
38
|
+
particleUpdaters;
|
|
34
39
|
particles;
|
|
35
40
|
plugins;
|
|
36
41
|
retina;
|
|
42
|
+
shapeDrawers;
|
|
37
43
|
started;
|
|
38
44
|
zLayers;
|
|
39
45
|
_delay;
|
|
40
46
|
_delayTimeout;
|
|
41
47
|
_delta = { value: 0, factor: 0 };
|
|
48
|
+
_dispatchCallback;
|
|
42
49
|
_drawAnimationFrame;
|
|
43
50
|
_duration;
|
|
44
|
-
_engine;
|
|
45
51
|
_eventListeners;
|
|
46
52
|
_firstStart;
|
|
47
53
|
_initialSourceOptions;
|
|
48
54
|
_lastFrameTime;
|
|
49
55
|
_lifeTime;
|
|
56
|
+
_onDestroy;
|
|
50
57
|
_options;
|
|
51
58
|
_paused;
|
|
59
|
+
_pluginManager;
|
|
52
60
|
_smooth;
|
|
53
61
|
_sourceOptions;
|
|
54
|
-
constructor(
|
|
55
|
-
|
|
62
|
+
constructor(params) {
|
|
63
|
+
const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
|
|
64
|
+
this._pluginManager = pluginManager;
|
|
65
|
+
this._dispatchCallback = dispatchCallback;
|
|
66
|
+
this._onDestroy = onDestroy;
|
|
56
67
|
this.id = Symbol(id);
|
|
57
68
|
this.fpsLimit = 120;
|
|
58
69
|
this.hdr = false;
|
|
@@ -69,17 +80,20 @@ export class Container {
|
|
|
69
80
|
this.pageHidden = false;
|
|
70
81
|
this._sourceOptions = sourceOptions;
|
|
71
82
|
this._initialSourceOptions = sourceOptions;
|
|
83
|
+
this.effectDrawers = new Map();
|
|
84
|
+
this.shapeDrawers = new Map();
|
|
85
|
+
this.particleUpdaters = [];
|
|
72
86
|
this.retina = new Retina(this);
|
|
73
|
-
this.canvas = new
|
|
74
|
-
this.particles = new
|
|
87
|
+
this.canvas = new CanvasManager(this._pluginManager, this);
|
|
88
|
+
this.particles = new ParticlesManager(this._pluginManager, this);
|
|
75
89
|
this.plugins = [];
|
|
76
90
|
this.particleDestroyedPlugins = [];
|
|
77
91
|
this.particleCreatedPlugins = [];
|
|
78
92
|
this.particlePositionPlugins = [];
|
|
79
|
-
this._options = loadContainerOptions(this.
|
|
80
|
-
this.actualOptions = loadContainerOptions(this.
|
|
93
|
+
this._options = loadContainerOptions(this._pluginManager, this);
|
|
94
|
+
this.actualOptions = loadContainerOptions(this._pluginManager, this);
|
|
81
95
|
this._eventListeners = new EventListeners(this);
|
|
82
|
-
this.
|
|
96
|
+
this.dispatchEvent(EventType.containerBuilt);
|
|
83
97
|
}
|
|
84
98
|
get animationStatus() {
|
|
85
99
|
return !this._paused && !this.pageHidden && guardCheck(this);
|
|
@@ -103,19 +117,29 @@ export class Container {
|
|
|
103
117
|
this.stop();
|
|
104
118
|
this.particles.destroy();
|
|
105
119
|
this.canvas.destroy();
|
|
120
|
+
for (const [, effectDrawer] of this.effectDrawers) {
|
|
121
|
+
effectDrawer.destroy?.(this);
|
|
122
|
+
}
|
|
123
|
+
for (const [, shapeDrawer] of this.shapeDrawers) {
|
|
124
|
+
shapeDrawer.destroy?.(this);
|
|
125
|
+
}
|
|
106
126
|
for (const plugin of this.plugins) {
|
|
107
127
|
plugin.destroy?.();
|
|
108
128
|
}
|
|
129
|
+
this.effectDrawers = new Map();
|
|
130
|
+
this.shapeDrawers = new Map();
|
|
131
|
+
this.particleUpdaters = [];
|
|
109
132
|
this.plugins.length = 0;
|
|
110
|
-
this.
|
|
133
|
+
this._pluginManager.clearPlugins(this);
|
|
111
134
|
this.destroyed = true;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
this._onDestroy(remove);
|
|
136
|
+
this.dispatchEvent(EventType.containerDestroyed);
|
|
137
|
+
}
|
|
138
|
+
dispatchEvent(type, data) {
|
|
139
|
+
this._dispatchCallback(type, {
|
|
140
|
+
container: this,
|
|
141
|
+
data,
|
|
142
|
+
});
|
|
119
143
|
}
|
|
120
144
|
draw(force) {
|
|
121
145
|
if (!guardCheck(this)) {
|
|
@@ -149,16 +173,16 @@ export class Container {
|
|
|
149
173
|
return;
|
|
150
174
|
}
|
|
151
175
|
const allContainerPlugins = new Map();
|
|
152
|
-
for (const plugin of this.
|
|
176
|
+
for (const plugin of this._pluginManager.plugins) {
|
|
153
177
|
const containerPlugin = await plugin.getPlugin(this);
|
|
154
178
|
if (containerPlugin.preInit) {
|
|
155
179
|
await containerPlugin.preInit();
|
|
156
180
|
}
|
|
157
181
|
allContainerPlugins.set(plugin, containerPlugin);
|
|
158
182
|
}
|
|
159
|
-
await this.
|
|
160
|
-
this._options = loadContainerOptions(this.
|
|
161
|
-
this.actualOptions = loadContainerOptions(this.
|
|
183
|
+
await this.initDrawersAndUpdaters();
|
|
184
|
+
this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
|
|
185
|
+
this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
|
|
162
186
|
this.plugins.length = 0;
|
|
163
187
|
this.particleDestroyedPlugins.length = 0;
|
|
164
188
|
this.particleCreatedPlugins.length = 0;
|
|
@@ -194,12 +218,18 @@ export class Container {
|
|
|
194
218
|
await plugin.init?.();
|
|
195
219
|
}
|
|
196
220
|
await this.particles.init();
|
|
197
|
-
this.
|
|
221
|
+
this.dispatchEvent(EventType.containerInit);
|
|
198
222
|
this.particles.setDensity();
|
|
199
223
|
for (const plugin of this.plugins) {
|
|
200
224
|
plugin.particlesSetup?.();
|
|
201
225
|
}
|
|
202
|
-
this.
|
|
226
|
+
this.dispatchEvent(EventType.particlesSetup);
|
|
227
|
+
}
|
|
228
|
+
async initDrawersAndUpdaters() {
|
|
229
|
+
const pluginManager = this._pluginManager;
|
|
230
|
+
this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
|
|
231
|
+
this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
|
|
232
|
+
this.particleUpdaters = await pluginManager.getUpdaters(this, true);
|
|
203
233
|
}
|
|
204
234
|
pause() {
|
|
205
235
|
if (!guardCheck(this)) {
|
|
@@ -218,7 +248,7 @@ export class Container {
|
|
|
218
248
|
if (!this.pageHidden) {
|
|
219
249
|
this._paused = true;
|
|
220
250
|
}
|
|
221
|
-
this.
|
|
251
|
+
this.dispatchEvent(EventType.containerPaused);
|
|
222
252
|
}
|
|
223
253
|
play(force) {
|
|
224
254
|
if (!guardCheck(this)) {
|
|
@@ -239,7 +269,7 @@ export class Container {
|
|
|
239
269
|
}
|
|
240
270
|
}
|
|
241
271
|
}
|
|
242
|
-
this.
|
|
272
|
+
this.dispatchEvent(EventType.containerPlay);
|
|
243
273
|
this.draw(needsUpdate ?? false);
|
|
244
274
|
}
|
|
245
275
|
async refresh() {
|
|
@@ -255,8 +285,8 @@ export class Container {
|
|
|
255
285
|
}
|
|
256
286
|
this._initialSourceOptions = sourceOptions;
|
|
257
287
|
this._sourceOptions = sourceOptions;
|
|
258
|
-
this._options = loadContainerOptions(this.
|
|
259
|
-
this.actualOptions = loadContainerOptions(this.
|
|
288
|
+
this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
|
|
289
|
+
this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
|
|
260
290
|
return this.refresh();
|
|
261
291
|
}
|
|
262
292
|
async start() {
|
|
@@ -271,7 +301,7 @@ export class Container {
|
|
|
271
301
|
for (const plugin of this.plugins) {
|
|
272
302
|
await plugin.start?.();
|
|
273
303
|
}
|
|
274
|
-
this.
|
|
304
|
+
this.dispatchEvent(EventType.containerStarted);
|
|
275
305
|
this.play();
|
|
276
306
|
resolve();
|
|
277
307
|
};
|
|
@@ -299,7 +329,7 @@ export class Container {
|
|
|
299
329
|
this.particleDestroyedPlugins.length = 0;
|
|
300
330
|
this.particlePositionPlugins.length = 0;
|
|
301
331
|
this._sourceOptions = this._options;
|
|
302
|
-
this.
|
|
332
|
+
this.dispatchEvent(EventType.containerStopped);
|
|
303
333
|
}
|
|
304
334
|
updateActualOptions() {
|
|
305
335
|
let refresh = false;
|
|
@@ -326,7 +356,7 @@ export class Container {
|
|
|
326
356
|
this.draw(false);
|
|
327
357
|
return;
|
|
328
358
|
}
|
|
329
|
-
this.canvas.drawParticles(this._delta);
|
|
359
|
+
this.canvas.render.drawParticles(this._delta);
|
|
330
360
|
if (!this.alive()) {
|
|
331
361
|
this.destroy();
|
|
332
362
|
return;
|