@tsparticles/engine 4.0.0-alpha.1 → 4.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/638.min.js +1 -1
- package/638.min.js.LICENSE.txt +1 -1
- package/browser/Core/Canvas.js +15 -19
- package/browser/Core/Container.js +10 -15
- package/browser/Core/Engine.js +34 -14
- package/browser/Core/Interfaces/IParticleOpacityData.js +1 -0
- package/browser/Core/Interfaces/IParticleRotateData.js +1 -0
- package/browser/Core/Particle.js +95 -49
- package/browser/Utils/CanvasUtils.js +26 -83
- package/browser/Utils/ColorUtils.js +15 -2
- package/browser/Utils/MathUtils.js +3 -2
- package/browser/Utils/Utils.js +1 -1
- package/cjs/Core/Canvas.js +15 -19
- package/cjs/Core/Container.js +10 -15
- package/cjs/Core/Engine.js +34 -14
- package/cjs/Core/Interfaces/IParticleOpacityData.js +1 -0
- package/cjs/Core/Interfaces/IParticleRotateData.js +1 -0
- package/cjs/Core/Particle.js +95 -49
- package/cjs/Utils/CanvasUtils.js +26 -83
- package/cjs/Utils/ColorUtils.js +15 -2
- package/cjs/Utils/MathUtils.js +3 -2
- package/cjs/Utils/Utils.js +1 -1
- package/dist_browser_Core_Container_js.js +4 -4
- package/esm/Core/Canvas.js +15 -19
- package/esm/Core/Container.js +10 -15
- package/esm/Core/Engine.js +34 -14
- package/esm/Core/Interfaces/IParticleOpacityData.js +1 -0
- package/esm/Core/Interfaces/IParticleRotateData.js +1 -0
- package/esm/Core/Particle.js +95 -49
- package/esm/Utils/CanvasUtils.js +26 -83
- package/esm/Utils/ColorUtils.js +15 -2
- package/esm/Utils/MathUtils.js +3 -2
- package/esm/Utils/Utils.js +1 -1
- package/package.json +1 -1
- package/report.html +1 -1
- package/scripts/install.js +28 -9
- package/tsparticles.engine.js +6 -6
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Canvas.d.ts +3 -0
- package/types/Core/Container.d.ts +1 -0
- package/types/Core/Engine.d.ts +1 -1
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +1 -1
- package/types/Core/Interfaces/IParticleOpacityData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleRotateData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleTransformValues.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +1 -1
- package/types/Core/Particle.d.ts +12 -0
- package/types/Types/CustomEventListener.d.ts +1 -1
- package/types/Utils/CanvasUtils.d.ts +6 -21
- package/types/Utils/EventDispatcher.d.ts +1 -1
- package/umd/Core/Canvas.js +14 -18
- package/umd/Core/Container.js +10 -15
- package/umd/Core/Engine.js +34 -14
- package/umd/Core/Interfaces/IParticleOpacityData.js +12 -0
- package/umd/Core/Interfaces/IParticleRotateData.js +12 -0
- package/umd/Core/Particle.js +94 -48
- package/umd/Utils/CanvasUtils.js +25 -82
- package/umd/Utils/ColorUtils.js +15 -2
- package/umd/Utils/MathUtils.js +3 -2
- package/umd/Utils/Utils.js +1 -1
package/638.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 638.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[638],{1638(t,i,e){e.d(i,{Container:()=>A});var s=e(397),n=e(4117),o=e(9259),a=e(615),r=e(6192);function h(t,i,e){const s=i[e];void 0!==s&&(t[e]=(t[e]??n.zs)*s)}function c(t,i,e=!1){if(!i)return;const s=t.style,n=new Set;for(let t=0;t<s.length;t++){const i=s.item(t);i&&n.add(i)}for(let t=0;t<i.length;t++){const e=i.item(t);e&&n.add(e)}for(const t of n){const n=i.getPropertyValue(t);n?s.setProperty(t,n,e?"important":""):s.removeProperty(t)}}class l{constructor(t,i){this.container=t,this._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)h(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,r.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,r.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return[i,e]},this._initStyle=()=>{const t=this.element,i=this.container.actualOptions;if(t){this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle();for(const e in i.style){if(!e||!Object.prototype.hasOwnProperty.call(i.style,e))continue;const s=i.style[e];s&&t.style.setProperty(e,s,"important")}}},this._repairStyle=()=>{const t=this.element;if(!t)return;this._safeMutationObserver((t=>{t.disconnect()})),this._initStyle(),this.initBackground();const i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver((i=>{t instanceof Node&&i.observe(t,{attributes:!0})}))},this._resetOriginalStyle=()=>{const t=this.element,i=this._originalStyle;t&&i&&c(t,i,!0)},this._safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)},this._setFullScreenStyle=()=>{const t=this.element;t&&c(t,(0,a.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)},this._engine=i,this._standardSize={height:0,width:0};const e=t.retina.pixelRatio,s=this._standardSize;this.size={height:s.height*e,width:s.width*e},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._pointerEvents="none"}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw((t=>{(0,o.IU)(t,this.size)}))}clear(){let t=!1;for(const i of this.container.plugins.values())!t&&i.canvasClear&&(t=i.canvasClear());t||this.canvasClear()}clearDrawPlugin(t,i){this.draw((e=>{(0,o.l7)(e,t,i)}))}destroy(){if(this.stop(),this._generated){const t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}draw(t){const i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;const e=t.getRadius();if(e<=n.w2)return;const s=t.getFillColor(),a=t.getStrokeColor()??s;let[h,c]=this._getPluginParticleColors(t);if(h??=s,c??=a,!h&&!c)return;const l=this.container,d=t.options.zIndex,u=n.RV-t.zIndexFactor,p=u**d.opacityRate,f=t.bubble.opacity??t.opacity?.value??n.hv,_=t.strokeOpacity??f,g=f*p,v=_*p,m={},y={fill:(()=>{if(h)return(0,r.LC)(h,l.hdr,g)})()};y.stroke=c?(0,r.LC)(c,l.hdr,v):y.fill,this.draw((s=>{this._applyPreDrawUpdaters(s,t,e,g,y,m),(0,o.p0)({container:l,context:s,particle:t,delta:i,colorStyles:y,radius:e*u**d.sizeRate,opacity:g,transform:m})})),this._applyPostDrawUpdaters(t)}drawParticlePlugin(t,i,e){this.draw((s=>{(0,o.Wb)(s,t,i,e)}))}drawParticles(t){const{particles:i,plugins:e}=this.container;this.clear(),i.update(t);for(const i of e.values())this.drawPlugin(i,t);this.draw((()=>{i.drawParticles(t)}));for(const i of e.values())this.clearDrawPlugin(i,t)}drawPlugin(t,i){this.draw((e=>{(0,o.e_)(e,t,i)}))}init(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=(0,a.tG)((t=>{for(const i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()})),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})})),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){const{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;const s=e.style,n=(0,r.BN)(this._engine,i.color);s.backgroundColor=n?(0,r.xx)(n,t.hdr,i.opacity):"",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){this._resizePlugins=[];for(const t of this.container.plugins.values())t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t)}initUpdaters(){this._preDrawUpdaters=[],this._postDrawUpdaters=[];for(const t of this.container.particles.updaters)t.afterDraw&&this._postDrawUpdaters.push(t),(t.getColorStyles??t.getTransformValues??t.beforeDraw)&&this._preDrawUpdaters.push(t)}loadCanvas(t){this._generated&&this.element&&this.element.remove();const i=this.container;this._generated=n.eb in t.dataset?"true"===t.dataset[n.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,a.td)(this.element.style);const e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;const s=this.container.retina.pixelRatio,o=this.size;t.height=o.height=e.height*s,t.width=o.width=e.width*s;const r=(0,a.lV)("(color-gamut: p3)");this._context=this.element.getContext("2d",{alpha:!0,colorSpace:r?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1}),this._safeMutationObserver((t=>{t.disconnect()})),i.retina.init(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}))}paint(){let t=!1;for(const i of this.container.plugins.values()){if(t)break;t=i.canvasPaint?.()??!1}t||this.paintBase()}paintBase(t){this.draw((i=>{(0,o.Sn)(i,this.size,t)}))}paintImage(t,i){this.draw((e=>{(0,o.Md)(e,this.size,t,i)}))}resize(){if(!this.element)return!1;const t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,n={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&n.height===this.element.height&&n.width===this.element.width)return!1;const o={...i};i.height=e.height,i.width=e.width;const a=this.size;return this.element.width=a.width=n.width,this.element.height=a.height=n.height,this.container.started&&t.particles.setResizeFactor({width:i.width/o.width,height:i.height/o.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}stop(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=void 0,this.draw((t=>{(0,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 d=e(6249),u=e(3631);function p(t,i,e,s,n){if(s){let s={passive:!0};(0,u.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 f{constructor(t){this.container=t,this._canPush=!0,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=Date.now();const n=e.interactivity.events.onClick;(0,a.wJ)(n.mode,(t=>{this.container.handleClickMode(t)}))}"touchend"===t.type&&setTimeout((()=>{this._mouseTouchFinish()}),n.pH)},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?.default.auto&&e.loadTheme(o)},this._handleVisibilityChange=()=>{const t=this.container,i=t.actualOptions;this._mouseTouchFinish(),i.pauseOnBlur&&((0,a.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))},this._handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);const t=async()=>{const t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout((()=>{t()}),this.container.actualOptions.interactivity.events.resize.delay*n.Xu)},this._manageInteractivityListeners=(t,i)=>{const e=this._handlers,s=this.container,o=s.actualOptions,a=s.interactivity.element;if(!a)return;const r=a,h=s.canvas;h.setPointerEvents(r===h.element?"initial":"none"),(o.interactivity.events.onHover.enable||o.interactivity.events.onClick.enable)&&(p(a,n.Rb,e.mouseMove,i),p(a,n.s7,e.touchStart,i),p(a,n.DG,e.touchMove,i),o.interactivity.events.onClick.enable?(p(a,n.Bp,e.touchEndClick,i),p(a,n.vo,e.mouseUp,i),p(a,n.ms,e.mouseDown,i)):p(a,n.Bp,e.touchEnd,i),p(a,t,e.mouseLeave,i),p(a,n.G3,e.touchCancel,i))},this._manageListeners=t=>{const i=this._handlers,e=this.container,s=e.actualOptions.interactivity.detectsOn,o=e.canvas.element;let a=n.Z0;s===d.h.window?(e.interactivity.element=window,a=n.sf):s===d.h.parent&&o?e.interactivity.element=o.parentElement??o.parentNode:e.interactivity.element=o,this._manageMediaMatch(t),this._manageResize(t),this._manageInteractivityListeners(a,t),p(document,n.nK,i.visibilityChange,t,!1)},this._manageMediaMatch=t=>{const i=this._handlers;this._matchMedia&&p(this._matchMedia,"change",i.themeChange,t)},this._manageResize=t=>{const i=this._handlers,e=this.container;if(!e.actualOptions.interactivity.events.resize.enable)return;if("undefined"==typeof ResizeObserver)return void p(globalThis,n.NF,i.resize,t);const s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver((t=>{t.find((t=>t.target===s))&&this._handleWindowResize()})),this._resizeObserver.observe(s))},this._mouseDown=()=>{const{interactivity:t}=this.container,{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.values())if(t.clickPositionValid&&(n=t.clickPositionValid(o),n))break;n||this._doMouseTouchClick(t),s.clicking=!1}},this._mouseTouchFinish=()=>{const{interactivity:t}=this.container,{mouse:i}=t;delete i.position,delete i.clickPosition,delete i.downPosition,t.status=n.Z0,i.inside=!1,i.clicking=!1},this._mouseTouchMove=t=>{const i=this.container,e=i.actualOptions,s=i.interactivity,o=i.canvas.element;if(!s.element)return;let a;if(s.mouse.inside=!0,t.type.startsWith("pointer")){this._canPush=!0;const i=t;if(s.element===window){if(o){const t=o.getBoundingClientRect();a={x:i.clientX-t.left,y:i.clientY-t.top}}}else if(e.interactivity.detectsOn===d.h.parent){const t=i.target,e=i.currentTarget;if(o){const s=t.getBoundingClientRect(),r=e.getBoundingClientRect(),h=o.getBoundingClientRect();a={x:i.offsetX+n.gd*s.left-(r.left+h.left),y:i.offsetY+n.gd*s.top-(r.top+h.top)}}else a={x:i.offsetX,y:i.offsetY}}else i.target===o&&(a={x:i.offsetX,y:i.offsetY})}else if(this._canPush="touchmove"!==t.type,o){const i=t,e=i.touches[i.touches.length-n.K3],s=o.getBoundingClientRect();if(!e)return;a={x:e.clientX-s.left,y:e.clientY-s.top}}const r=i.retina.pixelRatio;a&&(a.x*=r,a.y*=r),s.mouse.position=a,s.status=n.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._matchMedia=(0,a.lV)("(prefers-color-scheme: dark)"),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 _=e(6991),g=e(3984),v=e(5536);class m{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 v.e.external:this._externalInteractors.push(t);break;case v.e.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 y=e(1690),w=e(560),b=e(4997),z=e(4342),P=e(1049),x=e(753),C=e(8627);function k(t){if(!(0,a.hn)(t.outMode,t.checkModes))return;const i=t.radius*n.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class M{constructor(t,i){this.container=i,this._calcPosition=(t,i,e,o=n.rq)=>{const a=t.plugins.values();for(const t of a){const s=t.particlePosition?.(i,this);if(s)return w.p.create(s.x,s.y,e)}const r=t.canvas.size,h=(0,s.Nx)({size:r,position:i}),c=w.p.create(h.x,h.y,e),l=this.getRadius(),d=this.options.move.outModes,u=i=>{k({outMode:i,checkModes:[P.Y.bounce],coord:c.x,maxCoord:t.canvas.size.width,setCb:t=>c.x+=t,radius:l})},p=i=>{k({outMode:i,checkModes:[P.Y.bounce],coord:c.y,maxCoord:t.canvas.size.height,setCb:t=>c.y+=t,radius:l})};u(d.left??d.default),u(d.right??d.default),p(d.top??d.default),p(d.bottom??d.default);let f=!0;for(const t of a)if(f=t.checkParticlePosition?.(this,c,o),!1===f)break;return f?c:this._calcPosition(t,void 0,e,o+n.Eo)},this._calculateVelocity=()=>{const t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===z.F.inside||i.direction===z.F.outside)return t;const e=(0,s.pu)((0,s.VG)(i.angle.value)),o=(0,s.pu)((0,s.VG)(i.angle.offset)),a={left:o-e*n.MX,right:o+e*n.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(a.left,a.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t},this._getRollColor=t=>{if(!t||!this.roll||!this.backColor&&!this.roll.alter)return t;const i=this.roll.horizontal&&this.roll.vertical?n.gd*n.l:n.l,e=this.roll.horizontal?Math.PI*n.MX:n.dv;return Math.floor((this.roll.angle+e)/(Math.PI/i))%n.gd?this.backColor?this.backColor:this.roll.alter?(0,o.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t},this._initPosition=t=>{const i=this.container,e=(0,s.VG)(this.options.zIndex.value);this.position=this._calcPosition(i,t,(0,s.qE)(e,n.X_,i.zLayers)),this.initialPosition=this.position.copy();const o=i.canvas.size;switch(this.moveCenter={...(0,a.E9)(this.options.move.center,o),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case z.F.inside:this.outType=x.x.inside;break;case z.F.outside:this.outType=x.x.outside}this.offset=w.M.origin},this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;const i=this.container,e=this.pathGenerator,s=this.shape?i.shapeDrawers.get(this.shape):void 0;s?.particleDestroy?.(this);for(const e of i.plugins.values())e.particleDestroyed?.(this,t);for(const e of i.particles.updaters)e.particleDestroyed?.(this,t);e?.reset(this),this._engine.dispatchEvent(_.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){const i=this.container,e=i.canvas;for(const s of i.plugins.values())e.drawParticlePlugin(s,this,t);e.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:n.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,r.O_)(this.color))}getMass(){return this.getRadius()**n.dm*Math.PI*n.MX}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,r.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.isRotating=!1,this.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType=x.x.normal,this.ignoresResizeRatio=!0;const c=r.retina.pixelRatio,l=r.actualOptions,d=(0,C.y)(this._engine,r,l.particles),u=d.reduceDuplicates,p=d.effect.type,f=d.shape.type;this.effect=(0,a.TA)(p,this.id,u),this.shape=(0,a.TA)(f,this.id,u);const _=d.effect,g=d.shape;if(e){if(e.effect?.type){const t=e.effect.type,i=(0,a.TA)(t,this.id,u);i&&(this.effect=i,_.load(e.effect))}if(e.shape?.type){const t=e.shape.type,i=(0,a.TA)(t,this.id,u);i&&(this.shape=i,g.load(e.shape))}}if(this.effect===n.mR){const t=[...this.container.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===n.mR){const t=[...this.container.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?function(t,i,e,s){const n=i.options[t];return(0,a.zw)({close:i.close,fill:i.fill},(0,a.TA)(n,e,s))}(this.effect,_,this.id,u):void 0,this.shapeData=this.shape?function(t,i,e,s){const n=i.options[t];return(0,a.zw)({close:i.close,fill:i.fill},(0,a.TA)(n,e,s))}(this.shape,g,this.id,u):void 0,d.load(e);const v=this.effectData;v&&d.load(v.particles);const m=this.shapeData;m&&d.load(m.particles);const y=new b.k(h,r);y.load(r.actualOptions.interactivity),y.load(d.interactivity),this.interactivity=y,this.effectFill=v?.fill??d.effect.fill,this.effectClose=v?.close??d.effect.close,this.shapeFill=m?.fill??d.shape.fill,this.shapeClose=m?.close??d.shape.close,this.options=d;const w=this.options.move.path;this.pathDelay=(0,s.VG)(w.delay.value)*n.Xu,w.generator&&(this.pathGenerator=this._engine.getPathGenerator(w.generator),this.pathGenerator&&r.addPath(w.generator,this.pathGenerator)&&this.pathGenerator.init(r)),r.retina.initParticle(this),this.size=(0,a.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=n.WH-(0,s.VG)(this.options.move.decay);const z=r.particles;let P,k;z.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/r.zLayers,this.sides=24,this.effect&&(P=r.effectDrawers.get(this.effect),P||(P=this._engine.getEffectDrawer(this.effect),P&&r.effectDrawers.set(this.effect,P))),P?.loadEffect&&P.loadEffect(this),this.shape&&(k=r.shapeDrawers.get(this.shape),k||(k=this._engine.getShapeDrawer(this.shape),k&&r.shapeDrawers.set(this.shape,k))),k?.loadShape&&k.loadShape(this);const M=k?.getSidesCount;M&&(this.sides=M(this)),this.spawning=!1;for(const t of z.updaters)t.init(this);for(const t of z.movers)t.init(this);P?.particleInit?.(r,this),k?.particleInit?.(r,this);for(const t of r.plugins.values())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 O=e(2186),T=e(6978);class S{constructor(t,i){this.rectangle=t,this.capacity=i,this._subdivide=()=>{const{x:t,y:i}=this.rectangle.position,{width:e,height:s}=this.rectangle.size,{capacity:o}=this;for(let a=0;a<n.Pg;a++){const r=a%n.gd;this._subs.push(new S(new T.M_(t+e*n.MX*r,i+s*n.MX*(Math.round(a*n.MX)-r),e*n.MX,s*n.MX),o))}this._divided=!0},this._points=[],this._divided=!1,this._subs=[]}insert(t){return!!this.rectangle.contains(t.position)&&(this._points.length<this.capacity?(this._points.push(t),!0):(this._divided||this._subdivide(),this._subs.some((i=>i.insert(t)))))}query(t,i){const e=[];if(!t.intersects(this.rectangle))return[];for(const n of this._points)!t.contains(n.position)&&(0,s.Yf)(t.position,n.position)>n.particle.getRadius()&&(!i||i(n.particle))||e.push(n.particle);if(this._divided)for(const s of this._subs)e.push(...s.query(t,i));return e}queryCircle(t,i,e){return this.query(new T.jl(t.x,t.y,i),e)}queryRectangle(t,i,e){return this.query(new T.M_(t.x,t.y,i.width,i.height),e)}}var D=e(183);const R=t=>{const{height:i,width:e}=t;return new T.M_(n.un*e,n.un*i,n.Rh*e,n.Rh*i)};class I{constructor(t,i){this._addToPool=(...t)=>{this._pool.push(...t)},this._applyDensity=(t,i,e,s)=>{const o=t.number;if(!o.density.enable)return void(void 0===e?this._limit=o.limit.value:(s?.number.limit.value??o.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??o.limit.value));const a=this._initDensityFactor(o.density),r=o.value,h=o.limit.value>n.ou?o.limit.value:r,c=Math.min(r,h)*a+i,l=Math.min(this.count,this.filter((t=>t.group===e)).length);void 0===e?this._limit=o.limit.value*a:this._groupLimits.set(e,o.limit.value*a),l<c?this.push(Math.abs(c-l),void 0,t,e):l>c&&this.removeQuantity(l-c,e)},this._initDensityFactor=t=>{const i=this._container;if(!i.canvas.element||!t.enable)return n.lA;const e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**n.dm)},this._pushParticle=(t,i,e,s)=>{try{const n=this._pool.pop()??new M(this._engine,this._container);n.init(this._nextId,t,i,e);let o=!0;if(s&&(o=s(n)),!o)return;return this._array.push(n),this._zArray.push(n),this._nextId++,this._engine.dispatchEvent(_.B.particleAdded,{container:this._container,data:{particle:n}}),n}catch(t){(0,D.t)().warning(`error adding particle: ${t}`)}},this._removeParticle=(t,i,e)=>{const s=this._array[t];if(!s)return!1;if(s.group!==i)return!1;const o=this._zArray.indexOf(s);return this._array.splice(t,n.LD),this._zArray.splice(o,n.LD),s.destroy(e),this._engine.dispatchEvent(_.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0},this._engine=t,this._container=i,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._lastZIndex=0,this._interactionManager=new m(t,i),this._pluginsInitialized=!1;const e=i.canvas.size;this.quadTree=new S(R(e),n.Kw),this.movers=[],this.updaters=[]}get count(){return this._array.length}addManualParticles(){const t=this._container;t.actualOptions.manualParticles.forEach((i=>this.addParticle(i.position?(0,a.E9)(i.position,t.canvas.size):void 0,i.options)))}addParticle(t,i,e,s){const o=this._container.actualOptions.particles.number.limit.mode,a=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,r=this.count;if(a>n.ou)switch(o){case y.d.delete:{const t=r+n.nq-a;t>n.wM&&this.removeQuantity(t);break}case y.d.wait:if(r>=a)return}return this._pushParticle(t,i,e,s)}clear(){this._array=[],this._zArray=[],this._pluginsInitialized=!1}destroy(){this._array=[],this._zArray=[],this.movers=[],this.updaters=[]}drawParticles(t){for(const i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}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.values())if(e=i.particlesInitialization?.()??e,e)break;if(this.addManualParticles(),!e){const t=i.particles,e=t.groups;for(const i in e){const s=e[i];if(s)for(let e=this.count,n=0;n<s.number.value&&e<t.number.value;e++,n++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){if(this._pluginsInitialized)return;const t=this._container;this.movers=await this._engine.getMovers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0),await this._interactionManager.init();for(const i of t.pathGenerators.values())i.init(t)}push(t,i,e,s){for(let n=0;n<t;n++)this.addParticle(i?.position,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=n.xd,e,s){if(t<n.z9||t>this.count)return;let o=0;for(let n=t;o<i&&n<this.count;n++)this._removeParticle(n,e,s)&&(n--,o++)}removeQuantity(t,i){this.removeAt(n.z9,t,i)}setDensity(){const t=this._container.actualOptions,i=t.particles.groups,e=t.manualParticles.length;for(const t in i){const s=i[t];if(!s)continue;const n=(0,C.y)(this._engine,this._container,s);this._applyDensity(n,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._lastZIndex=t,this._needsSort=this._needsSort||this._lastZIndex<t}setResizeFactor(t){this._resizeFactor=t}update(t){const i=this._container,e=new Set;this.quadTree=new S(R(i.canvas.size),n.Kw);for(const t of i.pathGenerators.values())t.update();for(const e of i.plugins.values())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.values()){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 O.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(_.B.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=t[t.length-n.K3];if(!i)return;this._lastZIndex=i.position.z,this._needsSort=!1}}}class E{constructor(t){this.container=t,this.pixelRatio=n.$x,this.reduceFactor=n.Zp}init(){const t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:n.$x,this.reduceFactor=n.Zp;const e=this.pixelRatio,o=t.canvas;if(o.element){const t=o.element;o.size.width=t.offsetWidth*e,o.size.height=t.offsetHeight*e}const a=i.particles,r=a.move;this.maxSpeed=(0,s.VG)(r.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(a.size.animation.speed)*e}initParticle(t){const i=t.options,e=this.pixelRatio,n=i.move,o=n.distance,a=t.retina;a.moveDrift=(0,s.VG)(n.drift)*e,a.moveSpeed=(0,s.VG)(n.speed)*e,a.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;const r=a.maxDistance;r.horizontal=void 0!==o.horizontal?o.horizontal*e:void 0,r.vertical=void 0!==o.vertical?o.vertical*e:void 0,a.maxSpeed=(0,s.VG)(n.gravity.maxSpeed)*e}}function F(t){return!t.destroyed}function L(t,i,...e){const s=new g.J(t,i);return(0,C.Z)(s,...e),s}class A{constructor(t,i,e){this._intersectionManager=t=>{if(F(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+n.Xu/this.fpsLimit)return void this.draw(!1);this._lastFrameTime??=t;const i=function(t,i=n.z$,e=!1){return{value:t,factor:e?n.z$/i:n.z$*t/n.Xu}}(t-this._lastFrameTime,this.fpsLimit,this._smooth);if(this.addLifeTime(i.value),this._lastFrameTime=t,i.value>n.Xu)return void this.draw(!1);if(this.canvas.drawParticles(i),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,D.t)().error("error in animation loop",t)}},this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._clickHandlers=new Map,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new E(this),this.canvas=new l(this,this._engine),this.particles=new I(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=L(this._engine,this),this.actualOptions=L(this._engine,this),this._eventListeners=new f(this),this._intersectionObserver=(0,a.BR)((t=>{this._intersectionManager(t)})),this._engine.dispatchEvent(_.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&F(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addClickHandler(t){if(!F(this))return;const i=this.interactivity.element;if(!i)return;const e=(i,e,s)=>{if(!F(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,o=!1;this._clickHandlers.set("click",(t=>{if(!F(this))return;const i=t,s={x:i.offsetX||i.clientX,y:i.offsetY||i.clientY};e(t,s,n.FS)})),this._clickHandlers.set("touchstart",(()=>{F(this)&&(s=!0,o=!1)})),this._clickHandlers.set("touchmove",(()=>{F(this)&&(o=!0)})),this._clickHandlers.set("touchend",(t=>{if(F(this)){if(s&&!o){const i=t,s=i.touches[i.touches.length-n.KZ];if(!s)return;const o=this.canvas.element,a=o?o.getBoundingClientRect():void 0,r={x:s.clientX-(a?a.left:n.TL),y:s.clientY-(a?a.top:n.TL)};e(t,r,Math.max(s.radiusX,s.radiusY))}s=!1,o=!1}})),this._clickHandlers.set("touchcancel",(()=>{F(this)&&(s=!1,o=!1)}));for(const[t,e]of this._clickHandlers)i.addEventListener(t,e)}addLifeTime(t){this._lifeTime+=t}addPath(t,i,e=!1){return!(!F(this)||!e&&this.pathGenerators.has(t))&&(this.pathGenerators.set(t,i),!0)}alive(){return!this._duration||this._lifeTime<=this._duration}clearClickHandlers(){if(F(this)){for(const[t,i]of this._clickHandlers)this.interactivity.element?.removeEventListener(t,i);this._clickHandlers.clear()}}destroy(t=!0){if(F(this)){this.stop(),this.clearClickHandlers(),this.particles.destroy(),this.canvas.destroy();for(const t of this.effectDrawers.values())t.destroy?.(this);for(const t of this.shapeDrawers.values())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);if(this._engine.clearPlugins(this),this.destroyed=!0,t){const t=this._engine.items,i=t.findIndex((t=>t===this));i>=n.vF&&t.splice(i,n.JC)}this._engine.dispatchEvent(_.B.containerDestroyed,{container:this})}}draw(t){if(!F(this))return;let i=t;const e=t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)};this._drawAnimationFrame=(0,s.i0)((t=>{e(t)}))}async export(t,i={}){for(const e of this.plugins.values()){if(!e.export)continue;const s=await e.export(t,i);if(s.supported)return s.blob}(0,D.t)().error(`Export plugin with type ${t} not found`)}handleClickMode(t){if(F(this)){this.particles.handleClickMode(t);for(const i of this.plugins.values())i.handleClickMode?.(t)}}async init(){if(!F(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=L(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=L(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(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();const{delay:o,duration:a,fpsLimit:r,hdr:h,smooth:c,zLayers:l}=this.actualOptions;this.hdr=h,this.zLayers=l,this._duration=(0,s.VG)(a)*n.Xu,this._delay=(0,s.VG)(o)*n.Xu,this._lifeTime=0,this.fpsLimit=r>n.DN?r:n.i8,this._smooth=c;for(const t of this.effectDrawers.values())await(t.init?.(this));for(const t of this.shapeDrawers.values())await(t.init?.(this));for(const t of this.plugins.values())await(t.init?.());this._engine.dispatchEvent(_.B.containerInit,{container:this}),await this.particles.init(),this.particles.setDensity();for(const t of this.plugins.values())t.particlesSetup?.();this._engine.dispatchEvent(_.B.particlesSetup,{container:this})}async loadTheme(t){F(this)&&(this._currentTheme=t,await this.refresh())}pause(){if(F(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(const t of this.plugins.values())t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(_.B.containerPaused,{container:this})}}play(t){if(!F(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.values())t.play&&t.play();this._engine.dispatchEvent(_.B.containerPlay,{container:this}),this.draw(i??!1)}else this._firstStart=!1}async refresh(){if(F(this))return this.stop(),this.start()}async reset(t){if(F(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=L(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=L(this._engine,this,this._options),this.refresh()}async start(){F(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.values())await(t.start?.());this._engine.dispatchEvent(_.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout((()=>{i()}),this._delay)})))}stop(){if(F(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.values())t.stop?.();for(const t of this.plugins.keys())this.plugins.delete(t);this._sourceOptions=this._options,this._engine.dispatchEvent(_.B.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)}}}}]);
|
|
2
|
+
(this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[638],{1638(t,i,e){e.d(i,{Container:()=>A});var s=e(397),n=e(4117),a=e(9259),o=e(615),r=e(6192);function h(t,i,e){const s=i[e];void 0!==s&&(t[e]=(t[e]??n.zs)*s)}function c(t,i,e=!1){if(!i)return;const s=t.style,n=new Set;for(let t=0;t<s.length;t++){const i=s.item(t);i&&n.add(i)}for(let t=0;t<i.length;t++){const e=i.item(t);e&&n.add(e)}for(const t of n){const n=i.getPropertyValue(t);n?s.setProperty(t,n,e?"important":""):s.removeProperty(t)}}class l{constructor(t,i){this.container=t,this._reusableColorStyles={},this._reusablePluginColors=[void 0,void 0],this._reusableTransform={},this._applyPostDrawUpdaters=t=>{for(const i of this._postDrawUpdaters)i.afterDraw?.(t)},this._applyPreDrawUpdaters=(t,i,e,s,n,a)=>{for(const o of this._preDrawUpdaters){if(o.getColorStyles){const{fill:a,stroke:r}=o.getColorStyles(i,t,e,s);a&&(n.fill=a),r&&(n.stroke=r)}if(o.getTransformValues){const t=o.getTransformValues(i);for(const i in t)h(a,t,i)}o.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,r.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,r.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors},this._initStyle=()=>{const t=this.element,i=this.container.actualOptions;if(t){this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle();for(const e in i.style){if(!e||!Object.hasOwn(i.style,e))continue;const s=i.style[e];s&&t.style.setProperty(e,s,"important")}}},this._repairStyle=()=>{const t=this.element;if(!t)return;this._safeMutationObserver((t=>{t.disconnect()})),this._initStyle(),this.initBackground();const i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver((i=>{t instanceof Node&&i.observe(t,{attributes:!0})}))},this._resetOriginalStyle=()=>{const t=this.element,i=this._originalStyle;t&&i&&c(t,i,!0)},this._safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)},this._setFullScreenStyle=()=>{const t=this.element;t&&c(t,(0,o.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)},this._engine=i,this._standardSize={height:0,width:0};const e=t.retina.pixelRatio,s=this._standardSize;this.size={height:s.height*e,width:s.width*e},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._pointerEvents="none"}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw((t=>{(0,a.IU)(t,this.size)}))}clear(){let t=!1;for(const i of this.container.plugins.values())!t&&i.canvasClear&&(t=i.canvasClear());t||this.canvasClear()}clearDrawPlugin(t,i){this.draw((e=>{(0,a.l7)(e,t,i)}))}destroy(){if(this.stop(),this._generated){const t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[]}draw(t){const i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;const e=t.getRadius();if(e<=n.w2)return;const s=t.getFillColor(),o=t.getStrokeColor()??s;let[h,c]=this._getPluginParticleColors(t);if(h??=s,c??=o,!h&&!c)return;const l=this.container,d=t.options.zIndex,u=n.RV-t.zIndexFactor,{opacity:p,strokeOpacity:f}=t.getOpacity(),_=this._reusableTransform,g=this._reusableColorStyles,v=h?(0,r.LC)(h,l.hdr,p):void 0,m=c?(0,r.LC)(c,l.hdr,f):v;_.a=_.b=_.c=_.d=void 0,g.fill=v,g.stroke=m,this.draw((s=>{this._applyPreDrawUpdaters(s,t,e,p,g,_),(0,a.p0)({container:l,context:s,particle:t,delta:i,colorStyles:g,radius:e*u**d.sizeRate,opacity:p,transform:_})})),this._applyPostDrawUpdaters(t)}drawParticlePlugin(t,i,e){this.draw((s=>{(0,a.Wb)(s,t,i,e)}))}drawParticles(t){const{particles:i,plugins:e}=this.container;this.clear(),i.update(t);for(const i of e.values())this.drawPlugin(i,t);this.draw((()=>{i.drawParticles(t)}));for(const i of e.values())this.clearDrawPlugin(i,t)}drawPlugin(t,i){this.draw((e=>{(0,a.e_)(e,t,i)}))}init(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=(0,o.tG)((t=>{for(const i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()})),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})})),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){const{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;const s=e.style,n=(0,r.BN)(this._engine,i.color);s.backgroundColor=n?(0,r.xx)(n,t.hdr,i.opacity):"",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){this._resizePlugins=[];for(const t of this.container.plugins.values())t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t)}initUpdaters(){this._preDrawUpdaters=[],this._postDrawUpdaters=[];for(const t of this.container.particles.updaters)t.afterDraw&&this._postDrawUpdaters.push(t),(t.getColorStyles??t.getTransformValues??t.beforeDraw)&&this._preDrawUpdaters.push(t)}loadCanvas(t){this._generated&&this.element&&this.element.remove();const i=this.container;this._generated=n.eb in t.dataset?"true"===t.dataset[n.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,o.td)(this.element.style);const e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;const s=this.container.retina.pixelRatio,a=this.size;t.height=a.height=e.height*s,t.width=a.width=e.width*s;const r=(0,o.lV)("(color-gamut: p3)");this._context=this.element.getContext("2d",{alpha:!0,colorSpace:r?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1}),this._safeMutationObserver((t=>{t.disconnect()})),i.retina.init(),this.initBackground(),this._safeMutationObserver((t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}))}paint(){let t=!1;for(const i of this.container.plugins.values()){if(t)break;t=i.canvasPaint?.()??!1}t||this.paintBase()}paintBase(t){this.draw((i=>{(0,a.Sn)(i,this.size,t)}))}paintImage(t,i){this.draw((e=>{(0,a.Md)(e,this.size,t,i)}))}resize(){if(!this.element)return!1;const t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,n={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&n.height===this.element.height&&n.width===this.element.width)return!1;const a={...i};i.height=e.height,i.width=e.width;const o=this.size;return this.element.width=o.width=n.width,this.element.height=o.height=n.height,this.container.started&&t.particles.setResizeFactor({width:i.width/a.width,height:i.height/a.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}stop(){this._safeMutationObserver((t=>{t.disconnect()})),this._mutationObserver=void 0,this.draw((t=>{(0,a.IU)(t,this.size)}))}async windowResize(){if(!this.element||!this.resize())return;const t=this.container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}}var d=e(6249),u=e(3631);function p(t,i,e,s,n){if(s){let s={passive:!0};(0,u.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 f{constructor(t){this.container=t,this._canPush=!0,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=Date.now();const n=e.interactivity.events.onClick;(0,o.wJ)(n.mode,(t=>{this.container.handleClickMode(t)}))}"touchend"===t.type&&setTimeout((()=>{this._mouseTouchFinish()}),n.pH)},this._handleThemeChange=t=>{const i=t,e=this.container,s=e.options,n=s.defaultThemes,a=i.matches?n.dark:n.light,o=s.themes.find((t=>t.name===a));o?.default.auto&&e.loadTheme(a)},this._handleVisibilityChange=()=>{const t=this.container,i=t.actualOptions;this._mouseTouchFinish(),i.pauseOnBlur&&((0,o.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))},this._handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);const t=async()=>{const t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout((()=>{t()}),this.container.actualOptions.interactivity.events.resize.delay*n.Xu)},this._manageInteractivityListeners=(t,i)=>{const e=this._handlers,s=this.container,a=s.actualOptions,o=s.interactivity.element;if(!o)return;const r=o,h=s.canvas;h.setPointerEvents(r===h.element?"initial":"none"),(a.interactivity.events.onHover.enable||a.interactivity.events.onClick.enable)&&(p(o,n.Rb,e.mouseMove,i),p(o,n.s7,e.touchStart,i),p(o,n.DG,e.touchMove,i),a.interactivity.events.onClick.enable?(p(o,n.Bp,e.touchEndClick,i),p(o,n.vo,e.mouseUp,i),p(o,n.ms,e.mouseDown,i)):p(o,n.Bp,e.touchEnd,i),p(o,t,e.mouseLeave,i),p(o,n.G3,e.touchCancel,i))},this._manageListeners=t=>{const i=this._handlers,e=this.container,s=e.actualOptions.interactivity.detectsOn,a=e.canvas.element;let o=n.Z0;s===d.h.window?(e.interactivity.element=window,o=n.sf):s===d.h.parent&&a?e.interactivity.element=a.parentElement??a.parentNode:e.interactivity.element=a,this._manageMediaMatch(t),this._manageResize(t),this._manageInteractivityListeners(o,t),p(document,n.nK,i.visibilityChange,t,!1)},this._manageMediaMatch=t=>{const i=this._handlers;this._matchMedia&&p(this._matchMedia,"change",i.themeChange,t)},this._manageResize=t=>{const i=this._handlers,e=this.container;if(!e.actualOptions.interactivity.events.resize.enable)return;if("undefined"==typeof ResizeObserver)return void p(globalThis,n.NF,i.resize,t);const s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver((t=>{t.find((t=>t.target===s))&&this._handleWindowResize()})),this._resizeObserver.observe(s))},this._mouseDown=()=>{const{interactivity:t}=this.container,{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 a=s.position;if(a&&e.interactivity.events.onClick.enable){for(const t of i.plugins.values())if(t.clickPositionValid&&(n=t.clickPositionValid(a),n))break;n||this._doMouseTouchClick(t),s.clicking=!1}},this._mouseTouchFinish=()=>{const{interactivity:t}=this.container,{mouse:i}=t;delete i.position,delete i.clickPosition,delete i.downPosition,t.status=n.Z0,i.inside=!1,i.clicking=!1},this._mouseTouchMove=t=>{const i=this.container,e=i.actualOptions,s=i.interactivity,a=i.canvas.element;if(!s.element)return;let o;if(s.mouse.inside=!0,t.type.startsWith("pointer")){this._canPush=!0;const i=t;if(s.element===window){if(a){const t=a.getBoundingClientRect();o={x:i.clientX-t.left,y:i.clientY-t.top}}}else if(e.interactivity.detectsOn===d.h.parent){const t=i.target,e=i.currentTarget;if(a){const s=t.getBoundingClientRect(),r=e.getBoundingClientRect(),h=a.getBoundingClientRect();o={x:i.offsetX+n.gd*s.left-(r.left+h.left),y:i.offsetY+n.gd*s.top-(r.top+h.top)}}else o={x:i.offsetX,y:i.offsetY}}else i.target===a&&(o={x:i.offsetX,y:i.offsetY})}else if(this._canPush="touchmove"!==t.type,a){const i=t,e=i.touches[i.touches.length-n.K3],s=a.getBoundingClientRect();if(!e)return;o={x:e.clientX-s.left,y:e.clientY-s.top}}const r=i.retina.pixelRatio;o&&(o.x*=r,o.y*=r),s.mouse.position=o,s.status=n.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._matchMedia=(0,o.lV)("(prefers-color-scheme: dark)"),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 _=e(6991),g=e(3984),v=e(5536);class m{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 v.e.external:this._externalInteractors.push(t);break;case v.e.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 y=e(1690),w=e(560),b=e(4997),z=e(4342),P=e(1049),x=e(753),C=e(8627);function k(t){if(!(0,o.hn)(t.outMode,t.checkModes))return;const i=t.radius*n.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class O{constructor(t,i){this.container=i,this._cachedOpacityData={opacity:n.hv,strokeOpacity:n.hv},this._cachedPosition=w.p.origin,this._cachedRotateData={sin:0,cos:0},this._cachedTransform={a:1,b:0,c:0,d:1},this._calcPosition=(t,i)=>{let e=n.rq,a=t?w.p.create(t.x,t.y,i):void 0;const o=this.container,r=Array.from(o.plugins.values()),h=this.options.move.outModes,c=this.getRadius(),l=o.canvas.size,d=new AbortController,{signal:u}=d;for(;!u.aborted;){for(const t of r){const e=t.particlePosition?.(a,this);if(e)return w.p.create(e.x,e.y,i)}const t=(0,s.Nx)({size:l,position:a}),o=w.p.create(t.x,t.y,i);this._fixHorizontal(o,c,h.left??h.default),this._fixHorizontal(o,c,h.right??h.default),this._fixVertical(o,c,h.top??h.default),this._fixVertical(o,c,h.bottom??h.default);let d=!0;for(const t of r)if(d=t.checkParticlePosition?.(this,o,e)??!0,!d)break;if(d)return o;e+=n.Eo,a=void 0}return a},this._calculateVelocity=()=>{const t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===z.F.inside||i.direction===z.F.outside)return t;const e=(0,s.pu)((0,s.VG)(i.angle.value)),a=(0,s.pu)((0,s.VG)(i.angle.offset)),o={left:a-e*n.MX,right:a+e*n.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(o.left,o.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t},this._fixHorizontal=(t,i,e)=>{k({outMode:e,checkModes:[P.Y.bounce],coord:t.x,maxCoord:this.container.canvas.size.width,setCb:i=>t.x+=i,radius:i})},this._fixVertical=(t,i,e)=>{k({outMode:e,checkModes:[P.Y.bounce],coord:t.y,maxCoord:this.container.canvas.size.height,setCb:i=>t.y+=i,radius:i})},this._getRollColor=t=>{if(!t||!this.roll||!this.backColor&&!this.roll.alter)return t;const i=this.roll.horizontal&&this.roll.vertical?n.gd*n.l:n.l,e=this.roll.horizontal?Math.PI*n.MX:n.dv;return Math.floor((this.roll.angle+e)/(Math.PI/i))%n.gd?this.backColor?this.backColor:this.roll.alter?(0,a.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t},this._initPosition=t=>{const i=this.container,e=(0,s.VG)(this.options.zIndex.value),a=this._calcPosition(t,(0,s.qE)(e,n.X_,i.zLayers));if(!a)throw new Error("a valid position cannot be found for particle");this.position=a,this.initialPosition=this.position.copy();const r=i.canvas.size;switch(this.moveCenter={...(0,o.E9)(this.options.move.center,r),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case z.F.inside:this.outType=x.x.inside;break;case z.F.outside:this.outType=x.x.outside}this.offset=w.M.origin},this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;const i=this.container,e=this.pathGenerator,s=this.shape?i.shapeDrawers.get(this.shape):void 0;s?.particleDestroy?.(this);for(const e of i.plugins.values())e.particleDestroyed?.(this,t);for(const e of i.particles.updaters)e.particleDestroyed?.(this,t);e?.reset(this),this._engine.dispatchEvent(_.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){const i=this.container,e=i.canvas;for(const s of i.plugins.values())e.drawParticlePlugin(s,this,t);e.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:n.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,r.O_)(this.color))}getMass(){return this.getRadius()**n.dm*Math.PI*n.MX}getOpacity(){const t=this.options.zIndex,i=(n.RV-this.zIndexFactor)**t.opacityRate,e=this.bubble.opacity??(0,s.VG)(this.opacity?.value??n.hv),a=this.strokeOpacity??e;return this._cachedOpacityData.opacity=e*i,this._cachedOpacityData.strokeOpacity=a*i,this._cachedOpacityData}getPosition(){return this._cachedPosition.x=this.position.x+this.offset.x,this._cachedPosition.y=this.position.y+this.offset.y,this._cachedPosition.z=this.position.z,this._cachedPosition}getRadius(){return this.bubble.radius??this.size.value}getRotateData(){const t=this.getAngle();return this._cachedRotateData.sin=Math.sin(t),this._cachedRotateData.cos=Math.cos(t),this._cachedRotateData}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,r.O_)(this.strokeColor))}getTransformData(t){const i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??n.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??n.D_):t.b??n.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??n.D_):t.c??n.Ug.c,this._cachedTransform.d=i.cos*(t.d??n.Ug.d),this._cachedTransform}init(t,i,e,a){const r=this.container,h=this._engine;this.id=t,this.group=a,this.effectClose=!0,this.effectFill=!0,this.shapeClose=!0,this.shapeFill=!0,this.pathRotation=!1,this.lastPathTime=0,this.destroyed=!1,this.unbreakable=!1,this.isRotating=!1,this.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType=x.x.normal,this.ignoresResizeRatio=!0;const c=r.retina.pixelRatio,l=r.actualOptions,d=(0,C.y)(this._engine,r,l.particles),u=d.reduceDuplicates,p=d.effect.type,f=d.shape.type;this.effect=(0,o.TA)(p,this.id,u),this.shape=(0,o.TA)(f,this.id,u);const _=d.effect,g=d.shape;if(e){if(e.effect?.type){const t=e.effect.type,i=(0,o.TA)(t,this.id,u);i&&(this.effect=i,_.load(e.effect))}if(e.shape?.type){const t=e.shape.type,i=(0,o.TA)(t,this.id,u);i&&(this.shape=i,g.load(e.shape))}}if(this.effect===n.mR){const t=[...this.container.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===n.mR){const t=[...this.container.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?function(t,i,e,s){const n=i.options[t];return(0,o.zw)({close:i.close,fill:i.fill},(0,o.TA)(n,e,s))}(this.effect,_,this.id,u):void 0,this.shapeData=this.shape?function(t,i,e,s){const n=i.options[t];return(0,o.zw)({close:i.close,fill:i.fill},(0,o.TA)(n,e,s))}(this.shape,g,this.id,u):void 0,d.load(e);const v=this.effectData;v&&d.load(v.particles);const m=this.shapeData;m&&d.load(m.particles);const y=new b.k(h,r);y.load(r.actualOptions.interactivity),y.load(d.interactivity),this.interactivity=y,this.effectFill=v?.fill??d.effect.fill,this.effectClose=v?.close??d.effect.close,this.shapeFill=m?.fill??d.shape.fill,this.shapeClose=m?.close??d.shape.close,this.options=d;const w=this.options.move.path;this.pathDelay=(0,s.VG)(w.delay.value)*n.Xu,w.generator&&(this.pathGenerator=this._engine.getPathGenerator(w.generator),this.pathGenerator&&r.addPath(w.generator,this.pathGenerator)&&this.pathGenerator.init(r)),r.retina.initParticle(this),this.size=(0,o.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=n.WH-(0,s.VG)(this.options.move.decay);const z=r.particles;let P,k;z.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/r.zLayers,this.sides=24,this.effect&&(P=r.effectDrawers.get(this.effect),P||(P=this._engine.getEffectDrawer(this.effect),P&&r.effectDrawers.set(this.effect,P))),P?.loadEffect&&P.loadEffect(this),this.shape&&(k=r.shapeDrawers.get(this.shape),k||(k=this._engine.getShapeDrawer(this.shape),k&&r.shapeDrawers.set(this.shape,k))),k?.loadShape&&k.loadShape(this);const O=k?.getSidesCount;O&&(this.sides=O(this)),this.spawning=!1;for(const t of z.updaters)t.init(this);for(const t of z.movers)t.init(this);P?.particleInit?.(r,this),k?.particleInit?.(r,this);for(const t of r.plugins.values())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 M=e(2186),T=e(6978);class D{constructor(t,i){this.rectangle=t,this.capacity=i,this._subdivide=()=>{const{x:t,y:i}=this.rectangle.position,{width:e,height:s}=this.rectangle.size,{capacity:a}=this;for(let o=0;o<n.Pg;o++){const r=o%n.gd;this._subs.push(new D(new T.M_(t+e*n.MX*r,i+s*n.MX*(Math.round(o*n.MX)-r),e*n.MX,s*n.MX),a))}this._divided=!0},this._points=[],this._divided=!1,this._subs=[]}insert(t){return!!this.rectangle.contains(t.position)&&(this._points.length<this.capacity?(this._points.push(t),!0):(this._divided||this._subdivide(),this._subs.some((i=>i.insert(t)))))}query(t,i){const e=[];if(!t.intersects(this.rectangle))return[];for(const n of this._points)!t.contains(n.position)&&(0,s.Yf)(t.position,n.position)>n.particle.getRadius()&&(!i||i(n.particle))||e.push(n.particle);if(this._divided)for(const s of this._subs)e.push(...s.query(t,i));return e}queryCircle(t,i,e){return this.query(new T.jl(t.x,t.y,i),e)}queryRectangle(t,i,e){return this.query(new T.M_(t.x,t.y,i.width,i.height),e)}}var R=e(183);const S=t=>{const{height:i,width:e}=t;return new T.M_(n.un*e,n.un*i,n.Rh*e,n.Rh*i)};class I{constructor(t,i){this._addToPool=(...t)=>{this._pool.push(...t)},this._applyDensity=(t,i,e,s)=>{const a=t.number;if(!a.density.enable)return void(void 0===e?this._limit=a.limit.value:(s?.number.limit.value??a.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??a.limit.value));const o=this._initDensityFactor(a.density),r=a.value,h=a.limit.value>n.ou?a.limit.value:r,c=Math.min(r,h)*o+i,l=Math.min(this.count,this.filter((t=>t.group===e)).length);void 0===e?this._limit=a.limit.value*o:this._groupLimits.set(e,a.limit.value*o),l<c?this.push(Math.abs(c-l),void 0,t,e):l>c&&this.removeQuantity(l-c,e)},this._initDensityFactor=t=>{const i=this._container;if(!i.canvas.element||!t.enable)return n.lA;const e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**n.dm)},this._pushParticle=(t,i,e,s)=>{try{const n=this._pool.pop()??new O(this._engine,this._container);n.init(this._nextId,t,i,e);let a=!0;if(s&&(a=s(n)),!a)return;return this._array.push(n),this._zArray.push(n),this._nextId++,this._engine.dispatchEvent(_.B.particleAdded,{container:this._container,data:{particle:n}}),n}catch(t){(0,R.t)().warning(`error adding particle: ${t}`)}},this._removeParticle=(t,i,e)=>{const s=this._array[t];if(!s)return!1;if(s.group!==i)return!1;const a=this._zArray.indexOf(s);return this._array.splice(t,n.LD),this._zArray.splice(a,n.LD),s.destroy(e),this._engine.dispatchEvent(_.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0},this._engine=t,this._container=i,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._lastZIndex=0,this._interactionManager=new m(t,i),this._pluginsInitialized=!1;const e=i.canvas.size;this.quadTree=new D(S(e),n.Kw),this.movers=[],this.updaters=[]}get count(){return this._array.length}addManualParticles(){const t=this._container;t.actualOptions.manualParticles.forEach((i=>this.addParticle(i.position?(0,o.E9)(i.position,t.canvas.size):void 0,i.options)))}addParticle(t,i,e,s){const a=this._container.actualOptions.particles.number.limit.mode,o=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,r=this.count;if(o>n.ou)switch(a){case y.d.delete:{const t=r+n.nq-o;t>n.wM&&this.removeQuantity(t);break}case y.d.wait:if(r>=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=[]}drawParticles(t){for(const i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}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.values())if(e=i.particlesInitialization?.()??e,e)break;if(this.addManualParticles(),!e){const t=i.particles,e=t.groups;for(const i in e){const s=e[i];if(s)for(let e=this.count,n=0;n<s.number.value&&e<t.number.value;e++,n++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){if(this._pluginsInitialized)return;const t=this._container;this.movers=await this._engine.getMovers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0),await this._interactionManager.init();for(const i of t.pathGenerators.values())i.init(t)}push(t,i,e,s){for(let n=0;n<t;n++)this.addParticle(i?.position,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=n.xd,e,s){if(t<n.z9||t>this.count)return;let a=0;for(let n=t;a<i&&n<this.count;n++)this._removeParticle(n,e,s)&&(n--,a++)}removeQuantity(t,i){this.removeAt(n.z9,t,i)}setDensity(){const t=this._container.actualOptions,i=t.particles.groups,e=t.manualParticles.length;for(const t in i){const s=i[t];if(!s)continue;const n=(0,C.y)(this._engine,this._container,s);this._applyDensity(n,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._lastZIndex=t,this._needsSort=this._needsSort||this._lastZIndex<t}setResizeFactor(t){this._resizeFactor=t}update(t){const i=this._container,e=new Set;this.quadTree=new D(S(i.canvas.size),n.Kw);for(const t of i.pathGenerators.values())t.update();for(const e of i.plugins.values())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.values()){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 M.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(_.B.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=t[t.length-n.K3];if(!i)return;this._lastZIndex=i.position.z,this._needsSort=!1}}}class E{constructor(t){this.container=t,this.pixelRatio=n.$x,this.reduceFactor=n.Zp}init(){const t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:n.$x,this.reduceFactor=n.Zp;const e=this.pixelRatio,a=t.canvas;if(a.element){const t=a.element;a.size.width=t.offsetWidth*e,a.size.height=t.offsetHeight*e}const o=i.particles,r=o.move;this.maxSpeed=(0,s.VG)(r.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(o.size.animation.speed)*e}initParticle(t){const i=t.options,e=this.pixelRatio,n=i.move,a=n.distance,o=t.retina;o.moveDrift=(0,s.VG)(n.drift)*e,o.moveSpeed=(0,s.VG)(n.speed)*e,o.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;const r=o.maxDistance;r.horizontal=void 0!==a.horizontal?a.horizontal*e:void 0,r.vertical=void 0!==a.vertical?a.vertical*e:void 0,o.maxSpeed=(0,s.VG)(n.gravity.maxSpeed)*e}}function F(t){return!t.destroyed}function L(t,i,...e){const s=new g.J(t,i);return(0,C.Z)(s,...e),s}class A{constructor(t,i,e){this._delta={value:0,factor:0},this._intersectionManager=t=>{if(F(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+n.Xu/this.fpsLimit)return void this.draw(!1);if(this._lastFrameTime??=t,function(t,i,e=n.z$,s=!1){t.value=i,t.factor=s?n.z$/e:n.z$*i/n.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>n.Xu)return void this.draw(!1);if(this.canvas.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,R.t)().error("error in animation loop",t)}},this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._clickHandlers=new Map,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new E(this),this.canvas=new l(this,this._engine),this.particles=new I(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=L(this._engine,this),this.actualOptions=L(this._engine,this),this._eventListeners=new f(this),this._intersectionObserver=(0,o.BR)((t=>{this._intersectionManager(t)})),this._engine.dispatchEvent(_.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&F(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addClickHandler(t){if(!F(this))return;const i=this.interactivity.element;if(!i)return;const e=(i,e,s)=>{if(!F(this))return;const n=this.retina.pixelRatio,a={x:e.x*n,y:e.y*n},o=this.particles.quadTree.queryCircle(a,s*n);t(i,o)};let s=!1,a=!1;this._clickHandlers.set("click",(t=>{if(!F(this))return;const i=t,s={x:i.offsetX||i.clientX,y:i.offsetY||i.clientY};e(t,s,n.FS)})),this._clickHandlers.set("touchstart",(()=>{F(this)&&(s=!0,a=!1)})),this._clickHandlers.set("touchmove",(()=>{F(this)&&(a=!0)})),this._clickHandlers.set("touchend",(t=>{if(F(this)){if(s&&!a){const i=t,s=i.touches[i.touches.length-n.KZ];if(!s)return;const a=this.canvas.element,o=a?a.getBoundingClientRect():void 0,r={x:s.clientX-(o?o.left:n.TL),y:s.clientY-(o?o.top:n.TL)};e(t,r,Math.max(s.radiusX,s.radiusY))}s=!1,a=!1}})),this._clickHandlers.set("touchcancel",(()=>{F(this)&&(s=!1,a=!1)}));for(const[t,e]of this._clickHandlers)i.addEventListener(t,e)}addLifeTime(t){this._lifeTime+=t}addPath(t,i,e=!1){return!(!F(this)||!e&&this.pathGenerators.has(t))&&(this.pathGenerators.set(t,i),!0)}alive(){return!this._duration||this._lifeTime<=this._duration}clearClickHandlers(){if(F(this)){for(const[t,i]of this._clickHandlers)this.interactivity.element?.removeEventListener(t,i);this._clickHandlers.clear()}}destroy(t=!0){if(F(this)){this.stop(),this.clearClickHandlers(),this.particles.destroy(),this.canvas.destroy();for(const t of this.effectDrawers.values())t.destroy?.(this);this.effectDrawers.clear();for(const t of this.shapeDrawers.values())t.destroy?.(this);if(this.shapeDrawers.clear(),this._engine.clearPlugins(this),this.destroyed=!0,t){const t=this._engine.items,i=t.findIndex((t=>t===this));i>=n.vF&&t.splice(i,n.JC)}this._engine.dispatchEvent(_.B.containerDestroyed,{container:this})}}draw(t){if(!F(this))return;let i=t;const e=t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)};this._drawAnimationFrame=(0,s.i0)((t=>{e(t)}))}async export(t,i={}){for(const e of this.plugins.values()){if(!e.export)continue;const s=await e.export(t,i);if(s.supported)return s.blob}(0,R.t)().error(`Export plugin with type ${t} not found`)}handleClickMode(t){if(F(this)){this.particles.handleClickMode(t);for(const i of this.plugins.values())i.handleClickMode?.(t)}}async init(){if(!F(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=L(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=L(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(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();const{delay:a,duration:o,fpsLimit:r,hdr:h,smooth:c,zLayers:l}=this.actualOptions;this.hdr=h,this.zLayers=l,this._duration=(0,s.VG)(o)*n.Xu,this._delay=(0,s.VG)(a)*n.Xu,this._lifeTime=0,this.fpsLimit=r>n.DN?r:n.i8,this._smooth=c;for(const t of this.effectDrawers.values())await(t.init?.(this));for(const t of this.shapeDrawers.values())await(t.init?.(this));for(const t of this.plugins.values())await(t.init?.());this._engine.dispatchEvent(_.B.containerInit,{container:this}),await this.particles.init(),this.particles.setDensity();for(const t of this.plugins.values())t.particlesSetup?.();this._engine.dispatchEvent(_.B.particlesSetup,{container:this})}async loadTheme(t){F(this)&&(this._currentTheme=t,await this.refresh())}pause(){if(F(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(const t of this.plugins.values())t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(_.B.containerPaused,{container:this})}}play(t){if(!F(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.values())t.play&&t.play();this._engine.dispatchEvent(_.B.containerPlay,{container:this}),this.draw(i??!1)}else this._firstStart=!1}async refresh(){if(F(this))return this.stop(),this.start()}async reset(t){if(F(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=L(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=L(this._engine,this,this._options),this.refresh()}async start(){F(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.values())await(t.start?.());this._engine.dispatchEvent(_.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout((()=>{i()}),this._delay)})))}stop(){if(F(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.values())t.stop?.();for(const t of this.plugins.keys())this.plugins.delete(t);this._sourceOptions=this._options,this._engine.dispatchEvent(_.B.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)}}}}]);
|
package/638.min.js.LICENSE.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Engine v4.0.0-alpha.
|
|
1
|
+
/*! tsParticles Engine v4.0.0-alpha.3 by Matteo Bruni */
|
package/browser/Core/Canvas.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { clear, clearDrawPlugin, drawParticle, drawParticlePlugin, drawPlugin, paintBase, paintImage, } from "../Utils/CanvasUtils.js";
|
|
2
2
|
import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
|
|
4
4
|
import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
|
|
5
|
+
const fColorIndex = 0, sColorIndex = 1;
|
|
5
6
|
function setTransformValue(factor, newFactor, key) {
|
|
6
7
|
const newValue = newFactor[key];
|
|
7
8
|
if (newValue !== undefined) {
|
|
@@ -40,6 +41,9 @@ function setStyle(canvas, style, important = false) {
|
|
|
40
41
|
export class Canvas {
|
|
41
42
|
constructor(container, engine) {
|
|
42
43
|
this.container = container;
|
|
44
|
+
this._reusableColorStyles = {};
|
|
45
|
+
this._reusablePluginColors = [undefined, undefined];
|
|
46
|
+
this._reusableTransform = {};
|
|
43
47
|
this._applyPostDrawUpdaters = particle => {
|
|
44
48
|
for (const updater of this._postDrawUpdaters) {
|
|
45
49
|
updater.afterDraw?.(particle);
|
|
@@ -83,7 +87,9 @@ export class Canvas {
|
|
|
83
87
|
break;
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
|
-
|
|
90
|
+
this._reusablePluginColors[fColorIndex] = fColor;
|
|
91
|
+
this._reusablePluginColors[sColorIndex] = sColor;
|
|
92
|
+
return this._reusablePluginColors;
|
|
87
93
|
};
|
|
88
94
|
this._initStyle = () => {
|
|
89
95
|
const element = this.element, options = this.container.actualOptions;
|
|
@@ -97,7 +103,7 @@ export class Canvas {
|
|
|
97
103
|
this._resetOriginalStyle();
|
|
98
104
|
}
|
|
99
105
|
for (const key in options.style) {
|
|
100
|
-
if (!key || !Object.
|
|
106
|
+
if (!key || !Object.hasOwn(options.style, key)) {
|
|
101
107
|
continue;
|
|
102
108
|
}
|
|
103
109
|
const value = options.style[key];
|
|
@@ -230,22 +236,12 @@ export class Canvas {
|
|
|
230
236
|
if (!fColor && !sColor) {
|
|
231
237
|
return;
|
|
232
238
|
}
|
|
233
|
-
const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return getStyleFromHsl(fColor, container.hdr, zOpacity);
|
|
238
|
-
}, colorStyles = {
|
|
239
|
-
fill: getFillStyle(),
|
|
240
|
-
}, getStrokestyle = () => {
|
|
241
|
-
if (!sColor) {
|
|
242
|
-
return colorStyles.fill;
|
|
243
|
-
}
|
|
244
|
-
return getStyleFromHsl(sColor, container.hdr, zStrokeOpacity);
|
|
245
|
-
};
|
|
246
|
-
colorStyles.stroke = getStrokestyle();
|
|
239
|
+
const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? getStyleFromHsl(fColor, container.hdr, opacity) : undefined, stroke = sColor ? getStyleFromHsl(sColor, container.hdr, strokeOpacity) : fill;
|
|
240
|
+
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
241
|
+
colorStyles.fill = fill;
|
|
242
|
+
colorStyles.stroke = stroke;
|
|
247
243
|
this.draw((context) => {
|
|
248
|
-
this._applyPreDrawUpdaters(context, particle, radius,
|
|
244
|
+
this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
|
|
249
245
|
drawParticle({
|
|
250
246
|
container,
|
|
251
247
|
context,
|
|
@@ -253,7 +249,7 @@ export class Canvas {
|
|
|
253
249
|
delta,
|
|
254
250
|
colorStyles,
|
|
255
251
|
radius: radius * zIndexFactor ** zIndexOptions.sizeRate,
|
|
256
|
-
opacity:
|
|
252
|
+
opacity: opacity,
|
|
257
253
|
transform,
|
|
258
254
|
});
|
|
259
255
|
});
|
|
@@ -12,11 +12,9 @@ import { safeIntersectionObserver } from "../Utils/Utils.js";
|
|
|
12
12
|
function guardCheck(container) {
|
|
13
13
|
return !container.destroyed;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
factor: smooth ? defaultFps / fpsLimit : (defaultFps * value) / millisecondsToSeconds,
|
|
19
|
-
};
|
|
15
|
+
function updateDelta(delta, value, fpsLimit = defaultFps, smooth = false) {
|
|
16
|
+
delta.value = value;
|
|
17
|
+
delta.factor = smooth ? defaultFps / fpsLimit : (defaultFps * value) / millisecondsToSeconds;
|
|
20
18
|
}
|
|
21
19
|
function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
22
20
|
const options = new Options(engine, container);
|
|
@@ -25,6 +23,7 @@ function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
|
25
23
|
}
|
|
26
24
|
export class Container {
|
|
27
25
|
constructor(engine, id, sourceOptions) {
|
|
26
|
+
this._delta = { value: 0, factor: 0 };
|
|
28
27
|
this._intersectionManager = entries => {
|
|
29
28
|
if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
|
|
30
29
|
return;
|
|
@@ -50,14 +49,14 @@ export class Container {
|
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
51
|
this._lastFrameTime ??= timestamp;
|
|
53
|
-
|
|
54
|
-
this.addLifeTime(
|
|
52
|
+
updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
|
|
53
|
+
this.addLifeTime(this._delta.value);
|
|
55
54
|
this._lastFrameTime = timestamp;
|
|
56
|
-
if (
|
|
55
|
+
if (this._delta.value > millisecondsToSeconds) {
|
|
57
56
|
this.draw(false);
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
60
|
-
this.canvas.drawParticles(
|
|
59
|
+
this.canvas.drawParticles(this._delta);
|
|
61
60
|
if (!this.alive()) {
|
|
62
61
|
this.destroy();
|
|
63
62
|
return;
|
|
@@ -222,15 +221,11 @@ export class Container {
|
|
|
222
221
|
for (const effectDrawer of this.effectDrawers.values()) {
|
|
223
222
|
effectDrawer.destroy?.(this);
|
|
224
223
|
}
|
|
224
|
+
this.effectDrawers.clear();
|
|
225
225
|
for (const shapeDrawer of this.shapeDrawers.values()) {
|
|
226
226
|
shapeDrawer.destroy?.(this);
|
|
227
227
|
}
|
|
228
|
-
|
|
229
|
-
this.effectDrawers.delete(key);
|
|
230
|
-
}
|
|
231
|
-
for (const key of this.shapeDrawers.keys()) {
|
|
232
|
-
this.shapeDrawers.delete(key);
|
|
233
|
-
}
|
|
228
|
+
this.shapeDrawers.clear();
|
|
234
229
|
this._engine.clearPlugins(this);
|
|
235
230
|
this.destroyed = true;
|
|
236
231
|
if (remove) {
|
package/browser/Core/Engine.js
CHANGED
|
@@ -4,6 +4,7 @@ import { EventDispatcher } from "../Utils/EventDispatcher.js";
|
|
|
4
4
|
import { EventType } from "../Enums/Types/EventType.js";
|
|
5
5
|
import { getLogger } from "../Utils/LogUtils.js";
|
|
6
6
|
import { getRandom } from "../Utils/MathUtils.js";
|
|
7
|
+
const fullPercent = "100%";
|
|
7
8
|
async function getItemsFromInitializer(container, map, initializers, force = false) {
|
|
8
9
|
let res = map.get(container);
|
|
9
10
|
if (!res || force) {
|
|
@@ -25,6 +26,7 @@ async function getDataFromUrl(data) {
|
|
|
25
26
|
return data.fallback;
|
|
26
27
|
}
|
|
27
28
|
const getCanvasFromContainer = (domContainer) => {
|
|
29
|
+
const documentSafe = safeDocument();
|
|
28
30
|
let canvasEl;
|
|
29
31
|
if (domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === canvasTag) {
|
|
30
32
|
canvasEl = domContainer;
|
|
@@ -37,28 +39,24 @@ const getCanvasFromContainer = (domContainer) => {
|
|
|
37
39
|
canvasEl.dataset[generatedAttribute] = generatedFalse;
|
|
38
40
|
}
|
|
39
41
|
else {
|
|
40
|
-
canvasEl =
|
|
42
|
+
canvasEl = documentSafe.createElement(canvasTag);
|
|
41
43
|
canvasEl.dataset[generatedAttribute] = generatedTrue;
|
|
42
44
|
domContainer.appendChild(canvasEl);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
canvasEl.style.width = fullPercent;
|
|
48
|
-
}
|
|
49
|
-
if (!canvasEl.style.height) {
|
|
50
|
-
canvasEl.style.height = fullPercent;
|
|
51
|
-
}
|
|
47
|
+
canvasEl.style.width ||= fullPercent;
|
|
48
|
+
canvasEl.style.height ||= fullPercent;
|
|
52
49
|
return canvasEl;
|
|
53
50
|
}, getDomContainer = (id, source) => {
|
|
54
|
-
|
|
51
|
+
const documentSafe = safeDocument();
|
|
52
|
+
let domContainer = source ?? document.getElementById(id);
|
|
55
53
|
if (domContainer) {
|
|
56
54
|
return domContainer;
|
|
57
55
|
}
|
|
58
|
-
domContainer =
|
|
56
|
+
domContainer = documentSafe.createElement("div");
|
|
59
57
|
domContainer.id = id;
|
|
60
58
|
domContainer.dataset[generatedAttribute] = generatedTrue;
|
|
61
|
-
|
|
59
|
+
documentSafe.body.append(domContainer);
|
|
62
60
|
return domContainer;
|
|
63
61
|
};
|
|
64
62
|
export class Engine {
|
|
@@ -95,7 +93,7 @@ export class Engine {
|
|
|
95
93
|
return this._domArray;
|
|
96
94
|
}
|
|
97
95
|
get version() {
|
|
98
|
-
return "4.0.0-alpha.
|
|
96
|
+
return "4.0.0-alpha.3";
|
|
99
97
|
}
|
|
100
98
|
addColorManager(manager) {
|
|
101
99
|
this.colorManagers.set(manager.key, manager);
|
|
@@ -221,10 +219,32 @@ export class Engine {
|
|
|
221
219
|
if (this._initialized) {
|
|
222
220
|
return;
|
|
223
221
|
}
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
const executed = new Set(), allLoaders = new Set(this._loadPromises), stack = [...allLoaders];
|
|
223
|
+
while (stack.length) {
|
|
224
|
+
const loader = stack.shift();
|
|
225
|
+
if (!loader) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (executed.has(loader)) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
executed.add(loader);
|
|
232
|
+
const inner = [], origRegister = this.register.bind(this);
|
|
233
|
+
this.register = (...loaders) => {
|
|
234
|
+
inner.push(...loaders);
|
|
235
|
+
for (const loader of loaders) {
|
|
236
|
+
allLoaders.add(loader);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
await loader(this);
|
|
240
|
+
this.register = origRegister;
|
|
241
|
+
stack.unshift(...inner);
|
|
242
|
+
this._loadPromises.delete(loader);
|
|
226
243
|
}
|
|
227
244
|
this._loadPromises.clear();
|
|
245
|
+
for (const loader of allLoaders) {
|
|
246
|
+
this._loadPromises.add(loader);
|
|
247
|
+
}
|
|
228
248
|
this._initialized = true;
|
|
229
249
|
}
|
|
230
250
|
item(index) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/browser/Core/Particle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector, Vector3d } from "./Utils/Vectors.js";
|
|
2
2
|
import { calcExactPositionOrRandomFromSize, clamp, degToRad, getParticleBaseVelocity, getParticleDirectionAngle, getRandom, getRangeValue, randomInRangeValue, setRangeValue, } from "../Utils/MathUtils.js";
|
|
3
|
-
import { decayOffset, defaultAngle, defaultRetryCount, double, half, millisecondsToSeconds, minZ, none, randomColorValue, rollFactor, squareExp, tryCountIncrement, } from "./Utils/Constants.js";
|
|
3
|
+
import { decayOffset, defaultAngle, defaultOpacity, defaultRetryCount, defaultTransform, double, half, identity, millisecondsToSeconds, minZ, none, randomColorValue, rollFactor, squareExp, tryCountIncrement, zIndexFactorOffset, } from "./Utils/Constants.js";
|
|
4
4
|
import { deepExtend, getPosition, initParticleNumericAnimationValue, isInArray, itemFromSingleOrMultiple, } from "../Utils/Utils.js";
|
|
5
5
|
import { EventType } from "../Enums/Types/EventType.js";
|
|
6
6
|
import { Interactivity } from "../Options/Classes/Interactivity/Interactivity.js";
|
|
@@ -39,51 +39,50 @@ function fixOutMode(data) {
|
|
|
39
39
|
export class Particle {
|
|
40
40
|
constructor(engine, container) {
|
|
41
41
|
this.container = container;
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
this._cachedOpacityData = {
|
|
43
|
+
opacity: defaultOpacity,
|
|
44
|
+
strokeOpacity: defaultOpacity,
|
|
45
|
+
};
|
|
46
|
+
this._cachedPosition = Vector3d.origin;
|
|
47
|
+
this._cachedRotateData = { sin: 0, cos: 0 };
|
|
48
|
+
this._cachedTransform = {
|
|
49
|
+
a: 1,
|
|
50
|
+
b: 0,
|
|
51
|
+
c: 0,
|
|
52
|
+
d: 1,
|
|
53
|
+
};
|
|
54
|
+
this._calcPosition = (position, zIndex) => {
|
|
55
|
+
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
56
|
+
const container = this.container, plugins = Array.from(container.plugins.values()), outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
|
|
57
|
+
while (!signal.aborted) {
|
|
58
|
+
for (const plugin of plugins) {
|
|
59
|
+
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
60
|
+
if (pluginPos) {
|
|
61
|
+
return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
62
|
+
}
|
|
48
63
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fixOutMode({
|
|
64
|
-
outMode,
|
|
65
|
-
checkModes: [OutMode.bounce],
|
|
66
|
-
coord: pos.y,
|
|
67
|
-
maxCoord: container.canvas.size.height,
|
|
68
|
-
setCb: (value) => (pos.y += value),
|
|
69
|
-
radius,
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
fixHorizontal(outModes.left ?? outModes.default);
|
|
73
|
-
fixHorizontal(outModes.right ?? outModes.default);
|
|
74
|
-
fixVertical(outModes.top ?? outModes.default);
|
|
75
|
-
fixVertical(outModes.bottom ?? outModes.default);
|
|
76
|
-
let isValidPosition = true;
|
|
77
|
-
for (const plugin of plugins) {
|
|
78
|
-
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount);
|
|
79
|
-
if (isValidPosition === false) {
|
|
80
|
-
break;
|
|
64
|
+
const exactPosition = calcExactPositionOrRandomFromSize({
|
|
65
|
+
size: canvasSize,
|
|
66
|
+
position: posVec,
|
|
67
|
+
}), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
|
|
68
|
+
this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
|
|
69
|
+
this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
|
|
70
|
+
this._fixVertical(pos, radius, outModes.top ?? outModes.default);
|
|
71
|
+
this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
|
|
72
|
+
let isValidPosition = true;
|
|
73
|
+
for (const plugin of plugins) {
|
|
74
|
+
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
|
|
75
|
+
if (!isValidPosition) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
81
78
|
}
|
|
79
|
+
if (isValidPosition) {
|
|
80
|
+
return pos;
|
|
81
|
+
}
|
|
82
|
+
tryCount += tryCountIncrement;
|
|
83
|
+
posVec = undefined;
|
|
82
84
|
}
|
|
83
|
-
|
|
84
|
-
return this._calcPosition(container, undefined, zIndex, tryCount + tryCountIncrement);
|
|
85
|
-
}
|
|
86
|
-
return pos;
|
|
85
|
+
return posVec;
|
|
87
86
|
};
|
|
88
87
|
this._calculateVelocity = () => {
|
|
89
88
|
const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
@@ -102,6 +101,26 @@ export class Particle {
|
|
|
102
101
|
}
|
|
103
102
|
return res;
|
|
104
103
|
};
|
|
104
|
+
this._fixHorizontal = (pos, radius, outMode) => {
|
|
105
|
+
fixOutMode({
|
|
106
|
+
outMode,
|
|
107
|
+
checkModes: [OutMode.bounce],
|
|
108
|
+
coord: pos.x,
|
|
109
|
+
maxCoord: this.container.canvas.size.width,
|
|
110
|
+
setCb: (value) => (pos.x += value),
|
|
111
|
+
radius,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
this._fixVertical = (pos, radius, outMode) => {
|
|
115
|
+
fixOutMode({
|
|
116
|
+
outMode,
|
|
117
|
+
checkModes: [OutMode.bounce],
|
|
118
|
+
coord: pos.y,
|
|
119
|
+
maxCoord: this.container.canvas.size.height,
|
|
120
|
+
setCb: (value) => (pos.y += value),
|
|
121
|
+
radius,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
105
124
|
this._getRollColor = color => {
|
|
106
125
|
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
107
126
|
return color;
|
|
@@ -120,7 +139,11 @@ export class Particle {
|
|
|
120
139
|
};
|
|
121
140
|
this._initPosition = position => {
|
|
122
141
|
const container = this.container, zIndexValue = getRangeValue(this.options.zIndex.value);
|
|
123
|
-
|
|
142
|
+
const initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
143
|
+
if (!initialPosition) {
|
|
144
|
+
throw new Error("a valid position cannot be found for particle");
|
|
145
|
+
}
|
|
146
|
+
this.position = initialPosition;
|
|
124
147
|
this.initialPosition = this.position.copy();
|
|
125
148
|
const canvasSize = container.canvas.size;
|
|
126
149
|
this.moveCenter = {
|
|
@@ -180,19 +203,42 @@ export class Particle {
|
|
|
180
203
|
getMass() {
|
|
181
204
|
return this.getRadius() ** squareExp * Math.PI * half;
|
|
182
205
|
}
|
|
206
|
+
getOpacity() {
|
|
207
|
+
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity), strokeOpacity = this.strokeOpacity ?? opacity;
|
|
208
|
+
this._cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
209
|
+
this._cachedOpacityData.strokeOpacity = strokeOpacity * zOpacityFactor;
|
|
210
|
+
return this._cachedOpacityData;
|
|
211
|
+
}
|
|
183
212
|
getPosition() {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
213
|
+
this._cachedPosition.x = this.position.x + this.offset.x;
|
|
214
|
+
this._cachedPosition.y = this.position.y + this.offset.y;
|
|
215
|
+
this._cachedPosition.z = this.position.z;
|
|
216
|
+
return this._cachedPosition;
|
|
189
217
|
}
|
|
190
218
|
getRadius() {
|
|
191
219
|
return this.bubble.radius ?? this.size.value;
|
|
192
220
|
}
|
|
221
|
+
getRotateData() {
|
|
222
|
+
const angle = this.getAngle();
|
|
223
|
+
this._cachedRotateData.sin = Math.sin(angle);
|
|
224
|
+
this._cachedRotateData.cos = Math.cos(angle);
|
|
225
|
+
return this._cachedRotateData;
|
|
226
|
+
}
|
|
193
227
|
getStrokeColor() {
|
|
194
228
|
return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
|
|
195
229
|
}
|
|
230
|
+
getTransformData(externalTransform) {
|
|
231
|
+
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
232
|
+
this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
|
|
233
|
+
this._cachedTransform.b = rotating
|
|
234
|
+
? rotateData.sin * (externalTransform.b ?? identity)
|
|
235
|
+
: (externalTransform.b ?? defaultTransform.b);
|
|
236
|
+
this._cachedTransform.c = rotating
|
|
237
|
+
? -rotateData.sin * (externalTransform.c ?? identity)
|
|
238
|
+
: (externalTransform.c ?? defaultTransform.c);
|
|
239
|
+
this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
|
|
240
|
+
return this._cachedTransform;
|
|
241
|
+
}
|
|
196
242
|
init(id, position, overrideOptions, group) {
|
|
197
243
|
const container = this.container, engine = this._engine;
|
|
198
244
|
this.id = id;
|