@tsparticles/engine 4.0.0-alpha.4 → 4.0.0-alpha.8

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 (43) hide show
  1. package/794.min.js +1 -1
  2. package/794.min.js.LICENSE.txt +1 -1
  3. package/browser/Core/Canvas.js +25 -19
  4. package/browser/Core/Engine.js +32 -39
  5. package/browser/Core/Particle.js +22 -6
  6. package/browser/Core/Utils/Constants.js +1 -1
  7. package/browser/Enums/Types/EasingType.js +18 -3
  8. package/browser/Utils/CanvasUtils.js +0 -12
  9. package/browser/Utils/Utils.js +8 -4
  10. package/cjs/Core/Canvas.js +25 -19
  11. package/cjs/Core/Engine.js +32 -39
  12. package/cjs/Core/Particle.js +22 -6
  13. package/cjs/Core/Utils/Constants.js +1 -1
  14. package/cjs/Enums/Types/EasingType.js +18 -3
  15. package/cjs/Utils/CanvasUtils.js +0 -12
  16. package/cjs/Utils/Utils.js +8 -4
  17. package/dist_browser_Core_Container_js.js +3 -3
  18. package/esm/Core/Canvas.js +25 -19
  19. package/esm/Core/Engine.js +32 -39
  20. package/esm/Core/Particle.js +22 -6
  21. package/esm/Core/Utils/Constants.js +1 -1
  22. package/esm/Enums/Types/EasingType.js +18 -3
  23. package/esm/Utils/CanvasUtils.js +0 -12
  24. package/esm/Utils/Utils.js +8 -4
  25. package/package.json +1 -1
  26. package/report.html +3 -3
  27. package/tsparticles.engine.js +8 -8
  28. package/tsparticles.engine.min.js +1 -1
  29. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  30. package/types/Core/Canvas.d.ts +0 -2
  31. package/types/Core/Engine.d.ts +5 -1
  32. package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -0
  33. package/types/Core/Particle.d.ts +1 -0
  34. package/types/Core/Utils/Constants.d.ts +1 -1
  35. package/types/Enums/Types/EasingType.d.ts +20 -5
  36. package/types/Utils/CanvasUtils.d.ts +0 -2
  37. package/umd/Core/Canvas.js +24 -18
  38. package/umd/Core/Engine.js +32 -39
  39. package/umd/Core/Particle.js +21 -5
  40. package/umd/Core/Utils/Constants.js +2 -2
  41. package/umd/Enums/Types/EasingType.js +18 -3
  42. package/umd/Utils/CanvasUtils.js +0 -14
  43. package/umd/Utils/Utils.js +8 -4
package/794.min.js CHANGED
@@ -1,2 +1,2 @@
1
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:()=>M});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()}clearDrawPlugin(t,i){this.draw((e=>{(0,a.l7)(e,t,i)}))}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=>{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)}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);for(const i of e.values())this.drawPlugin(i,t);this.draw((()=>{i.drawParticles(t)}));for(const i of e.values())this.clearDrawPlugin(i,t)}drawPlugin(t,i){this.draw((e=>{(0,a.e_)(e,t,i)}))}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=>{if(!t||!this.roll||!this.backColor&&!this.roll.alter)return t;const i=this.roll.horizontal&&this.roll.vertical?n.gd*n.l:n.l,e=this.roll.horizontal?Math.PI*n.MX:n.dv;return Math.floor((this.roll.angle+e)/(Math.PI/i))%n.gd?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 D=P?.getSidesCount;D&&(this.sides=D(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}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 D{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 D(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 O=t=>{const{height:i,width:e}=t;return new P.M_(n.un*e,n.un*i,n.Rh*e,n.Rh*i)};class S{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 D(O(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 D(O(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 T(t,i,...e){const s=new u.J(t,i);return(0,v.Z)(s,...e),s}class M{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 S(this._engine,this),this.pathGenerators=new Map,this.plugins=[],this.effectDrawers=new Map,this.shapeDrawers=new Map,this._options=T(this._engine,this),this.actualOptions=T(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=T(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=T(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=T(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=T(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}}}}]);
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 +1 @@
1
- /*! tsParticles Engine v4.0.0-alpha.4 by Matteo Bruni */
1
+ /*! tsParticles Engine v4.0.0-alpha.8 by Matteo Bruni */
@@ -1,4 +1,4 @@
1
- import { clear, clearDrawPlugin, drawParticle, drawParticlePlugin, drawPlugin, paintBase, paintImage, } from "../Utils/CanvasUtils.js";
1
+ import { clear, drawParticle, drawParticlePlugin, paintBase, paintImage } from "../Utils/CanvasUtils.js";
2
2
  import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
3
3
  import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
4
4
  import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
@@ -194,11 +194,6 @@ export class Canvas {
194
194
  }
195
195
  this.canvasClear();
196
196
  }
197
- clearDrawPlugin(plugin, delta) {
198
- this.draw(ctx => {
199
- clearDrawPlugin(ctx, plugin, delta);
200
- });
201
- }
202
197
  destroy() {
203
198
  this.stop();
204
199
  if (this._generated) {
@@ -241,6 +236,11 @@ export class Canvas {
241
236
  colorStyles.fill = fill;
242
237
  colorStyles.stroke = stroke;
243
238
  this.draw((context) => {
239
+ for (const plugin of container.plugins) {
240
+ if (plugin.drawParticleSetup) {
241
+ plugin.drawParticleSetup(context, particle, delta);
242
+ }
243
+ }
244
244
  this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
245
245
  drawParticle({
246
246
  container,
@@ -252,8 +252,13 @@ export class Canvas {
252
252
  opacity: opacity,
253
253
  transform,
254
254
  });
255
+ this._applyPostDrawUpdaters(particle);
256
+ for (const plugin of container.plugins) {
257
+ if (plugin.drawParticleCleanup) {
258
+ plugin.drawParticleCleanup(context, particle, delta);
259
+ }
260
+ }
255
261
  });
256
- this._applyPostDrawUpdaters(particle);
257
262
  }
258
263
  drawParticlePlugin(plugin, particle, delta) {
259
264
  this.draw(ctx => {
@@ -264,19 +269,20 @@ export class Canvas {
264
269
  const { particles, plugins } = this.container;
265
270
  this.clear();
266
271
  particles.update(delta);
267
- for (const plugin of plugins.values()) {
268
- this.drawPlugin(plugin, delta);
269
- }
270
- this.draw(() => {
271
- particles.drawParticles(delta);
272
- });
273
- for (const plugin of plugins.values()) {
274
- this.clearDrawPlugin(plugin, delta);
275
- }
276
- }
277
- drawPlugin(plugin, delta) {
278
272
  this.draw(ctx => {
279
- drawPlugin(ctx, plugin, delta);
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
+ }
280
286
  });
281
287
  }
282
288
  init() {
@@ -57,7 +57,10 @@ export class Engine {
57
57
  this._domArray = [];
58
58
  this._eventDispatcher = new EventDispatcher();
59
59
  this._initialized = false;
60
+ this._isRunningLoaders = false;
60
61
  this._loadPromises = new Set();
62
+ this._allLoadersSet = new Set();
63
+ this._executedSet = new Set();
61
64
  this.plugins = [];
62
65
  this.colorManagers = new Map();
63
66
  this.easingFunctions = new Map();
@@ -83,7 +86,7 @@ export class Engine {
83
86
  return this._domArray;
84
87
  }
85
88
  get version() {
86
- return "4.0.0-alpha.4";
89
+ return "4.0.0-alpha.8";
87
90
  }
88
91
  addColorManager(manager) {
89
92
  this.colorManagers.set(manager.key, manager);
@@ -184,40 +187,21 @@ export class Engine {
184
187
  return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
185
188
  }
186
189
  async init() {
187
- if (this._initialized) {
190
+ if (this._initialized || this._isRunningLoaders)
188
191
  return;
189
- }
190
- const executed = new Set(), allLoaders = new Set(this._loadPromises), stack = [...allLoaders];
191
- while (stack.length) {
192
- const loader = stack.shift();
193
- if (!loader) {
194
- continue;
195
- }
196
- if (executed.has(loader)) {
197
- continue;
198
- }
199
- executed.add(loader);
200
- const inner = [], origRegister = this.register.bind(this);
201
- this.register = (...loaders) => {
202
- inner.push(...loaders);
203
- for (const loader of loaders) {
204
- allLoaders.add(loader);
205
- }
206
- };
207
- try {
208
- await loader(this);
192
+ this._isRunningLoaders = true;
193
+ this._executedSet = new Set();
194
+ this._allLoadersSet = new Set(this._loadPromises);
195
+ try {
196
+ for (const loader of this._allLoadersSet) {
197
+ await this._runLoader(loader, this._executedSet, this._allLoadersSet);
209
198
  }
210
- finally {
211
- this.register = origRegister;
212
- }
213
- stack.unshift(...inner);
214
- this._loadPromises.delete(loader);
215
199
  }
216
- this._loadPromises.clear();
217
- for (const loader of allLoaders) {
218
- this._loadPromises.add(loader);
200
+ finally {
201
+ this._loadPromises.clear();
202
+ this._isRunningLoaders = false;
203
+ this._initialized = true;
219
204
  }
220
- this._initialized = true;
221
205
  }
222
206
  item(index) {
223
207
  const { items } = this, item = items[index];
@@ -229,10 +213,7 @@ export class Engine {
229
213
  }
230
214
  async load(params) {
231
215
  await this.init();
232
- this._loadPromises.clear();
233
- const { Container } = await import("./Container.js"), id = params.id ??
234
- params.element?.id ??
235
- `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container(this, id, currentOptions);
216
+ const { Container } = await import("./Container.js"), id = params.id ?? params.element?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container(this, id, currentOptions);
236
217
  if (oldIndex >= loadMinIndex) {
237
218
  const old = this.item(oldIndex), deleteCount = old ? one : none;
238
219
  if (old && !old.destroyed) {
@@ -261,15 +242,27 @@ export class Engine {
261
242
  }
262
243
  await Promise.all(this.items.map(t => t.refresh()));
263
244
  }
264
- register(...loadPromises) {
245
+ async register(...loaders) {
265
246
  if (this._initialized) {
266
- throw new Error(`Register plugins can only be done before calling tsParticles.load()`);
247
+ throw new Error("Register plugins can only be done before calling tsParticles.load()");
267
248
  }
268
- for (const loadPromise of loadPromises) {
269
- this._loadPromises.add(loadPromise);
249
+ for (const loader of loaders) {
250
+ if (this._isRunningLoaders) {
251
+ await this._runLoader(loader, this._executedSet, this._allLoadersSet);
252
+ }
253
+ else {
254
+ this._loadPromises.add(loader);
255
+ }
270
256
  }
271
257
  }
272
258
  removeEventListener(type, listener) {
273
259
  this._eventDispatcher.removeEventListener(type, listener);
274
260
  }
261
+ async _runLoader(loader, executed, allLoaders) {
262
+ if (executed.has(loader))
263
+ return;
264
+ executed.add(loader);
265
+ allLoaders.add(loader);
266
+ await loader(this);
267
+ }
275
268
  }
@@ -1,6 +1,6 @@
1
1
  import { Vector, Vector3d } from "./Utils/Vectors.js";
2
2
  import { calcExactPositionOrRandomFromSize, clamp, degToRad, getParticleBaseVelocity, getParticleDirectionAngle, getRandom, getRangeValue, randomInRangeValue, setRangeValue, } from "../Utils/MathUtils.js";
3
- import { decayOffset, defaultAngle, defaultOpacity, defaultRetryCount, defaultTransform, double, half, identity, millisecondsToSeconds, minZ, none, randomColorValue, rollFactor, squareExp, tryCountIncrement, zIndexFactorOffset, } from "./Utils/Constants.js";
3
+ import { decayOffset, defaultAngle, defaultOpacity, defaultRetryCount, defaultTransform, double, doublePI, half, identity, millisecondsToSeconds, minZ, randomColorValue, squareExp, triple, tryCountIncrement, zIndexFactorOffset, } from "./Utils/Constants.js";
4
4
  import { deepExtend, getPosition, initParticleNumericAnimationValue, isInArray, itemFromSingleOrMultiple, } from "../Utils/Utils.js";
5
5
  import { EventType } from "../Enums/Types/EventType.js";
6
6
  import { MoveDirection } from "../Enums/Directions/MoveDirection.js";
@@ -124,8 +124,7 @@ export class Particle {
124
124
  if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
125
125
  return color;
126
126
  }
127
- const backFactor = this.roll.horizontal && this.roll.vertical ? double * rollFactor : rollFactor, backSum = this.roll.horizontal ? Math.PI * half : none, rolled = Math.floor((this.roll.angle + backSum) / (Math.PI / backFactor)) % double;
128
- if (!rolled) {
127
+ if (!this.isShowingBack()) {
129
128
  return color;
130
129
  }
131
130
  if (this.backColor) {
@@ -286,9 +285,7 @@ export class Particle {
286
285
  const availableShapes = [...this.container.shapeDrawers.keys()];
287
286
  this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
288
287
  }
289
- this.effectData = this.effect
290
- ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates)
291
- : undefined;
288
+ this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
292
289
  this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
293
290
  particlesOptions.load(overrideOptions);
294
291
  const effectData = this.effectData;
@@ -378,6 +375,25 @@ export class Particle {
378
375
  position.y <= canvasSize.height + radius &&
379
376
  position.x <= canvasSize.width + radius);
380
377
  }
378
+ isShowingBack() {
379
+ if (!this.roll) {
380
+ return false;
381
+ }
382
+ const angle = this.roll.angle;
383
+ if (this.roll.horizontal && this.roll.vertical) {
384
+ const normalizedAngle = angle % doublePI, adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + doublePI : normalizedAngle;
385
+ return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
386
+ }
387
+ if (this.roll.horizontal) {
388
+ const normalizedAngle = (angle + Math.PI * half) % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
389
+ return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
390
+ }
391
+ if (this.roll.vertical) {
392
+ const normalizedAngle = angle % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
393
+ return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
394
+ }
395
+ return false;
396
+ }
381
397
  isVisible() {
382
398
  return !this.destroyed && !this.spawning && this.isInsideCanvas();
383
399
  }
@@ -7,4 +7,4 @@ export const generatedAttribute = "generated", resizeEvent = "resize", visibilit
7
7
  b: 0,
8
8
  c: 0,
9
9
  d: 1,
10
- }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, rollFactor = 1, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0;
10
+ }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0;
@@ -1,30 +1,45 @@
1
1
  export var EasingType;
2
2
  (function (EasingType) {
3
3
  EasingType["easeInBack"] = "ease-in-back";
4
+ EasingType["easeInBounce"] = "ease-in-bounce";
4
5
  EasingType["easeInCirc"] = "ease-in-circ";
5
6
  EasingType["easeInCubic"] = "ease-in-cubic";
7
+ EasingType["easeInElastic"] = "ease-in-elastic";
8
+ EasingType["easeInExpo"] = "ease-in-expo";
9
+ EasingType["easeInGaussian"] = "ease-in-gaussian";
6
10
  EasingType["easeInLinear"] = "ease-in-linear";
7
11
  EasingType["easeInQuad"] = "ease-in-quad";
8
12
  EasingType["easeInQuart"] = "ease-in-quart";
9
13
  EasingType["easeInQuint"] = "ease-in-quint";
10
- EasingType["easeInExpo"] = "ease-in-expo";
14
+ EasingType["easeInSigmoid"] = "ease-in-sigmoid";
11
15
  EasingType["easeInSine"] = "ease-in-sine";
16
+ EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
12
17
  EasingType["easeOutBack"] = "ease-out-back";
18
+ EasingType["easeOutBounce"] = "ease-out-bounce";
13
19
  EasingType["easeOutCirc"] = "ease-out-circ";
14
20
  EasingType["easeOutCubic"] = "ease-out-cubic";
21
+ EasingType["easeOutElastic"] = "ease-out-elastic";
22
+ EasingType["easeOutExpo"] = "ease-out-expo";
23
+ EasingType["easeOutGaussian"] = "ease-out-gaussian";
15
24
  EasingType["easeOutLinear"] = "ease-out-linear";
16
25
  EasingType["easeOutQuad"] = "ease-out-quad";
17
26
  EasingType["easeOutQuart"] = "ease-out-quart";
18
27
  EasingType["easeOutQuint"] = "ease-out-quint";
19
- EasingType["easeOutExpo"] = "ease-out-expo";
28
+ EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
20
29
  EasingType["easeOutSine"] = "ease-out-sine";
30
+ EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
21
31
  EasingType["easeInOutBack"] = "ease-in-out-back";
32
+ EasingType["easeInOutBounce"] = "ease-in-out-bounce";
22
33
  EasingType["easeInOutCirc"] = "ease-in-out-circ";
23
34
  EasingType["easeInOutCubic"] = "ease-in-out-cubic";
35
+ EasingType["easeInOutElastic"] = "ease-in-out-elastic";
36
+ EasingType["easeInOutExpo"] = "ease-in-out-expo";
37
+ EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
24
38
  EasingType["easeInOutLinear"] = "ease-in-out-linear";
25
39
  EasingType["easeInOutQuad"] = "ease-in-out-quad";
26
40
  EasingType["easeInOutQuart"] = "ease-in-out-quart";
27
41
  EasingType["easeInOutQuint"] = "ease-in-out-quint";
28
- EasingType["easeInOutExpo"] = "ease-in-out-expo";
42
+ EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
29
43
  EasingType["easeInOutSine"] = "ease-in-out-sine";
44
+ EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
30
45
  })(EasingType || (EasingType = {}));
@@ -1,11 +1,5 @@
1
1
  import { lFactor, minStrokeWidth, originPoint } from "../Core/Utils/Constants.js";
2
2
  import { AlterType } from "../Enums/Types/AlterType.js";
3
- export function clearDrawPlugin(context, plugin, delta) {
4
- if (!plugin.clearDraw) {
5
- return;
6
- }
7
- plugin.clearDraw(context, delta);
8
- }
9
3
  export function drawLine(context, begin, end) {
10
4
  context.beginPath();
11
5
  context.moveTo(begin.x, begin.y);
@@ -121,12 +115,6 @@ export function drawShapeBeforeDraw(container, data) {
121
115
  }
122
116
  drawer.beforeDraw(data);
123
117
  }
124
- export function drawPlugin(context, plugin, delta) {
125
- if (!plugin.draw) {
126
- return;
127
- }
128
- plugin.draw(context, delta);
129
- }
130
118
  export function drawParticlePlugin(context, plugin, particle, delta) {
131
119
  if (!plugin.drawParticle) {
132
120
  return;
@@ -98,11 +98,15 @@ export function deepExtend(destination, ...sources) {
98
98
  continue;
99
99
  }
100
100
  const sourceIsArray = Array.isArray(source);
101
- if (sourceIsArray && (isObject(destination) || !destination || !Array.isArray(destination))) {
102
- destination = [];
101
+ if (sourceIsArray) {
102
+ if (!Array.isArray(destination)) {
103
+ destination = [];
104
+ }
103
105
  }
104
- else if (!sourceIsArray && (isObject(destination) || !destination || Array.isArray(destination))) {
105
- destination = {};
106
+ else {
107
+ if (!isObject(destination) || Array.isArray(destination)) {
108
+ destination = {};
109
+ }
106
110
  }
107
111
  for (const key in source) {
108
112
  if (key === "__proto__") {
@@ -1,4 +1,4 @@
1
- import { clear, clearDrawPlugin, drawParticle, drawParticlePlugin, drawPlugin, paintBase, paintImage, } from "../Utils/CanvasUtils.js";
1
+ import { clear, drawParticle, drawParticlePlugin, paintBase, paintImage } from "../Utils/CanvasUtils.js";
2
2
  import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
3
3
  import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
4
4
  import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
@@ -194,11 +194,6 @@ export class Canvas {
194
194
  }
195
195
  this.canvasClear();
196
196
  }
197
- clearDrawPlugin(plugin, delta) {
198
- this.draw(ctx => {
199
- clearDrawPlugin(ctx, plugin, delta);
200
- });
201
- }
202
197
  destroy() {
203
198
  this.stop();
204
199
  if (this._generated) {
@@ -241,6 +236,11 @@ export class Canvas {
241
236
  colorStyles.fill = fill;
242
237
  colorStyles.stroke = stroke;
243
238
  this.draw((context) => {
239
+ for (const plugin of container.plugins) {
240
+ if (plugin.drawParticleSetup) {
241
+ plugin.drawParticleSetup(context, particle, delta);
242
+ }
243
+ }
244
244
  this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
245
245
  drawParticle({
246
246
  container,
@@ -252,8 +252,13 @@ export class Canvas {
252
252
  opacity: opacity,
253
253
  transform,
254
254
  });
255
+ this._applyPostDrawUpdaters(particle);
256
+ for (const plugin of container.plugins) {
257
+ if (plugin.drawParticleCleanup) {
258
+ plugin.drawParticleCleanup(context, particle, delta);
259
+ }
260
+ }
255
261
  });
256
- this._applyPostDrawUpdaters(particle);
257
262
  }
258
263
  drawParticlePlugin(plugin, particle, delta) {
259
264
  this.draw(ctx => {
@@ -264,19 +269,20 @@ export class Canvas {
264
269
  const { particles, plugins } = this.container;
265
270
  this.clear();
266
271
  particles.update(delta);
267
- for (const plugin of plugins.values()) {
268
- this.drawPlugin(plugin, delta);
269
- }
270
- this.draw(() => {
271
- particles.drawParticles(delta);
272
- });
273
- for (const plugin of plugins.values()) {
274
- this.clearDrawPlugin(plugin, delta);
275
- }
276
- }
277
- drawPlugin(plugin, delta) {
278
272
  this.draw(ctx => {
279
- drawPlugin(ctx, plugin, delta);
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
+ }
280
286
  });
281
287
  }
282
288
  init() {