@tsparticles/engine 3.2.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/174.min.js +2 -0
  2. package/174.min.js.LICENSE.txt +1 -0
  3. package/browser/Core/Canvas.js +9 -9
  4. package/browser/Core/Container.js +6 -6
  5. package/browser/Core/Engine.js +1 -1
  6. package/browser/Core/Particle.js +11 -11
  7. package/browser/Core/Particles.js +29 -29
  8. package/browser/Core/Utils/InteractionManager.js +4 -4
  9. package/browser/Utils/CanvasUtils.js +14 -14
  10. package/cjs/Core/Canvas.js +9 -9
  11. package/cjs/Core/Container.js +6 -6
  12. package/cjs/Core/Engine.js +2 -25
  13. package/cjs/Core/Particle.js +11 -11
  14. package/cjs/Core/Particles.js +30 -53
  15. package/cjs/Core/Utils/InteractionManager.js +4 -4
  16. package/cjs/Utils/CanvasUtils.js +14 -14
  17. package/dist_browser_Core_Container_js.js +15 -5
  18. package/esm/Core/Canvas.js +9 -9
  19. package/esm/Core/Container.js +6 -6
  20. package/esm/Core/Engine.js +1 -1
  21. package/esm/Core/Particle.js +11 -11
  22. package/esm/Core/Particles.js +29 -29
  23. package/esm/Core/Utils/InteractionManager.js +4 -4
  24. package/esm/Utils/CanvasUtils.js +14 -14
  25. package/package.json +1 -1
  26. package/report.html +1 -1
  27. package/tsparticles.engine.js +4 -4
  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 +4 -4
  31. package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -4
  32. package/types/Core/Interfaces/IEffectDrawer.d.ts +3 -3
  33. package/types/Core/Interfaces/IExternalInteractor.d.ts +1 -1
  34. package/types/Core/Interfaces/IMovePathGenerator.d.ts +2 -2
  35. package/types/Core/Interfaces/IParticleMover.d.ts +2 -2
  36. package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -2
  37. package/types/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
  38. package/types/Core/Interfaces/IShapeDrawer.d.ts +4 -4
  39. package/types/Core/Particle.d.ts +2 -2
  40. package/types/Core/Particles.d.ts +7 -7
  41. package/types/Core/Utils/ExternalInteractorBase.d.ts +1 -1
  42. package/types/Core/Utils/InteractionManager.d.ts +2 -2
  43. package/types/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
  44. package/types/Utils/CanvasUtils.d.ts +6 -6
  45. package/umd/Core/Canvas.js +9 -9
  46. package/umd/Core/Container.js +6 -6
  47. package/umd/Core/Engine.js +1 -1
  48. package/umd/Core/Particle.js +11 -11
  49. package/umd/Core/Particles.js +31 -55
  50. package/umd/Core/Utils/InteractionManager.js +4 -4
  51. package/umd/Utils/CanvasUtils.js +14 -14
  52. package/373.min.js +0 -2
  53. package/373.min.js.LICENSE.txt +0 -1
  54. package/438.min.js +0 -2
  55. package/438.min.js.LICENSE.txt +0 -1
  56. package/dist_browser_Core_Particle_js.js +0 -32
package/174.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 174.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[174],{1174:(t,i,e)=>{e.d(i,{Container:()=>D});var s=e(6299),n=e(4013),o=e(1745),a=e(746);function r(t,i,e){const s=i[e];void 0!==s&&(t[e]=(t[e]??1)*s)}function h(t,i,e=!1){if(!i)return;if(!t)return;const s=t.style;if(s)for(const t in i){const n=i[t];n&&s.setProperty(t,n,e?"important":"")}}class c{constructor(t){this.container=t,this._applyPostDrawUpdaters=t=>{for(const i of this._postDrawUpdaters)i.afterDraw?.(t)},this._applyPreDrawUpdaters=(t,i,e,s,n,o)=>{for(const a of this._preDrawUpdaters){if(a.getColorStyles){const{fill:o,stroke:r}=a.getColorStyles(i,t,e,s);o&&(n.fill=o),r&&(n.stroke=r)}if(a.getTransformValues){const t=a.getTransformValues(i);for(const i in t)r(o,t,i)}a.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,a.R5)(s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,a.R5)(s.particleStrokeColor(t))),i&&e)break;return[i,e]},this._initCover=async()=>{const t=this.container.actualOptions.backgroundMask.cover,i=t.color;if(i){const e=(0,a.BN)(i);if(e){const i={...e,a:t.opacity};this._coverColorStyle=(0,a.xx)(i,i.a)}}else await new Promise(((i,e)=>{if(!t.image)return;const s=document.createElement("img");s.addEventListener("load",(()=>{this._coverImage={image:s,opacity:t.opacity},i()})),s.addEventListener("error",(t=>{e(t.error)})),s.src=t.image}))},this._initStyle=()=>{const t=this.element,i=this.container.actualOptions;if(t){this._fullScreen?(this._originalStyle=(0,n.zw)({},t.style),this._setFullScreenStyle()):this._resetOriginalStyle();for(const e in i.style){if(!e||!i.style)continue;const s=i.style[e];s&&t.style.setProperty(e,s,"important")}}},this._initTrail=async()=>{const t=this.container.actualOptions.particles.move.trail,i=t.fill;if(!t.enable)return;const e=1/t.length;if(i.color){const t=(0,a.BN)(i.color);if(!t)return;this._trailFill={color:{...t},opacity:e}}else await new Promise(((t,s)=>{if(!i.image)return;const n=document.createElement("img");n.addEventListener("load",(()=>{this._trailFill={image:n,opacity:e},t()})),n.addEventListener("error",(t=>{s(t.error)})),n.src=i.image}))},this._paintBase=t=>{this.draw((i=>(0,o.Sn)(i,this.size,t)))},this._paintImage=(t,i)=>{this.draw((e=>(0,o.Md)(e,this.size,t,i)))},this._repairStyle=()=>{const t=this.element;t&&(this._safeMutationObserver((t=>t.disconnect())),this._initStyle(),this.initBackground(),this._safeMutationObserver((i=>i.observe(t,{attributes:!0}))))},this._resetOriginalStyle=()=>{const t=this.element,i=this._originalStyle;t&&i&&h(t,i)},this._safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)},this._setFullScreenStyle=()=>{const t=this.element;if(!t)return;h(t,{position:"fixed",zIndex:this.container.actualOptions.fullScreen.zIndex.toString(10),top:"0",left:"0",width:"100%",height:"100%"},!0)},this.size={height:0,width:0},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}clear(){const t=this.container.actualOptions,i=t.particles.move.trail,e=this._trailFill;t.backgroundMask.enable?this.paint():i.enable&&i.length>0&&e?e.color?this._paintBase((0,a.xx)(e.color,e.opacity)):e.image&&this._paintImage(e.image,e.opacity):t.clear&&this.draw((t=>{(0,o.IU)(t,this.size)}))}destroy(){if(this.stop(),this._generated){const t=this.element;t?.remove()}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}draw(t){const i=this._context;if(i)return t(i)}drawAsync(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<=0)return;const s=t.getFillColor(),n=t.getStrokeColor()??s;let[r,h]=this._getPluginParticleColors(t);r||(r=s),h||(h=n),(r||h)&&this.draw((s=>{const n=this.container,c=n.actualOptions,l=t.options.zIndex,d=1-t.zIndexFactor,u=d**l.opacityRate,p=t.bubble.opacity??t.opacity?.value??1,f=p*u,_=(t.strokeOpacity??p)*u,g={},m={fill:r?(0,a.LC)(r,f):void 0};m.stroke=h?(0,a.LC)(h,_):m.fill,this._applyPreDrawUpdaters(s,t,e,f,m,g),(0,o.p0)({container:n,context:s,particle:t,delta:i,colorStyles:m,backgroundMask:c.backgroundMask.enable,composite:c.backgroundMask.composite,radius:e*d**l.sizeRate,opacity:f,shadow:t.options.shadow,transform:g}),this._applyPostDrawUpdaters(t)}))}drawParticlePlugin(t,i,e){this.draw((s=>(0,o.Wb)(s,t,i,e)))}drawPlugin(t,i){this.draw((e=>(0,o.e_)(e,t,i)))}async init(){this._safeMutationObserver((t=>t.disconnect())),this._mutationObserver=(0,n.tG)((t=>{for(const i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()})),this.resize(),this._initStyle(),await this._initCover();try{await this._initTrail()}catch(t){(0,n.tZ)().error(t)}this.initBackground(),this._safeMutationObserver((t=>{this.element&&t.observe(this.element,{attributes:!0})})),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){const t=this.container.actualOptions.background,i=this.element;if(!i)return;const e=i.style;if(e){if(t.color){const i=(0,a.BN)(t.color);e.backgroundColor=i?(0,a.xx)(i,t.opacity):""}else e.backgroundColor="";e.backgroundImage=t.image||"",e.backgroundPosition=t.position||"",e.backgroundRepeat=t.repeat||"",e.backgroundSize=t.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(),this._generated=t.dataset&&s.eb in t.dataset?"true"===t.dataset[s.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,n.zw)({},this.element.style),this.size.height=t.offsetHeight,this.size.width=t.offsetWidth,this._context=this.element.getContext("2d"),this._safeMutationObserver((t=>{this.element&&t.observe(this.element,{attributes:!0})})),this.container.retina.init(),this.initBackground()}paint(){const t=this.container.actualOptions;this.draw((i=>{t.backgroundMask.enable&&t.backgroundMask.cover?((0,o.IU)(i,this.size),this._coverImage?this._paintImage(this._coverImage.image,this._coverImage.opacity):this._coverColorStyle?this._paintBase(this._coverColorStyle):this._paintBase()):this._paintBase()}))}resize(){if(!this.element)return!1;const t=this.container,i=t.retina.pixelRatio,e=t.canvas.size,s=this.element.offsetWidth*i,n=this.element.offsetHeight*i;if(n===e.height&&s===e.width&&n===this.element.height&&s===this.element.width)return!1;const o={...e};return this.element.width=e.width=this.element.offsetWidth*i,this.element.height=e.height=this.element.offsetHeight*i,this.container.started&&t.particles.setResizeFactor({width:e.width/o.width,height:e.height/o.height}),!0}stop(){this._safeMutationObserver((t=>t.disconnect())),this._mutationObserver=void 0,this.draw((t=>(0,o.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()}}var l=e(645);function d(t,i,e,s,n){if(s){let s={passive:!0};(0,l.Lm)(n)?s.capture=n:void 0!==n&&(s=n),t.addEventListener(i,e,s)}else{const s=n;t.removeEventListener(i,e,s)}}class u{constructor(t){this.container=t,this._doMouseTouchClick=t=>{const i=this.container,e=i.actualOptions;if(this._canPush){const t=i.interactivity.mouse,s=t.position;if(!s)return;t.clickPosition={...s},t.clickTime=(new Date).getTime();const o=e.interactivity.events.onClick;(0,n.wJ)(o.mode,(t=>this.container.handleClickMode(t)))}if("touchend"===t.type){setTimeout((()=>this._mouseTouchFinish()),500)}},this._handleThemeChange=t=>{const i=t,e=this.container,s=e.options,n=s.defaultThemes,o=i.matches?n.dark:n.light,a=s.themes.find((t=>t.name===o));a&&a.default.auto&&e.loadTheme(o)},this._handleVisibilityChange=()=>{const t=this.container,i=t.actualOptions;this._mouseTouchFinish(),i.pauseOnBlur&&(document&&document.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.interactivity.events.resize.delay*s.Xu)},this._manageInteractivityListeners=(t,i)=>{const e=this._handlers,n=this.container,o=n.actualOptions,a=n.interactivity.element;if(!a)return;const r=a,h=n.canvas.element;h&&(h.style.pointerEvents=r===h?"initial":"none"),(o.interactivity.events.onHover.enable||o.interactivity.events.onClick.enable)&&(d(a,s.Rb,e.mouseMove,i),d(a,s.s7,e.touchStart,i),d(a,s.DG,e.touchMove,i),o.interactivity.events.onClick.enable?(d(a,s.Bp,e.touchEndClick,i),d(a,s.vo,e.mouseUp,i),d(a,s.ms,e.mouseDown,i)):d(a,s.Bp,e.touchEnd,i),d(a,t,e.mouseLeave,i),d(a,s.G3,e.touchCancel,i))},this._manageListeners=t=>{const i=this._handlers,e=this.container,n=e.actualOptions.interactivity.detectsOn,o=e.canvas.element;let a=s.Z0;"window"===n?(e.interactivity.element=window,a=s.sf):e.interactivity.element="parent"===n&&o?o.parentElement??o.parentNode:o,this._manageMediaMatch(t),this._manageResize(t),this._manageInteractivityListeners(a,t),document&&d(document,s.nK,i.visibilityChange,t,!1)},this._manageMediaMatch=t=>{const i=this._handlers,e=(0,n.lV)("(prefers-color-scheme: dark)");e&&(void 0===e.addEventListener?void 0!==e.addListener&&(t?e.addListener(i.oldThemeChange):e.removeListener(i.oldThemeChange)):d(e,"change",i.themeChange,t))},this._manageResize=t=>{const i=this._handlers,e=this.container;if(!e.actualOptions.interactivity.events.resize)return;if("undefined"==typeof ResizeObserver)return void d(window,s.NF,i.resize,t);const n=e.canvas.element;this._resizeObserver&&!t?(n&&this._resizeObserver.unobserve(n),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&n&&(this._resizeObserver=new ResizeObserver((t=>{t.find((t=>t.target===n))&&this._handleWindowResize()})),this._resizeObserver.observe(n))},this._mouseDown=()=>{const{interactivity:t}=this.container;if(!t)return;const{mouse:i}=t;i.clicking=!0,i.downPosition=i.position},this._mouseTouchClick=t=>{const i=this.container,e=i.actualOptions,{mouse:s}=i.interactivity;s.inside=!0;let n=!1;const o=s.position;if(o&&e.interactivity.events.onClick.enable){for(const[,t]of i.plugins)if(t.clickPositionValid&&(n=t.clickPositionValid(o),n))break;n||this._doMouseTouchClick(t),s.clicking=!1}},this._mouseTouchFinish=()=>{const t=this.container.interactivity;if(!t)return;const i=t.mouse;delete i.position,delete i.clickPosition,delete i.downPosition,t.status=s.Z0,i.inside=!1,i.clicking=!1},this._mouseTouchMove=t=>{const i=this.container,e=i.actualOptions,n=i.interactivity,o=i.canvas.element;if(!n?.element)return;let a;if(n.mouse.inside=!0,t.type.startsWith("pointer")){this._canPush=!0;const i=t;if(n.element===window){if(o){const t=o.getBoundingClientRect();a={x:i.clientX-t.left,y:i.clientY-t.top}}}else if("parent"===e.interactivity.detectsOn){const t=i.target,e=i.currentTarget;if(t&&e&&o){const s=t.getBoundingClientRect(),n=e.getBoundingClientRect(),r=o.getBoundingClientRect();a={x:i.offsetX+2*s.left-(n.left+r.left),y:i.offsetY+2*s.top-(n.top+r.top)}}else a={x:i.offsetX??i.clientX,y:i.offsetY??i.clientY}}else i.target===o&&(a={x:i.offsetX??i.clientX,y:i.offsetY??i.clientY})}else if(this._canPush="touchmove"!==t.type,o){const i=t,e=1,s=i.touches[i.touches.length-e],n=o.getBoundingClientRect(),r=0;a={x:s.clientX-(n.left??r),y:s.clientY-(n.top??r)}}const r=i.retina.pixelRatio;a&&(a.x*=r,a.y*=r),n.mouse.position=a,n.status=s.Rb},this._touchEnd=t=>{const i=t,e=Array.from(i.changedTouches);for(const t of e)this._touches.delete(t.identifier);this._mouseTouchFinish()},this._touchEndClick=t=>{const i=t,e=Array.from(i.changedTouches);for(const t of e)this._touches.delete(t.identifier);this._mouseTouchClick(t)},this._touchStart=t=>{const i=t,e=Array.from(i.changedTouches);for(const t of e)this._touches.set(t.identifier,performance.now());this._mouseTouchMove(t)},this._canPush=!0,this._touches=new Map,this._handlers={mouseDown:()=>this._mouseDown(),mouseLeave:()=>this._mouseTouchFinish(),mouseMove:t=>this._mouseTouchMove(t),mouseUp:t=>this._mouseTouchClick(t),touchStart:t=>this._touchStart(t),touchMove:t=>this._mouseTouchMove(t),touchEnd:t=>this._touchEnd(t),touchCancel:t=>this._touchEnd(t),touchEndClick:t=>this._touchEndClick(t),visibilityChange:()=>this._handleVisibilityChange(),themeChange:t=>this._handleThemeChange(t),oldThemeChange:t=>this._handleThemeChange(t),resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}}var p=e(5890);class f{constructor(t,i){this.container=i,this._engine=t,this._interactors=[],this._externalInteractors=[],this._particleInteractors=[]}externalInteract(t){for(const i of this._externalInteractors)i.isEnabled()&&i.interact(t)}handleClickMode(t){for(const i of this._externalInteractors)i.handleClickMode?.(t)}async init(){this._interactors=await this._engine.getInteractors(this.container,!0),this._externalInteractors=[],this._particleInteractors=[];for(const t of this._interactors){switch(t.type){case"external":this._externalInteractors.push(t);break;case"particles":this._particleInteractors.push(t)}t.init()}}particlesInteract(t,i){for(const e of this._externalInteractors)e.clear(t,i);for(const e of this._particleInteractors)e.isEnabled(t)&&e.interact(t,i)}reset(t){for(const i of this._externalInteractors)i.isEnabled()&&i.reset(t);for(const i of this._particleInteractors)i.isEnabled(t)&&i.reset(t)}}var _=e(4930),g=e(4802),m=e(6051),v=e(7405);const y=.5;function w(t){if(!(0,n.hn)(t.outMode,t.checkModes))return;const i=2*t.radius;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._calcPosition=(t,i,e,s=0)=>{for(const[,s]of t.plugins){const t=void 0!==s.particlePosition?s.particlePosition(i,this):void 0;if(t)return _.p.create(t.x,t.y,e)}const n=t.canvas.size,o=(0,g.Nx)({size:n,position:i}),a=_.p.create(o.x,o.y,e),r=this.getRadius(),h=this.options.move.outModes,c=i=>{w({outMode:i,checkModes:["bounce"],coord:a.x,maxCoord:t.canvas.size.width,setCb:t=>a.x+=t,radius:r})},l=i=>{w({outMode:i,checkModes:["bounce"],coord:a.y,maxCoord:t.canvas.size.height,setCb:t=>a.y+=t,radius:r})};if(c(h.left??h.default),c(h.right??h.default),l(h.top??h.default),l(h.bottom??h.default),this._checkOverlap(a,s)){const i=1;return this._calcPosition(t,void 0,e,s+i)}return a},this._calculateVelocity=()=>{const t=(0,g.$m)(this.direction).copy(),i=this.options.move;if("inside"===i.direction||"outside"===i.direction)return t;const e=(0,g.pu)((0,g.VG)(i.angle.value)),s=(0,g.pu)((0,g.VG)(i.angle.offset)),n={left:s-e*y,right:s+e*y};return i.straight||(t.angle+=(0,g.U4)((0,g.DT)(n.left,n.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,g.G0)()),t},this._checkOverlap=(t,i=0)=>{const e=this.options.collisions,n=this.getRadius();if(!e.enable)return!1;const o=e.overlap;if(o.enable)return!1;const a=o.retries;if(a>=0&&i>a)throw new Error(`${s.dI} particle is overlapping and can't be placed`);return!!this.container.particles.find((i=>(0,g.Yf)(t,i.position)<n+i.getRadius()))},this._getRollColor=t=>{if(!t||!this.roll||!this.backColor&&!this.roll.alter)return t;const i=this.roll.horizontal&&this.roll.vertical?2:1,e=this.roll.horizontal?Math.PI*y:0;return Math.floor(((this.roll.angle??0)+e)/(Math.PI/i))%2?this.backColor?this.backColor:this.roll.alter?(0,o.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t},this._initPosition=t=>{const i=this.container,e=(0,g.VG)(this.options.zIndex.value);this.position=this._calcPosition(i,t,(0,g.qE)(e,0,i.zLayers)),this.initialPosition=this.position.copy();const s=i.canvas.size;switch(this.moveCenter={...(0,n.E9)(this.options.move.center,s),radius:this.options.move.center.radius??0,mode:this.options.move.center.mode??"percent"},this.direction=(0,g.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case"inside":this.outType="inside";break;case"outside":this.outType="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=i.shapeDrawers.get(this.shape);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("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)}getFillColor(){return this._getRollColor(this.bubble.color??(0,a.O_)(this.color))}getMass(){return this.getRadius()**2*Math.PI*y}getPosition(){return{x:this.position.x+this.offset.x,y:this.position.y+this.offset.y,z:this.position.z}}getRadius(){return this.bubble.radius??this.size.value}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,a.O_)(this.strokeColor))}init(t,i,e,o){const r=this.container,h=this._engine;this.id=t,this.group=o,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.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType="normal",this.ignoresResizeRatio=!0;const c=r.retina.pixelRatio,l=r.actualOptions,d=(0,v.y)(this._engine,r,l.particles),u=d.effect.type,p=d.shape.type,{reduceDuplicates:f}=d;this.effect=(0,n.TA)(u,this.id,f),this.shape=(0,n.TA)(p,this.id,f);const _=d.effect,y=d.shape;if(e){if(e.effect?.type){const t=e.effect.type,i=(0,n.TA)(t,this.id,f);i&&(this.effect=i,_.load(e.effect))}if(e.shape?.type){const t=e.shape.type,i=(0,n.TA)(t,this.id,f);i&&(this.shape=i,y.load(e.shape))}}this.effectData=function(t,i,e,s){const o=i.options[t];if(o)return(0,n.zw)({close:i.close,fill:i.fill},(0,n.TA)(o,e,s))}(this.effect,_,this.id,f),this.shapeData=function(t,i,e,s){const o=i.options[t];if(o)return(0,n.zw)({close:i.close,fill:i.fill},(0,n.TA)(o,e,s))}(this.shape,y,this.id,f),d.load(e);const w=this.effectData;w&&d.load(w.particles);const b=this.shapeData;b&&d.load(b.particles);const z=new m.k(h,r);z.load(r.actualOptions.interactivity),z.load(d.interactivity),this.interactivity=z,this.effectFill=w?.fill??d.effect.fill,this.effectClose=w?.close??d.effect.close,this.shapeFill=b?.fill??d.shape.fill,this.shapeClose=b?.close??d.shape.close,this.options=d;const C=this.options.move.path;this.pathDelay=(0,g.VG)(C.delay.value)*s.Xu,C.generator&&(this.pathGenerator=this._engine.getPathGenerator(C.generator),this.pathGenerator&&r.addPath(C.generator,this.pathGenerator)&&this.pathGenerator.init(r)),r.retina.initParticle(this),this.size=(0,n.Xs)(this.options.size,c),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy();this.moveDecay=1-(0,g.VG)(this.options.move.decay);const x=r.particles;x.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/r.zLayers,this.sides=24;let k=r.effectDrawers.get(this.effect);k||(k=this._engine.getEffectDrawer(this.effect),k&&r.effectDrawers.set(this.effect,k)),k?.loadEffect&&k.loadEffect(this);let P=r.shapeDrawers.get(this.shape);P||(P=this._engine.getShapeDrawer(this.shape),P&&r.shapeDrawers.set(this.shape,P)),P?.loadShape&&P.loadShape(this);const O=P?.getSidesCount;O&&(this.sides=O(this)),this.spawning=!1,this.shadowColor=(0,a.BN)(this.options.shadow.color);for(const t of x.updaters)t.init(this);for(const t of x.movers)t.init?.(this);k?.particleInit?.(r,this),P?.particleInit?.(r,this);for(const[,t]of r.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(888),C=e(6858);const x=.5;class k{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:n}=this;for(let o=0;o<4;o++){const a=o%2;this._subs.push(new k(new C.M_(t+e*x*a,i+s*x*(Math.round(o*x)-a),e*x,s*x),n))}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 s of this._points)!t.contains(s.position)&&(0,g.Yf)(t.position,s.position)>s.particle.getRadius()&&(!i||i(s.particle))||e.push(s.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 C.jl(t.x,t.y,i),e)}queryRectangle(t,i,e){return this.query(new C.M_(t.x,t.y,i.width,i.height),e)}}const P=t=>{const{height:i,width:e}=t;return new C.M_(-.25*e,-.25*i,1.5*e,1.5*i)};class O{constructor(t,i){this._addToPool=(...t)=>{for(const i of t)this._pool.push(i)},this._applyDensity=(t,i,e)=>{const s=t.number;if(!t.number.density?.enable)return void(void 0===e?this._limit=s.limit.value:s.limit&&this._groupLimits.set(e,s.limit.value));const n=this._initDensityFactor(s.density),o=s.value,a=s.limit.value>0?s.limit.value:o,r=Math.min(o,a)*n+i,h=Math.min(this.count,this.filter((t=>t.group===e)).length);void 0===e?this._limit=s.limit.value*n:this._groupLimits.set(e,s.limit.value*n),h<r?this.push(Math.abs(r-h),void 0,t,e):h>r&&this.removeQuantity(h-r,e)},this._initDensityFactor=t=>{const i=this._container;if(!i.canvas.element||!t.enable)return 1;const e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**2)},this._pushParticle=(t,i,e,o)=>{try{let s=this._pool.pop();s||(s=new b(this._engine,this._container)),s.init(this._nextId,t,i,e);let n=!0;if(o&&(n=o(s)),!n)return;return this._array.push(s),this._zArray.push(s),this._nextId++,this._engine.dispatchEvent("particleAdded",{container:this._container,data:{particle:s}}),s}catch(t){(0,n.tZ)().warning(`${s.dI} adding particle: ${t}`)}},this._removeParticle=(t,i,e)=>{const s=this._array[t];if(!s||s.group!==i)return!1;const n=this._zArray.indexOf(s);return this._array.splice(t,1),this._zArray.splice(n,1),s.destroy(e),this._engine.dispatchEvent("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._interactionManager=new f(t,i),this._pluginsInitialized=!1;const e=i.canvas.size;this.quadTree=new k(P(e),4),this.movers=[],this.updaters=[]}get count(){return this._array.length}addManualParticles(){const t=this._container,i=t.actualOptions;for(const e of i.manualParticles)this.addParticle(e.position?(0,n.E9)(e.position,t.canvas.size):void 0,e.options)}addParticle(t,i,e,s){const n=this._container.actualOptions.particles.number.limit,o=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,a=this.count;if(o>0)if("delete"===n.mode){const t=a+1-o;t>0&&this.removeQuantity(t)}else if("wait"===n.mode&&a>=o)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=[]}draw(t){const i=this._container,e=i.canvas;e.clear(),this.update(t);for(const[,s]of i.plugins)e.drawPlugin(s,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]}handleClickMode(t){this._interactionManager.handleClickMode(t)}async init(){const t=this._container,i=t.actualOptions;this._lastZIndex=0,this._needsSort=!1,await this.initPlugins();let e=!1;for(const[,i]of t.plugins)if(void 0!==i.particlesInitialization&&(e=i.particlesInitialization()),e)break;if(this.addManualParticles(),!e){const t=i.particles,e=t.groups;for(const i in e){const s=e[i];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),await this._interactionManager.init();for(const[,i]of t.pathGenerators)i.init(t)}push(t,i,e,s){for(let n=0;n<t;n++)this.addParticle(i?.position,e,s)}async redraw(){this.clear(),await this.init(),this.draw({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=1,e,s){if(t<0||t>this.count)return;let n=0;for(let o=t;n<i&&o<this.count;o++)this._removeParticle(o--,e,s)&&n++}removeQuantity(t,i){this.removeAt(0,t,i)}setDensity(){const t=this._container.actualOptions,i=t.particles.groups;for(const t in i)this._applyDensity(i[t],0,t);this._applyDensity(t.particles,t.manualParticles.length)}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 k(P(i.canvas.size),4);for(const[,t]of i.pathGenerators)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,this._interactionManager.reset(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("particleRemoved",{container:this._container,data:{particle:t}});this._addToPool(...e)}this._interactionManager.externalInteract(t);for(const i of this._array){for(const e of this.updaters)e.update(i,t);i.destroyed||i.spawning||this._interactionManager.particlesInteract(i,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=1;this._lastZIndex=t[t.length-i].position.z,this._needsSort=!1}}}class T{constructor(t){this.container=t,this.pixelRatio=1,this.reduceFactor=1}init(){const t=this.container,i=t.actualOptions;this.pixelRatio=!i.detectRetina||(0,n.B9)()?1:window.devicePixelRatio,this.reduceFactor=1;const e=this.pixelRatio,s=t.canvas;if(s.element){const t=s.element;s.size.width=t.offsetWidth*e,s.size.height=t.offsetHeight*e}const o=i.particles,a=o.move;this.maxSpeed=(0,g.VG)(a.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,g.VG)(o.size.animation.speed)*e}initParticle(t){const i=t.options,e=this.pixelRatio,s=i.move,n=s.distance,o=t.retina;o.moveDrift=(0,g.VG)(s.drift)*e,o.moveSpeed=(0,g.VG)(s.speed)*e,o.sizeAnimationSpeed=(0,g.VG)(i.size.animation.speed)*e;const a=o.maxDistance;a.horizontal=void 0!==n.horizontal?n.horizontal*e:void 0,a.vertical=void 0!==n.vertical?n.vertical*e:void 0,o.maxSpeed=(0,g.VG)(s.gravity.maxSpeed)*e}}function M(t){return t&&!t.destroyed}function S(t,i,...e){const s=new p.J(t,i);return(0,v.Z)(s,...e),s}class D{constructor(t,i,e){this._intersectionManager=t=>{if(M(this)&&this.actualOptions.pauseOnOutsideViewport)for(const i of t)i.target===this.interactivity.element&&(i.isIntersecting?this.play():this.pause())},this._nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+s.Xu/this.fpsLimit)return void this.draw(!1);this._lastFrameTime??=t;const i=function(t,i=60,e=!1){return{value:t,factor:e?60/i:60*t/s.Xu}}(t-this._lastFrameTime,this.fpsLimit,this._smooth);if(this.addLifeTime(i.value),this._lastFrameTime=t,i.value>s.Xu)return void this.draw(!1);if(this.particles.draw(i),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,n.tZ)().error(`${s.dI} in animation loop`,t)}},this._engine=t,this.id=Symbol(i),this.fpsLimit=120,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 T(this),this.canvas=new c(this),this.particles=new O(this._engine,this),this.pathGenerators=new Map,this.interactivity={mouse:{clicking:!1,inside:!1}},this.plugins=new Map,this.effectDrawers=new Map,this.shapeDrawers=new Map,this._options=S(this._engine,this),this.actualOptions=S(this._engine,this),this._eventListeners=new u(this),this._intersectionObserver=(0,n.BR)((t=>this._intersectionManager(t))),this._engine.dispatchEvent("containerBuilt",{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&M(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addClickHandler(t){if(!M(this))return;const i=this.interactivity.element;if(!i)return;const e=(i,e,s)=>{if(!M(this))return;const n=this.retina.pixelRatio,o={x:e.x*n,y:e.y*n},a=this.particles.quadTree.queryCircle(o,s*n);t(i,a)};let s=!1,n=!1;i.addEventListener("click",(t=>{if(!M(this))return;const i=t,s={x:i.offsetX||i.clientX,y:i.offsetY||i.clientY};e(t,s,1)})),i.addEventListener("touchstart",(()=>{M(this)&&(s=!0,n=!1)})),i.addEventListener("touchmove",(()=>{M(this)&&(n=!0)})),i.addEventListener("touchend",(t=>{if(M(this)){if(s&&!n){const i=t,s=1;let n=i.touches[i.touches.length-s];if(!n&&(n=i.changedTouches[i.changedTouches.length-s],!n))return;const o=this.canvas.element,a=o?o.getBoundingClientRect():void 0,r=0,h={x:n.clientX-(a?a.left:r),y:n.clientY-(a?a.top:r)};e(t,h,Math.max(n.radiusX,n.radiusY))}s=!1,n=!1}})),i.addEventListener("touchcancel",(()=>{M(this)&&(s=!1,n=!1)}))}addLifeTime(t){this._lifeTime+=t}addPath(t,i,e=!1){return!(!M(this)||!e&&this.pathGenerators.has(t))&&(this.pathGenerators.set(t,i),!0)}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(){if(!M(this))return;this.stop(),this.particles.destroy(),this.canvas.destroy();for(const[,t]of this.effectDrawers)t.destroy?.(this);for(const[,t]of this.shapeDrawers)t.destroy?.(this);for(const t of this.effectDrawers.keys())this.effectDrawers.delete(t);for(const t of this.shapeDrawers.keys())this.shapeDrawers.delete(t);this._engine.clearPlugins(this),this.destroyed=!0;const t=this._engine.dom(),i=t.findIndex((t=>t===this));if(i>=0){const e=1;t.splice(i,e)}this._engine.dispatchEvent("containerDestroyed",{container:this})}draw(t){if(!M(this))return;let i=t;const e=t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)};this._drawAnimationFrame=requestAnimationFrame((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,n.tZ)().error(`${s.dI} - Export plugin with type ${t} not found`)}handleClickMode(t){if(M(this)){this.particles.handleClickMode(t);for(const[,i]of this.plugins)i.handleClickMode?.(t)}}async init(){if(!M(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)}await this.particles.initPlugins(),this._options=S(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=S(this._engine,this,this._options);const e=await this._engine.getAvailablePlugins(this);for(const[t,i]of e)this.plugins.set(t,i);this.retina.init(),await this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize(),this.zLayers=this.actualOptions.zLayers,this._duration=(0,g.VG)(this.actualOptions.duration)*s.Xu,this._delay=(0,g.VG)(this.actualOptions.delay)*s.Xu,this._lifeTime=0;this.fpsLimit=this.actualOptions.fpsLimit>0?this.actualOptions.fpsLimit:120,this._smooth=this.actualOptions.smooth;for(const[,t]of this.effectDrawers)await(t.init?.(this));for(const[,t]of this.shapeDrawers)await(t.init?.(this));for(const[,t]of this.plugins)await(t.init?.());this._engine.dispatchEvent("containerInit",{container:this}),await this.particles.init(),this.particles.setDensity();for(const[,t]of this.plugins)t.particlesSetup?.();this._engine.dispatchEvent("particlesSetup",{container:this})}async loadTheme(t){M(this)&&(this._currentTheme=t,await this.refresh())}pause(){if(M(this)&&(void 0!==this._drawAnimationFrame&&(cancelAnimationFrame(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(const[,t]of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent("containerPaused",{container:this})}}play(t){if(!M(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("containerPlay",{container:this}),this.draw(i??!1)}else this._firstStart=!1}async refresh(){if(M(this))return this.stop(),this.start()}async reset(){if(M(this))return this._initialSourceOptions=void 0,this._options=S(this._engine,this),this.actualOptions=S(this._engine,this,this._options),this.refresh()}async start(){M(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise((t=>{const i=async()=>{this._eventListeners.addListeners(),this.interactivity.element instanceof HTMLElement&&this._intersectionObserver&&this._intersectionObserver.observe(this.interactivity.element);for(const[,t]of this.plugins)await(t.start?.());this._engine.dispatchEvent("containerStarted",{container:this}),this.play(),t()};this._delayTimeout=setTimeout((()=>{i()}),this._delay)})))}stop(){if(M(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(),this.interactivity.element instanceof HTMLElement&&this._intersectionObserver&&this._intersectionObserver.unobserve(this.interactivity.element);for(const[,t]of this.plugins)t.stop?.();for(const t of this.plugins.keys())this.plugins.delete(t);this._sourceOptions=this._options,this._engine.dispatchEvent("containerStopped",{container:this})}}updateActualOptions(){this.actualOptions.responsive=[];const t=this.actualOptions.setResponsive(this.canvas.size.width,this.retina.pixelRatio,this._options);return this.actualOptions.setTheme(this._currentTheme),this._responsiveMaxWidth!==t&&(this._responsiveMaxWidth=t,!0)}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Engine v3.3.0 by Matteo Bruni */
@@ -270,11 +270,11 @@ export class Canvas {
270
270
  drawAsync(cb) {
271
271
  const ctx = this._context;
272
272
  if (!ctx) {
273
- return Promise.resolve(undefined);
273
+ return undefined;
274
274
  }
275
275
  return cb(ctx);
276
276
  }
277
- async drawParticle(particle, delta) {
277
+ drawParticle(particle, delta) {
278
278
  if (particle.spawning || particle.destroyed) {
279
279
  return;
280
280
  }
@@ -293,13 +293,13 @@ export class Canvas {
293
293
  if (!fColor && !sColor) {
294
294
  return;
295
295
  }
296
- await this.drawAsync(async (ctx) => {
296
+ this.draw((ctx) => {
297
297
  const container = this.container, options = container.actualOptions, zIndexOptions = particle.options.zIndex, zIndexFactorOffset = 1, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, defaultOpacity = 1, opacity = particle.bubble.opacity ?? particle.opacity?.value ?? defaultOpacity, strokeOpacity = particle.strokeOpacity ?? opacity, zOpacity = opacity * zOpacityFactor, zStrokeOpacity = strokeOpacity * zOpacityFactor, transform = {}, colorStyles = {
298
298
  fill: fColor ? getStyleFromHsl(fColor, zOpacity) : undefined,
299
299
  };
300
300
  colorStyles.stroke = sColor ? getStyleFromHsl(sColor, zStrokeOpacity) : colorStyles.fill;
301
301
  this._applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform);
302
- await drawParticle({
302
+ drawParticle({
303
303
  container,
304
304
  context: ctx,
305
305
  particle,
@@ -315,11 +315,11 @@ export class Canvas {
315
315
  this._applyPostDrawUpdaters(particle);
316
316
  });
317
317
  }
318
- async drawParticlePlugin(plugin, particle, delta) {
319
- await this.drawAsync((ctx) => drawParticlePlugin(ctx, plugin, particle, delta));
318
+ drawParticlePlugin(plugin, particle, delta) {
319
+ this.draw((ctx) => drawParticlePlugin(ctx, plugin, particle, delta));
320
320
  }
321
- async drawPlugin(plugin, delta) {
322
- await this.drawAsync((ctx) => drawPlugin(ctx, plugin, delta));
321
+ drawPlugin(plugin, delta) {
322
+ this.draw((ctx) => drawPlugin(ctx, plugin, delta));
323
323
  }
324
324
  async init() {
325
325
  this._safeMutationObserver((obs) => obs.disconnect());
@@ -472,7 +472,7 @@ export class Canvas {
472
472
  return;
473
473
  }
474
474
  const container = this.container, needsRefresh = container.updateActualOptions();
475
- await container.particles.setDensity();
475
+ container.particles.setDensity();
476
476
  this._applyResizePlugins();
477
477
  if (needsRefresh) {
478
478
  await container.refresh();
@@ -40,7 +40,7 @@ export class Container {
40
40
  }
41
41
  }
42
42
  };
43
- this._nextFrame = async (timestamp) => {
43
+ this._nextFrame = (timestamp) => {
44
44
  try {
45
45
  if (!this._smooth &&
46
46
  this._lastFrameTime !== undefined &&
@@ -56,7 +56,7 @@ export class Container {
56
56
  this.draw(false);
57
57
  return;
58
58
  }
59
- await this.particles.draw(delta);
59
+ this.particles.draw(delta);
60
60
  if (!this.alive()) {
61
61
  this.destroy();
62
62
  return;
@@ -237,14 +237,14 @@ export class Container {
237
237
  return;
238
238
  }
239
239
  let refreshTime = force;
240
- const frame = async (timestamp) => {
240
+ const frame = (timestamp) => {
241
241
  if (refreshTime) {
242
242
  this._lastFrameTime = undefined;
243
243
  refreshTime = false;
244
244
  }
245
- await this._nextFrame(timestamp);
245
+ this._nextFrame(timestamp);
246
246
  };
247
- this._drawAnimationFrame = requestAnimationFrame((timestamp) => void frame(timestamp));
247
+ this._drawAnimationFrame = requestAnimationFrame((timestamp) => frame(timestamp));
248
248
  }
249
249
  async export(type, options = {}) {
250
250
  for (const [, plugin] of this.plugins) {
@@ -316,7 +316,7 @@ export class Container {
316
316
  }
317
317
  this._engine.dispatchEvent("containerInit", { container: this });
318
318
  await this.particles.init();
319
- await this.particles.setDensity();
319
+ this.particles.setDensity();
320
320
  for (const [, plugin] of this.plugins) {
321
321
  plugin.particlesSetup?.();
322
322
  }
@@ -50,7 +50,7 @@ export class Engine {
50
50
  return res;
51
51
  }
52
52
  get version() {
53
- return "3.2.2";
53
+ return "3.3.0";
54
54
  }
55
55
  addConfig(config) {
56
56
  const key = config.key ?? config.name ?? "default";
@@ -175,12 +175,12 @@ export class Particle {
175
175
  },
176
176
  });
177
177
  }
178
- async draw(delta) {
178
+ draw(delta) {
179
179
  const container = this.container, canvas = container.canvas;
180
180
  for (const [, plugin] of container.plugins) {
181
- await canvas.drawParticlePlugin(plugin, this, delta);
181
+ canvas.drawParticlePlugin(plugin, this, delta);
182
182
  }
183
- await canvas.drawParticle(this, delta);
183
+ canvas.drawParticle(this, delta);
184
184
  }
185
185
  getFillColor() {
186
186
  return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.color));
@@ -201,7 +201,7 @@ export class Particle {
201
201
  getStrokeColor() {
202
202
  return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
203
203
  }
204
- async init(id, position, overrideOptions, group) {
204
+ init(id, position, overrideOptions, group) {
205
205
  const container = this.container, engine = this._engine;
206
206
  this.id = id;
207
207
  this.group = group;
@@ -265,7 +265,7 @@ export class Particle {
265
265
  if (pathOptions.generator) {
266
266
  this.pathGenerator = this._engine.getPathGenerator(pathOptions.generator);
267
267
  if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
268
- await this.pathGenerator.init(container);
268
+ this.pathGenerator.init(container);
269
269
  }
270
270
  }
271
271
  container.retina.initParticle(this);
@@ -294,7 +294,7 @@ export class Particle {
294
294
  }
295
295
  }
296
296
  if (effectDrawer?.loadEffect) {
297
- await effectDrawer.loadEffect(this);
297
+ effectDrawer.loadEffect(this);
298
298
  }
299
299
  let shapeDrawer = container.shapeDrawers.get(this.shape);
300
300
  if (!shapeDrawer) {
@@ -304,7 +304,7 @@ export class Particle {
304
304
  }
305
305
  }
306
306
  if (shapeDrawer?.loadShape) {
307
- await shapeDrawer.loadShape(this);
307
+ shapeDrawer.loadShape(this);
308
308
  }
309
309
  const sideCountFunc = shapeDrawer?.getSidesCount;
310
310
  if (sideCountFunc) {
@@ -313,13 +313,13 @@ export class Particle {
313
313
  this.spawning = false;
314
314
  this.shadowColor = rangeColorToRgb(this.options.shadow.color);
315
315
  for (const updater of particles.updaters) {
316
- await updater.init(this);
316
+ updater.init(this);
317
317
  }
318
318
  for (const mover of particles.movers) {
319
- await mover.init?.(this);
319
+ mover.init?.(this);
320
320
  }
321
- await effectDrawer?.particleInit?.(container, this);
322
- await shapeDrawer?.particleInit?.(container, this);
321
+ effectDrawer?.particleInit?.(container, this);
322
+ shapeDrawer?.particleInit?.(container, this);
323
323
  for (const [, plugin] of container.plugins) {
324
324
  plugin.particleCreated?.(this);
325
325
  }
@@ -1,5 +1,6 @@
1
1
  import { getLogger, getPosition } from "../Utils/Utils.js";
2
2
  import { InteractionManager } from "./Utils/InteractionManager.js";
3
+ import { Particle } from "./Particle.js";
3
4
  import { Point } from "./Utils/Point.js";
4
5
  import { QuadTree } from "./Utils/QuadTree.js";
5
6
  import { Rectangle } from "./Utils/Ranges.js";
@@ -16,7 +17,7 @@ export class Particles {
16
17
  this._pool.push(particle);
17
18
  }
18
19
  };
19
- this._applyDensity = async (options, manualCount, group) => {
20
+ this._applyDensity = (options, manualCount, group) => {
20
21
  const numberOptions = options.number;
21
22
  if (!options.number.density?.enable) {
22
23
  if (group === undefined) {
@@ -35,7 +36,7 @@ export class Particles {
35
36
  this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
36
37
  }
37
38
  if (particlesCount < particlesNumber) {
38
- await this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
39
+ this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
39
40
  }
40
41
  else if (particlesCount > particlesNumber) {
41
42
  this.removeQuantity(particlesCount - particlesNumber, group);
@@ -49,14 +50,13 @@ export class Particles {
49
50
  const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
50
51
  return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp);
51
52
  };
52
- this._pushParticle = async (position, overrideOptions, group, initializer) => {
53
+ this._pushParticle = (position, overrideOptions, group, initializer) => {
53
54
  try {
54
55
  let particle = this._pool.pop();
55
56
  if (!particle) {
56
- const { Particle } = await import("./Particle.js");
57
57
  particle = new Particle(this._engine, this._container);
58
58
  }
59
- await particle.init(this._nextId, position, overrideOptions, group);
59
+ particle.init(this._nextId, position, overrideOptions, group);
60
60
  let canAdd = true;
61
61
  if (initializer) {
62
62
  canAdd = initializer(particle);
@@ -117,13 +117,13 @@ export class Particles {
117
117
  get count() {
118
118
  return this._array.length;
119
119
  }
120
- async addManualParticles() {
120
+ addManualParticles() {
121
121
  const container = this._container, options = container.actualOptions;
122
122
  for (const particle of options.manualParticles) {
123
- await this.addParticle(particle.position ? getPosition(particle.position, container.canvas.size) : undefined, particle.options);
123
+ this.addParticle(particle.position ? getPosition(particle.position, container.canvas.size) : undefined, particle.options);
124
124
  }
125
125
  }
126
- async addParticle(position, overrideOptions, group, initializer) {
126
+ addParticle(position, overrideOptions, group, initializer) {
127
127
  const limitOptions = this._container.actualOptions.particles.number.limit, limit = group === undefined ? this._limit : this._groupLimits.get(group) ?? this._limit, currentCount = this.count, minLimit = 0;
128
128
  if (limit > minLimit) {
129
129
  if (limitOptions.mode === "delete") {
@@ -138,7 +138,7 @@ export class Particles {
138
138
  }
139
139
  }
140
140
  }
141
- return await this._pushParticle(position, overrideOptions, group, initializer);
141
+ return this._pushParticle(position, overrideOptions, group, initializer);
142
142
  }
143
143
  clear() {
144
144
  this._array = [];
@@ -151,15 +151,15 @@ export class Particles {
151
151
  this.movers = [];
152
152
  this.updaters = [];
153
153
  }
154
- async draw(delta) {
154
+ draw(delta) {
155
155
  const container = this._container, canvas = container.canvas;
156
156
  canvas.clear();
157
- await this.update(delta);
157
+ this.update(delta);
158
158
  for (const [, plugin] of container.plugins) {
159
- await canvas.drawPlugin(plugin, delta);
159
+ canvas.drawPlugin(plugin, delta);
160
160
  }
161
161
  for (const p of this._zArray) {
162
- await p.draw(delta);
162
+ p.draw(delta);
163
163
  }
164
164
  }
165
165
  filter(condition) {
@@ -188,17 +188,17 @@ export class Particles {
188
188
  break;
189
189
  }
190
190
  }
191
- await this.addManualParticles();
191
+ this.addManualParticles();
192
192
  if (!handled) {
193
193
  const particlesOptions = options.particles, groups = particlesOptions.groups;
194
194
  for (const group in groups) {
195
195
  const groupOptions = groups[group];
196
196
  for (let i = this.count, j = 0; j < groupOptions.number?.value && i < particlesOptions.number.value; i++, j++) {
197
- await this.addParticle(undefined, groupOptions, group);
197
+ this.addParticle(undefined, groupOptions, group);
198
198
  }
199
199
  }
200
200
  for (let i = this.count; i < particlesOptions.number.value; i++) {
201
- await this.addParticle();
201
+ this.addParticle();
202
202
  }
203
203
  }
204
204
  }
@@ -211,18 +211,18 @@ export class Particles {
211
211
  this.updaters = await this._engine.getUpdaters(container, true);
212
212
  await this._interactionManager.init();
213
213
  for (const [, pathGenerator] of container.pathGenerators) {
214
- await pathGenerator.init(container);
214
+ pathGenerator.init(container);
215
215
  }
216
216
  }
217
- async push(nb, mouse, overrideOptions, group) {
217
+ push(nb, mouse, overrideOptions, group) {
218
218
  for (let i = 0; i < nb; i++) {
219
- await this.addParticle(mouse?.position, overrideOptions, group);
219
+ this.addParticle(mouse?.position, overrideOptions, group);
220
220
  }
221
221
  }
222
222
  async redraw() {
223
223
  this.clear();
224
224
  await this.init();
225
- await this.draw({ value: 0, factor: 0 });
225
+ this.draw({ value: 0, factor: 0 });
226
226
  }
227
227
  remove(particle, group, override) {
228
228
  this.removeAt(this._array.indexOf(particle), undefined, group, override);
@@ -243,12 +243,12 @@ export class Particles {
243
243
  const defaultIndex = 0;
244
244
  this.removeAt(defaultIndex, quantity, group);
245
245
  }
246
- async setDensity() {
246
+ setDensity() {
247
247
  const options = this._container.actualOptions, groups = options.particles.groups, manualCount = 0;
248
248
  for (const group in groups) {
249
- await this._applyDensity(groups[group], manualCount, group);
249
+ this._applyDensity(groups[group], manualCount, group);
250
250
  }
251
- await this._applyDensity(options.particles, options.manualParticles.length);
251
+ this._applyDensity(options.particles, options.manualParticles.length);
252
252
  }
253
253
  setLastZIndex(zIndex) {
254
254
  this._lastZIndex = zIndex;
@@ -257,14 +257,14 @@ export class Particles {
257
257
  setResizeFactor(factor) {
258
258
  this._resizeFactor = factor;
259
259
  }
260
- async update(delta) {
260
+ update(delta) {
261
261
  const container = this._container, particlesToDelete = new Set();
262
262
  this.quadTree = new QuadTree(qTreeRectangle(container.canvas.size), qTreeCapacity);
263
263
  for (const [, pathGenerator] of container.pathGenerators) {
264
264
  pathGenerator.update();
265
265
  }
266
266
  for (const [, plugin] of container.plugins) {
267
- await plugin.update?.(delta);
267
+ plugin.update?.(delta);
268
268
  }
269
269
  const resizeFactor = this._resizeFactor;
270
270
  for (const particle of this._array) {
@@ -284,7 +284,7 @@ export class Particles {
284
284
  }
285
285
  for (const mover of this.movers) {
286
286
  if (mover.isEnabled(particle)) {
287
- await mover.move(particle, delta);
287
+ mover.move(particle, delta);
288
288
  }
289
289
  }
290
290
  if (particle.destroyed) {
@@ -307,13 +307,13 @@ export class Particles {
307
307
  }
308
308
  this._addToPool(...particlesToDelete);
309
309
  }
310
- await this._interactionManager.externalInteract(delta);
310
+ this._interactionManager.externalInteract(delta);
311
311
  for (const particle of this._array) {
312
312
  for (const updater of this.updaters) {
313
- await updater.update(particle, delta);
313
+ updater.update(particle, delta);
314
314
  }
315
315
  if (!particle.destroyed && !particle.spawning) {
316
- await this._interactionManager.particlesInteract(particle, delta);
316
+ this._interactionManager.particlesInteract(particle, delta);
317
317
  }
318
318
  }
319
319
  delete this._resizeFactor;
@@ -6,10 +6,10 @@ export class InteractionManager {
6
6
  this._externalInteractors = [];
7
7
  this._particleInteractors = [];
8
8
  }
9
- async externalInteract(delta) {
9
+ externalInteract(delta) {
10
10
  for (const interactor of this._externalInteractors) {
11
11
  if (interactor.isEnabled()) {
12
- await interactor.interact(delta);
12
+ interactor.interact(delta);
13
13
  }
14
14
  }
15
15
  }
@@ -34,13 +34,13 @@ export class InteractionManager {
34
34
  interactor.init();
35
35
  }
36
36
  }
37
- async particlesInteract(particle, delta) {
37
+ particlesInteract(particle, delta) {
38
38
  for (const interactor of this._externalInteractors) {
39
39
  interactor.clear(particle, delta);
40
40
  }
41
41
  for (const interactor of this._particleInteractors) {
42
42
  if (interactor.isEnabled(particle)) {
43
- await interactor.interact(particle, delta);
43
+ interactor.interact(particle, delta);
44
44
  }
45
45
  }
46
46
  }
@@ -21,7 +21,7 @@ export function paintImage(context, dimension, image, opacity) {
21
21
  export function clear(context, dimension) {
22
22
  context.clearRect(origin.x, origin.y, dimension.width, dimension.height);
23
23
  }
24
- export async function drawParticle(data) {
24
+ export function drawParticle(data) {
25
25
  const { container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow, transform, } = data, pos = particle.getPosition(), defaultAngle = 0, angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : defaultAngle), rotateData = {
26
26
  sin: Math.sin(angle),
27
27
  cos: Math.cos(angle),
@@ -60,13 +60,13 @@ export async function drawParticle(data) {
60
60
  transformData,
61
61
  strokeWidth,
62
62
  };
63
- await drawShape(drawData);
64
- await drawShapeAfterDraw(drawData);
65
- await drawEffect(drawData);
63
+ drawShape(drawData);
64
+ drawShapeAfterDraw(drawData);
65
+ drawEffect(drawData);
66
66
  context.globalCompositeOperation = "source-over";
67
67
  context.resetTransform();
68
68
  }
69
- export async function drawEffect(data) {
69
+ export function drawEffect(data) {
70
70
  const { container, context, particle, radius, opacity, delta, transformData } = data;
71
71
  if (!particle.effect) {
72
72
  return;
@@ -75,7 +75,7 @@ export async function drawEffect(data) {
75
75
  if (!drawer) {
76
76
  return;
77
77
  }
78
- await drawer.draw({
78
+ drawer.draw({
79
79
  context,
80
80
  particle,
81
81
  radius,
@@ -85,7 +85,7 @@ export async function drawEffect(data) {
85
85
  transformData: { ...transformData },
86
86
  });
87
87
  }
88
- export async function drawShape(data) {
88
+ export function drawShape(data) {
89
89
  const { container, context, particle, radius, opacity, delta, strokeWidth, transformData } = data, minStrokeWidth = 0;
90
90
  if (!particle.shape) {
91
91
  return;
@@ -95,7 +95,7 @@ export async function drawShape(data) {
95
95
  return;
96
96
  }
97
97
  context.beginPath();
98
- await drawer.draw({
98
+ drawer.draw({
99
99
  context,
100
100
  particle,
101
101
  radius,
@@ -114,7 +114,7 @@ export async function drawShape(data) {
114
114
  context.fill();
115
115
  }
116
116
  }
117
- export async function drawShapeAfterDraw(data) {
117
+ export function drawShapeAfterDraw(data) {
118
118
  const { container, context, particle, radius, opacity, delta, transformData } = data;
119
119
  if (!particle.shape) {
120
120
  return;
@@ -123,7 +123,7 @@ export async function drawShapeAfterDraw(data) {
123
123
  if (!drawer?.afterDraw) {
124
124
  return;
125
125
  }
126
- await drawer.afterDraw({
126
+ drawer.afterDraw({
127
127
  context,
128
128
  particle,
129
129
  radius,
@@ -133,17 +133,17 @@ export async function drawShapeAfterDraw(data) {
133
133
  transformData: { ...transformData },
134
134
  });
135
135
  }
136
- export async function drawPlugin(context, plugin, delta) {
136
+ export function drawPlugin(context, plugin, delta) {
137
137
  if (!plugin.draw) {
138
138
  return;
139
139
  }
140
- await plugin.draw(context, delta);
140
+ plugin.draw(context, delta);
141
141
  }
142
- export async function drawParticlePlugin(context, plugin, particle, delta) {
142
+ export function drawParticlePlugin(context, plugin, particle, delta) {
143
143
  if (!plugin.drawParticle) {
144
144
  return;
145
145
  }
146
- await plugin.drawParticle(context, particle, delta);
146
+ plugin.drawParticle(context, particle, delta);
147
147
  }
148
148
  export function alterHsl(color, type, value) {
149
149
  const lFactor = 1;
@@ -273,11 +273,11 @@ class Canvas {
273
273
  drawAsync(cb) {
274
274
  const ctx = this._context;
275
275
  if (!ctx) {
276
- return Promise.resolve(undefined);
276
+ return undefined;
277
277
  }
278
278
  return cb(ctx);
279
279
  }
280
- async drawParticle(particle, delta) {
280
+ drawParticle(particle, delta) {
281
281
  if (particle.spawning || particle.destroyed) {
282
282
  return;
283
283
  }
@@ -296,13 +296,13 @@ class Canvas {
296
296
  if (!fColor && !sColor) {
297
297
  return;
298
298
  }
299
- await this.drawAsync(async (ctx) => {
299
+ this.draw((ctx) => {
300
300
  const container = this.container, options = container.actualOptions, zIndexOptions = particle.options.zIndex, zIndexFactorOffset = 1, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, defaultOpacity = 1, opacity = particle.bubble.opacity ?? particle.opacity?.value ?? defaultOpacity, strokeOpacity = particle.strokeOpacity ?? opacity, zOpacity = opacity * zOpacityFactor, zStrokeOpacity = strokeOpacity * zOpacityFactor, transform = {}, colorStyles = {
301
301
  fill: fColor ? (0, ColorUtils_js_1.getStyleFromHsl)(fColor, zOpacity) : undefined,
302
302
  };
303
303
  colorStyles.stroke = sColor ? (0, ColorUtils_js_1.getStyleFromHsl)(sColor, zStrokeOpacity) : colorStyles.fill;
304
304
  this._applyPreDrawUpdaters(ctx, particle, radius, zOpacity, colorStyles, transform);
305
- await (0, CanvasUtils_js_1.drawParticle)({
305
+ (0, CanvasUtils_js_1.drawParticle)({
306
306
  container,
307
307
  context: ctx,
308
308
  particle,
@@ -318,11 +318,11 @@ class Canvas {
318
318
  this._applyPostDrawUpdaters(particle);
319
319
  });
320
320
  }
321
- async drawParticlePlugin(plugin, particle, delta) {
322
- await this.drawAsync((ctx) => (0, CanvasUtils_js_1.drawParticlePlugin)(ctx, plugin, particle, delta));
321
+ drawParticlePlugin(plugin, particle, delta) {
322
+ this.draw((ctx) => (0, CanvasUtils_js_1.drawParticlePlugin)(ctx, plugin, particle, delta));
323
323
  }
324
- async drawPlugin(plugin, delta) {
325
- await this.drawAsync((ctx) => (0, CanvasUtils_js_1.drawPlugin)(ctx, plugin, delta));
324
+ drawPlugin(plugin, delta) {
325
+ this.draw((ctx) => (0, CanvasUtils_js_1.drawPlugin)(ctx, plugin, delta));
326
326
  }
327
327
  async init() {
328
328
  this._safeMutationObserver((obs) => obs.disconnect());
@@ -475,7 +475,7 @@ class Canvas {
475
475
  return;
476
476
  }
477
477
  const container = this.container, needsRefresh = container.updateActualOptions();
478
- await container.particles.setDensity();
478
+ container.particles.setDensity();
479
479
  this._applyResizePlugins();
480
480
  if (needsRefresh) {
481
481
  await container.refresh();