@tsparticles/engine 3.2.1 → 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 (144) 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 +7 -7
  5. package/browser/Core/Engine.js +1 -1
  6. package/browser/Core/Particle.js +12 -13
  7. package/browser/Core/Particles.js +30 -30
  8. package/browser/Core/Utils/EventListeners.js +4 -3
  9. package/browser/Core/Utils/InteractionManager.js +4 -4
  10. package/browser/Core/Utils/QuadTree.js +4 -5
  11. package/browser/Core/Utils/Ranges.js +55 -0
  12. package/browser/Core/Utils/{Vector3d.js → Vectors.js} +15 -1
  13. package/browser/Options/Classes/AnimatableColor.js +1 -1
  14. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +1 -1
  15. package/browser/Options/Classes/Options.js +2 -1
  16. package/browser/Options/Classes/OptionsColor.js +1 -1
  17. package/browser/Options/Classes/Particles/Move/Move.js +1 -1
  18. package/browser/Types/RangeType.js +1 -0
  19. package/browser/Utils/CanvasUtils.js +14 -14
  20. package/browser/Utils/ColorUtils.js +2 -1
  21. package/browser/Utils/NumberUtils.js +2 -2
  22. package/browser/Utils/TypeUtils.js +18 -0
  23. package/browser/Utils/Utils.js +2 -19
  24. package/browser/exports.js +3 -5
  25. package/cjs/Core/Canvas.js +9 -9
  26. package/cjs/Core/Container.js +7 -7
  27. package/cjs/Core/Engine.js +2 -25
  28. package/cjs/Core/Particle.js +15 -16
  29. package/cjs/Core/Particles.js +32 -55
  30. package/cjs/Core/Utils/EventListeners.js +4 -3
  31. package/cjs/Core/Utils/InteractionManager.js +4 -4
  32. package/cjs/Core/Utils/QuadTree.js +7 -8
  33. package/cjs/Core/Utils/Ranges.js +61 -0
  34. package/cjs/Core/Utils/{Vector3d.js → Vectors.js} +18 -3
  35. package/cjs/Options/Classes/AnimatableColor.js +2 -2
  36. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +2 -2
  37. package/cjs/Options/Classes/Options.js +2 -1
  38. package/cjs/Options/Classes/OptionsColor.js +2 -2
  39. package/cjs/Options/Classes/Particles/Move/Move.js +4 -4
  40. package/cjs/Types/RangeType.js +2 -0
  41. package/cjs/Utils/CanvasUtils.js +14 -14
  42. package/cjs/Utils/ColorUtils.js +9 -8
  43. package/cjs/Utils/NumberUtils.js +9 -9
  44. package/cjs/Utils/TypeUtils.js +27 -0
  45. package/cjs/Utils/Utils.js +13 -36
  46. package/cjs/exports.js +3 -5
  47. package/dist_browser_Core_Container_js.js +17 -7
  48. package/esm/Core/Canvas.js +9 -9
  49. package/esm/Core/Container.js +7 -7
  50. package/esm/Core/Engine.js +1 -1
  51. package/esm/Core/Particle.js +12 -13
  52. package/esm/Core/Particles.js +30 -30
  53. package/esm/Core/Utils/EventListeners.js +4 -3
  54. package/esm/Core/Utils/InteractionManager.js +4 -4
  55. package/esm/Core/Utils/QuadTree.js +4 -5
  56. package/esm/Core/Utils/Ranges.js +55 -0
  57. package/esm/Core/Utils/{Vector3d.js → Vectors.js} +15 -1
  58. package/esm/Options/Classes/AnimatableColor.js +1 -1
  59. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +1 -1
  60. package/esm/Options/Classes/Options.js +2 -1
  61. package/esm/Options/Classes/OptionsColor.js +1 -1
  62. package/esm/Options/Classes/Particles/Move/Move.js +1 -1
  63. package/esm/Types/RangeType.js +1 -0
  64. package/esm/Utils/CanvasUtils.js +14 -14
  65. package/esm/Utils/ColorUtils.js +2 -1
  66. package/esm/Utils/NumberUtils.js +2 -2
  67. package/esm/Utils/TypeUtils.js +18 -0
  68. package/esm/Utils/Utils.js +2 -19
  69. package/esm/exports.js +3 -5
  70. package/package.json +1 -1
  71. package/report.html +1 -1
  72. package/tsparticles.engine.js +32 -52
  73. package/tsparticles.engine.min.js +1 -1
  74. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  75. package/types/Core/Canvas.d.ts +4 -4
  76. package/types/Core/Interfaces/ICircleBouncer.d.ts +1 -1
  77. package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -4
  78. package/types/Core/Interfaces/IEffectDrawer.d.ts +3 -3
  79. package/types/Core/Interfaces/IExternalInteractor.d.ts +1 -1
  80. package/types/Core/Interfaces/IMovePathGenerator.d.ts +3 -3
  81. package/types/Core/Interfaces/IParticleMover.d.ts +2 -2
  82. package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -2
  83. package/types/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
  84. package/types/Core/Interfaces/IShapeDrawer.d.ts +4 -4
  85. package/types/Core/Particle.d.ts +3 -4
  86. package/types/Core/Particles.d.ts +7 -7
  87. package/types/Core/Utils/ExternalInteractorBase.d.ts +1 -1
  88. package/types/Core/Utils/InteractionManager.d.ts +2 -2
  89. package/types/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
  90. package/types/Core/Utils/QuadTree.d.ts +2 -3
  91. package/types/Core/Utils/Ranges.d.ts +21 -0
  92. package/types/Core/Utils/{Vector3d.d.ts → Vectors.d.ts} +6 -0
  93. package/types/Types/RangeType.d.ts +4 -0
  94. package/types/Utils/CanvasUtils.d.ts +6 -6
  95. package/types/Utils/NumberUtils.d.ts +1 -1
  96. package/types/Utils/TypeUtils.d.ts +6 -0
  97. package/types/Utils/Utils.d.ts +0 -6
  98. package/types/exports.d.ts +3 -5
  99. package/umd/Core/Canvas.js +9 -9
  100. package/umd/Core/Container.js +7 -7
  101. package/umd/Core/Engine.js +1 -1
  102. package/umd/Core/Particle.js +16 -17
  103. package/umd/Core/Particles.js +33 -57
  104. package/umd/Core/Utils/EventListeners.js +5 -4
  105. package/umd/Core/Utils/InteractionManager.js +4 -4
  106. package/umd/Core/Utils/QuadTree.js +8 -9
  107. package/umd/Core/Utils/Ranges.js +71 -0
  108. package/umd/Core/Utils/{Vector3d.js → Vectors.js} +19 -4
  109. package/umd/Options/Classes/AnimatableColor.js +3 -3
  110. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +3 -3
  111. package/umd/Options/Classes/Options.js +3 -2
  112. package/umd/Options/Classes/OptionsColor.js +3 -3
  113. package/umd/Options/Classes/Particles/Move/Move.js +5 -5
  114. package/umd/{Core/Utils/Range.js → Types/RangeType.js} +0 -10
  115. package/umd/Utils/CanvasUtils.js +14 -14
  116. package/umd/Utils/ColorUtils.js +10 -9
  117. package/umd/Utils/NumberUtils.js +10 -10
  118. package/umd/Utils/TypeUtils.js +37 -0
  119. package/umd/Utils/Utils.js +14 -37
  120. package/umd/exports.js +4 -6
  121. package/373.min.js +0 -2
  122. package/373.min.js.LICENSE.txt +0 -1
  123. package/438.min.js +0 -2
  124. package/438.min.js.LICENSE.txt +0 -1
  125. package/browser/Core/Utils/Circle.js +0 -28
  126. package/browser/Core/Utils/Range.js +0 -8
  127. package/browser/Core/Utils/Rectangle.js +0 -22
  128. package/browser/Core/Utils/Vector.js +0 -20
  129. package/cjs/Core/Utils/Circle.js +0 -32
  130. package/cjs/Core/Utils/Range.js +0 -12
  131. package/cjs/Core/Utils/Rectangle.js +0 -26
  132. package/cjs/Core/Utils/Vector.js +0 -24
  133. package/dist_browser_Core_Particle_js.js +0 -32
  134. package/esm/Core/Utils/Circle.js +0 -28
  135. package/esm/Core/Utils/Range.js +0 -8
  136. package/esm/Core/Utils/Rectangle.js +0 -22
  137. package/esm/Core/Utils/Vector.js +0 -20
  138. package/types/Core/Utils/Circle.d.ts +0 -8
  139. package/types/Core/Utils/Range.d.ts +0 -7
  140. package/types/Core/Utils/Rectangle.d.ts +0 -9
  141. package/types/Core/Utils/Vector.d.ts +0 -8
  142. package/umd/Core/Utils/Circle.js +0 -42
  143. package/umd/Core/Utils/Rectangle.js +0 -36
  144. package/umd/Core/Utils/Vector.js +0 -34
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();
@@ -33,14 +33,14 @@ export class Container {
33
33
  continue;
34
34
  }
35
35
  if (entry.isIntersecting) {
36
- this.play();
36
+ void this.play();
37
37
  }
38
38
  else {
39
39
  this.pause();
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.1";
53
+ return "3.3.0";
54
54
  }
55
55
  addConfig(config) {
56
56
  const key = config.key ?? config.name ?? "default";
@@ -1,10 +1,9 @@
1
+ import { Vector, Vector3d } from "./Utils/Vectors.js";
1
2
  import { calcExactPositionOrRandomFromSize, clamp, degToRad, getDistance, getParticleBaseVelocity, getParticleDirectionAngle, getRandom, getRangeValue, randomInRange, setRangeValue, } from "../Utils/NumberUtils.js";
2
3
  import { deepExtend, getPosition, initParticleNumericAnimationValue, isInArray, itemFromSingleOrMultiple, } from "../Utils/Utils.js";
3
4
  import { errorPrefix, millisecondsToSeconds } from "./Utils/Constants.js";
4
5
  import { getHslFromAnimation, rangeColorToRgb } from "../Utils/ColorUtils.js";
5
6
  import { Interactivity } from "../Options/Classes/Interactivity/Interactivity.js";
6
- import { Vector } from "./Utils/Vector.js";
7
- import { Vector3d } from "./Utils/Vector3d.js";
8
7
  import { alterHsl } from "../Utils/CanvasUtils.js";
9
8
  import { loadParticlesOptions } from "../Utils/OptionsUtils.js";
10
9
  const defaultRetryCount = 0, double = 2, half = 0.5, squareExp = 2;
@@ -176,12 +175,12 @@ export class Particle {
176
175
  },
177
176
  });
178
177
  }
179
- async draw(delta) {
178
+ draw(delta) {
180
179
  const container = this.container, canvas = container.canvas;
181
180
  for (const [, plugin] of container.plugins) {
182
- await canvas.drawParticlePlugin(plugin, this, delta);
181
+ canvas.drawParticlePlugin(plugin, this, delta);
183
182
  }
184
- await canvas.drawParticle(this, delta);
183
+ canvas.drawParticle(this, delta);
185
184
  }
186
185
  getFillColor() {
187
186
  return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.color));
@@ -202,7 +201,7 @@ export class Particle {
202
201
  getStrokeColor() {
203
202
  return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
204
203
  }
205
- async init(id, position, overrideOptions, group) {
204
+ init(id, position, overrideOptions, group) {
206
205
  const container = this.container, engine = this._engine;
207
206
  this.id = id;
208
207
  this.group = group;
@@ -266,7 +265,7 @@ export class Particle {
266
265
  if (pathOptions.generator) {
267
266
  this.pathGenerator = this._engine.getPathGenerator(pathOptions.generator);
268
267
  if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
269
- await this.pathGenerator.init(container);
268
+ this.pathGenerator.init(container);
270
269
  }
271
270
  }
272
271
  container.retina.initParticle(this);
@@ -295,7 +294,7 @@ export class Particle {
295
294
  }
296
295
  }
297
296
  if (effectDrawer?.loadEffect) {
298
- await effectDrawer.loadEffect(this);
297
+ effectDrawer.loadEffect(this);
299
298
  }
300
299
  let shapeDrawer = container.shapeDrawers.get(this.shape);
301
300
  if (!shapeDrawer) {
@@ -305,7 +304,7 @@ export class Particle {
305
304
  }
306
305
  }
307
306
  if (shapeDrawer?.loadShape) {
308
- await shapeDrawer.loadShape(this);
307
+ shapeDrawer.loadShape(this);
309
308
  }
310
309
  const sideCountFunc = shapeDrawer?.getSidesCount;
311
310
  if (sideCountFunc) {
@@ -314,13 +313,13 @@ export class Particle {
314
313
  this.spawning = false;
315
314
  this.shadowColor = rangeColorToRgb(this.options.shadow.color);
316
315
  for (const updater of particles.updaters) {
317
- await updater.init(this);
316
+ updater.init(this);
318
317
  }
319
318
  for (const mover of particles.movers) {
320
- await mover.init?.(this);
319
+ mover.init?.(this);
321
320
  }
322
- await effectDrawer?.particleInit?.(container, this);
323
- await shapeDrawer?.particleInit?.(container, this);
321
+ effectDrawer?.particleInit?.(container, this);
322
+ shapeDrawer?.particleInit?.(container, this);
324
323
  for (const [, plugin] of container.plugins) {
325
324
  plugin.particleCreated?.(this);
326
325
  }
@@ -1,8 +1,9 @@
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
- import { Rectangle } from "./Utils/Rectangle.js";
6
+ import { Rectangle } from "./Utils/Ranges.js";
6
7
  import { errorPrefix } from "./Utils/Constants.js";
7
8
  const qTreeCapacity = 4, squareExp = 2, defaultRemoveQuantity = 1;
8
9
  const qTreeRectangle = (canvasSize) => {
@@ -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;
@@ -1,5 +1,6 @@
1
- import { executeOnSingleOrMultiple, isBoolean, safeMatchMedia } from "../../Utils/Utils.js";
1
+ import { executeOnSingleOrMultiple, safeMatchMedia } from "../../Utils/Utils.js";
2
2
  import { millisecondsToSeconds, mouseDownEvent, mouseLeaveEvent, mouseMoveEvent, mouseOutEvent, mouseUpEvent, resizeEvent, touchCancelEvent, touchEndEvent, touchMoveEvent, touchStartEvent, visibilityChangeEvent, } from "./Constants.js";
3
+ import { isBoolean } from "../../Utils/TypeUtils.js";
3
4
  const double = 2;
4
5
  function manageListener(element, event, handler, add, options) {
5
6
  if (add) {
@@ -56,10 +57,10 @@ export class EventListeners {
56
57
  else {
57
58
  container.pageHidden = false;
58
59
  if (container.animationStatus) {
59
- container.play(true);
60
+ void container.play(true);
60
61
  }
61
62
  else {
62
- container.draw(true);
63
+ void container.draw(true);
63
64
  }
64
65
  }
65
66
  };
@@ -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
  }
@@ -1,5 +1,4 @@
1
- import { Circle } from "./Circle.js";
2
- import { Rectangle } from "./Rectangle.js";
1
+ import { Circle, Rectangle } from "./Ranges.js";
3
2
  import { getDistance } from "../../Utils/NumberUtils.js";
4
3
  const half = 0.5, double = 2, subdivideCount = 4;
5
4
  export class QuadTree {
@@ -31,8 +30,8 @@ export class QuadTree {
31
30
  }
32
31
  return this._subs.some((sub) => sub.insert(point));
33
32
  }
34
- query(range, check, found) {
35
- const res = found ?? [];
33
+ query(range, check) {
34
+ const res = [];
36
35
  if (!range.intersects(this.rectangle)) {
37
36
  return [];
38
37
  }
@@ -46,7 +45,7 @@ export class QuadTree {
46
45
  }
47
46
  if (this._divided) {
48
47
  for (const sub of this._subs) {
49
- sub.query(range, check, res);
48
+ res.push(...sub.query(range, check));
50
49
  }
51
50
  }
52
51
  return res;
@@ -0,0 +1,55 @@
1
+ import { getDistance } from "../../Utils/NumberUtils.js";
2
+ const squareExp = 2;
3
+ export class BaseRange {
4
+ constructor(x, y, type) {
5
+ this.position = {
6
+ x: x,
7
+ y: y,
8
+ };
9
+ this.type = type;
10
+ }
11
+ }
12
+ export class Circle extends BaseRange {
13
+ constructor(x, y, radius) {
14
+ super(x, y, "circle");
15
+ this.radius = radius;
16
+ }
17
+ contains(point) {
18
+ return getDistance(point, this.position) <= this.radius;
19
+ }
20
+ intersects(range) {
21
+ const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
22
+ if (range instanceof Circle || range.type === "circle") {
23
+ const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
24
+ return rSum > dist;
25
+ }
26
+ else if (range instanceof Rectangle || range.type === "rectangle") {
27
+ const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
28
+ return (edges <= r ** squareExp ||
29
+ (distPos.x <= r + width && distPos.y <= r + height) ||
30
+ distPos.x <= width ||
31
+ distPos.y <= height);
32
+ }
33
+ return false;
34
+ }
35
+ }
36
+ export class Rectangle extends BaseRange {
37
+ constructor(x, y, width, height) {
38
+ super(x, y, "rectangle");
39
+ this.size = {
40
+ height: height,
41
+ width: width,
42
+ };
43
+ }
44
+ contains(point) {
45
+ const w = this.size.width, h = this.size.height, pos = this.position;
46
+ return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
47
+ }
48
+ intersects(range) {
49
+ if (range instanceof Circle) {
50
+ return range.intersects(this);
51
+ }
52
+ const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range instanceof Rectangle ? range.size : { width: 0, height: 0 }, w2 = size2.width, h2 = size2.height;
53
+ return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
54
+ }
55
+ }
@@ -1,5 +1,5 @@
1
1
  import { errorPrefix } from "./Constants.js";
2
- import { isNumber } from "../../Utils/Utils.js";
2
+ import { isNumber } from "../../Utils/TypeUtils.js";
3
3
  const origin = {
4
4
  x: 0,
5
5
  y: 0,
@@ -107,3 +107,17 @@ export class Vector3d {
107
107
  this.z -= v.z;
108
108
  }
109
109
  }
110
+ export class Vector extends Vector3d {
111
+ constructor(xOrCoords, y) {
112
+ super(xOrCoords, y, origin.z);
113
+ }
114
+ static get origin() {
115
+ return Vector.create(origin.x, origin.y);
116
+ }
117
+ static clone(source) {
118
+ return Vector.create(source.x, source.y);
119
+ }
120
+ static create(x, y) {
121
+ return new Vector(x, y);
122
+ }
123
+ }
@@ -1,4 +1,4 @@
1
- import { isArray, isString } from "../../Utils/Utils.js";
1
+ import { isArray, isString } from "../../Utils/TypeUtils.js";
2
2
  import { HslAnimation } from "./HslAnimation.js";
3
3
  import { OptionsColor } from "./OptionsColor.js";
4
4
  export class AnimatableColor extends OptionsColor {
@@ -1,5 +1,5 @@
1
1
  import { BackgroundMaskCover } from "./BackgroundMaskCover.js";
2
- import { isString } from "../../../Utils/Utils.js";
2
+ import { isString } from "../../../Utils/TypeUtils.js";
3
3
  export class BackgroundMask {
4
4
  constructor() {
5
5
  this.composite = "destination-out";