@tsparticles/engine 4.0.0-alpha.22 → 4.0.0-alpha.23

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/515.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";(this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[515],{5515(t,i,e){e.d(i,{Container:()=>M});var s=e(493),a=e(7157),r=e(1963),n=e(2439),h=e(6720);function o(t,i,e=!1){if(!i)return;let s=t.style,a=new Set;for(let t=0;t<s.length;t++){let i=s.item(t);i&&a.add(i)}for(let t=0;t<i.length;t++){let e=i.item(t);e&&a.add(e)}for(let t of a){let a=i.getPropertyValue(t);a?s.setProperty(t,a,e?"important":""):s.removeProperty(t)}}class l{container;element;size;_canvasClearPlugins;_canvasPaintPlugins;_canvasSettings;_clearDrawPlugins;_colorPlugins;_context;_drawParticlePlugins;_drawParticlesCleanupPlugins;_drawParticlesSetupPlugins;_drawPlugins;_drawSettingsCleanupPlugins;_drawSettingsSetupPlugins;_engine;_generated;_mutationObserver;_originalStyle;_pointerEvents;_postDrawUpdaters;_preDrawUpdaters;_resizePlugins;_reusableColorStyles={};_reusablePluginColors=[void 0,void 0];_reusableTransform={};_standardSize;constructor(t,i){this.container=t,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._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this._pointerEvents="none"}get settings(){return this._canvasSettings}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw(t=>{(0,r.IU)(t,this.size)})}clear(){let t=!1;for(let i of this._canvasClearPlugins)if(t=i.canvasClear?.()??!1)break;t||this.canvasClear()}destroy(){if(this.stop(),this._generated){let t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[]}draw(t){let i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;let e=t.getRadius();if(e<=a.w2)return;let s=t.getFillColor(),n=t.getStrokeColor()??s,[o,l]=this._getPluginParticleColors(t);if(o??=s,l??=n,!o&&!l)return;let c=this.container,d=t.options.zIndex,p=a.RV-t.zIndexFactor,{opacity:u,strokeOpacity:_}=t.getOpacity(),g=this._reusableTransform,f=this._reusableColorStyles,P=o?(0,h.LC)(o,c.hdr,u):void 0,m=l?(0,h.LC)(l,c.hdr,_):P;g.a=g.b=g.c=g.d=void 0,f.fill=P,f.stroke=m,this.draw(s=>{for(let e of this._drawParticlesSetupPlugins)e.drawParticleSetup?.(s,t,i);for(let a of(this._applyPreDrawUpdaters(s,t,e,u,f,g),(0,r.p0)({container:c,context:s,particle:t,delta:i,colorStyles:f,radius:e*p**d.sizeRate,opacity:u,transform:g}),this._applyPostDrawUpdaters(t),this._drawParticlesCleanupPlugins))a.drawParticleCleanup?.(s,t,i)})}drawParticlePlugins(t,i){this.draw(e=>{for(let s of this._drawParticlePlugins)(0,r.Wb)(e,s,t,i)})}drawParticles(t){let{particles:i}=this.container;this.clear(),i.update(t),this.draw(e=>{for(let i of this._drawSettingsSetupPlugins)i.drawSettingsSetup?.(e,t);for(let i of this._drawPlugins)i.draw?.(e,t);for(let s of(i.drawParticles(t),this._clearDrawPlugins))s.clearDraw?.(e,t);for(let i of this._drawSettingsCleanupPlugins)i.drawSettingsCleanup?.(e,t)})}init(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=(0,n.tG)(t=>{for(let i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()}),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver(t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){let{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;let s=e.style,a=(0,h.BN)(this._engine,i.color);a?s.backgroundColor=(0,h.xx)(a,t.hdr,i.opacity):s.backgroundColor="",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){for(let t of(this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesSetupPlugins=[],this._drawParticlesCleanupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this.container.plugins))t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t),t.canvasClear&&this._canvasClearPlugins.push(t),t.canvasPaint&&this._canvasPaintPlugins.push(t),t.drawParticle&&this._drawParticlePlugins.push(t),t.drawParticleSetup&&this._drawParticlesSetupPlugins.push(t),t.drawParticleCleanup&&this._drawParticlesCleanupPlugins.push(t),t.draw&&this._drawPlugins.push(t),t.drawSettingsSetup&&this._drawSettingsSetupPlugins.push(t),t.drawSettingsCleanup&&this._drawSettingsCleanupPlugins.push(t),t.clearDraw&&this._clearDrawPlugins.push(t)}initUpdaters(){for(let t of(this._preDrawUpdaters=[],this._postDrawUpdaters=[],this.container.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();let i=this.container;this._generated=a.eb in t.dataset?"true"===t.dataset[a.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,n.td)(this.element.style);let e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;let s=this.container.retina.pixelRatio,r=this.size;t.height=r.height=e.height*s,t.width=r.width=e.width*s;let h=(0,n.lV)("(color-gamut: p3)");this._canvasSettings={alpha:!0,colorSpace:h?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1},this._context=this.element.getContext("2d",this._canvasSettings),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(let i of this._canvasPaintPlugins)if(t=i.canvasPaint?.()??!1)break;t||this.paintBase()}paintBase(t){this.draw(i=>{(0,r.Sn)(i,this.size,t)})}paintImage(t,i){this.draw(e=>{(0,r.Md)(e,this.size,t,i)})}resize(){if(!this.element)return!1;let t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,a={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&a.height===this.element.height&&a.width===this.element.width)return!1;let r={...i};i.height=e.height,i.width=e.width;let n=this.size;return this.element.width=n.width=a.width,this.element.height=n.height=a.height,this.container.started&&t.particles.setResizeFactor({width:i.width/r.width,height:i.height/r.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}stop(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=void 0,this.draw(t=>{(0,r.IU)(t,this.size)})}async windowResize(){if(!this.element||!this.resize())return;let t=this.container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}_applyPostDrawUpdaters=t=>{for(let i of this._postDrawUpdaters)i.afterDraw?.(t)};_applyPreDrawUpdaters=(t,i,e,s,r,n)=>{for(let h of this._preDrawUpdaters){if(h.getColorStyles){let{fill:a,stroke:n}=h.getColorStyles(i,t,e,s);a&&(r.fill=a),n&&(r.stroke=n)}if(h.getTransformValues){let t=h.getTransformValues(i);for(let i in t)!function(t,i,e){let s=i[e];void 0!==s&&(t[e]=(t[e]??a.zs)*s)}(n,t,i)}h.beforeDraw?.(i)}};_applyResizePlugins=()=>{for(let t of this._resizePlugins)t.resize?.()};_getPluginParticleColors=t=>{let i,e;for(let s of this._colorPlugins)if(!i&&s.particleFillColor&&(i=(0,h.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,h.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors};_initStyle=()=>{let t=this.element,i=this.container.actualOptions;if(t)for(let e in this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle(),i.style){if(!e||!Object.hasOwn(i.style,e))continue;let s=i.style[e];s&&t.style.setProperty(e,s,"important")}};_repairStyle=()=>{let t=this.element;if(!t)return;this._safeMutationObserver(t=>{t.disconnect()}),this._initStyle(),this.initBackground();let i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver(i=>{t instanceof Node&&i.observe(t,{attributes:!0})})};_resetOriginalStyle=()=>{let t=this.element,i=this._originalStyle;t&&i&&o(t,i,!0)};_safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)};_setFullScreenStyle=()=>{let t=this.element;t&&o(t,(0,n.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)}}class c{container;_handlers;_resizeObserver;_resizeTimeout;constructor(t){this.container=t,this._handlers={visibilityChange:()=>{this._handleVisibilityChange()},resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}_handleVisibilityChange=()=>{let t=this.container;t.actualOptions.pauseOnBlur&&((0,n.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))};_handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);let t=async()=>{let t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout(()=>void t(),this.container.actualOptions.resize.delay*a.Xu)};_manageListeners=t=>{let i=this._handlers;this._manageResize(t),(0,n.Kp)(document,a.nK,i.visibilityChange,t,!1)};_manageResize=t=>{let i=this._handlers,e=this.container;if(!e.actualOptions.resize.enable)return;if("u"<typeof ResizeObserver)return void(0,n.Kp)(globalThis,a.NF,i.resize,t);let s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver(t=>{t.find(t=>t.target===s)&&this._handleWindowResize()}),this._resizeObserver.observe(s))}}var d=e(6911),p=e(5872),u=e(1610),_=e(1808),g=e(3702),f=e(3849),P=e(3457),m=e(9875);function y(t){if(!(0,n.hn)(t.outMode,t.checkModes))return;let i=t.radius*a.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class w{container;backColor;bubble;color;destroyed;direction;effect;effectClose;effectData;effectFill;group;id;ignoresResizeRatio;initialPosition;initialVelocity;isRotating;lastPathTime;misplaced;moveCenter;moveDecay;offset;opacity;options;outType;pathDelay;pathGenerator;pathRotation;position;randomIndexData;retina;roll;rotation;shape;shapeClose;shapeData;shapeFill;sides;size;slow;spawning;strokeColor;strokeOpacity;strokeWidth;unbreakable;velocity;zIndexFactor;_cachedOpacityData={opacity:a.hv,strokeOpacity:a.hv};_cachedPosition=_.p.origin;_cachedRotateData={sin:0,cos:0};_cachedTransform={a:1,b:0,c:0,d:1};_engine;constructor(t,i){this.container=i,this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;let i=this.container,e=this.pathGenerator,s=this.shape?i.particles.shapeDrawers.get(this.shape):void 0;for(let e of(s?.particleDestroy?.(this),i.particleDestroyedPlugins))e.particleDestroyed?.(this,t);for(let e of i.particles.updaters)e.particleDestroyed?.(this,t);e?.reset(this),this._engine.dispatchEvent(d.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){let i=this.container.canvas;i.drawParticlePlugins(this,t),i.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:a.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,h.O_)(this.color))}getMass(){return this.getRadius()**a.dm*Math.PI*a.MX}getOpacity(){let t=this.options.zIndex,i=a.RV-this.zIndexFactor,e=i**t.opacityRate,r=this.bubble.opacity??(0,s.VG)(this.opacity?.value??a.hv),n=this.strokeOpacity??r;return this._cachedOpacityData.opacity=r*e,this._cachedOpacityData.strokeOpacity=n*e,this._cachedOpacityData}getPosition(){return this._cachedPosition.x=this.position.x+this.offset.x,this._cachedPosition.y=this.position.y+this.offset.y,this._cachedPosition.z=this.position.z,this._cachedPosition}getRadius(){return this.bubble.radius??this.size.value}getRotateData(){let t=this.getAngle();return this._cachedRotateData.sin=Math.sin(t),this._cachedRotateData.cos=Math.cos(t),this._cachedRotateData}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,h.O_)(this.strokeColor))}getTransformData(t){let i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??a.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??a.D_):t.b??a.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??a.D_):t.c??a.Ug.c,this._cachedTransform.d=i.cos*(t.d??a.Ug.d),this._cachedTransform}init(t,i,e,r){var h,o,l,c;let d,p,u,_,g=this.container;this.id=t,this.group=r,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=P.x.normal,this.ignoresResizeRatio=!0;let f=g.retina.pixelRatio,y=g.actualOptions,w=(0,m.y)(this._engine,g,y.particles),v=w.reduceDuplicates,b=w.effect.type,z=w.shape.type;this.effect=(0,n.TA)(b,this.id,v),this.shape=(0,n.TA)(z,this.id,v);let S=w.effect,C=w.shape;if(e){if(e.effect?.type){let t=e.effect.type,i=(0,n.TA)(t,this.id,v);i&&(this.effect=i,S.load(e.effect))}if(e.shape?.type){let t=e.shape.type,i=(0,n.TA)(t,this.id,v);i&&(this.shape=i,C.load(e.shape))}}if(this.effect===a.mR){let t=[...this.container.particles.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===a.mR){let t=[...this.container.particles.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?(h=this.effect,o=this.id,u=S.options[h],(0,n.zw)({close:S.close,fill:S.fill},(0,n.TA)(u,o,v))):void 0,this.shapeData=this.shape?(l=this.shape,c=this.id,_=C.options[l],(0,n.zw)({close:C.close,fill:C.fill},(0,n.TA)(_,c,v))):void 0,w.load(e);let D=this.effectData;D&&w.load(D.particles);let x=this.shapeData;x&&w.load(x.particles),this.effectFill=D?.fill??w.effect.fill,this.effectClose=D?.close??w.effect.close,this.shapeFill=x?.fill??w.shape.fill,this.shapeClose=x?.close??w.shape.close,this.options=w;let R=this.options.move.path;if(this.pathDelay=(0,s.VG)(R.delay.value)*a.Xu,R.generator){let t=this.container.particles.pathGenerators.get(R.generator);!t&&(t=this.container.particles.availablePathGenerators.get(R.generator))&&(this.container.particles.pathGenerators.set(R.generator,t),t.init()),this.pathGenerator=t}g.retina.initParticle(this),this.size=(0,n.Xs)(this.options.size,f),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy(),this.moveDecay=a.WH-(0,s.VG)(this.options.move.decay);let O=g.particles;O.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/g.zLayers,this.sides=24,this.effect&&(d=g.particles.effectDrawers.get(this.effect)),d?.loadEffect&&d.loadEffect(this),this.shape&&(p=g.particles.shapeDrawers.get(this.shape)),p?.loadShape&&p.loadShape(this);let M=p?.getSidesCount;for(let t of(M&&(this.sides=M(this)),this.spawning=!1,O.updaters))t.init(this);for(let t of O.movers)t.init(this);for(let t of(d?.particleInit?.(g,this),p?.particleInit?.(g,this),g.particleCreatedPlugins))t.particleCreated?.(this)}isInsideCanvas(){let t=this.getRadius(),i=this.container.canvas.size,e=this.position;return e.x>=-t&&e.y>=-t&&e.y<=i.height+t&&e.x<=i.width+t}isShowingBack(){if(!this.roll)return!1;let t=this.roll.angle;if(this.roll.horizontal&&this.roll.vertical){let i=t%a.R1,e=i<a.tA?i+a.R1:i;return e>=Math.PI*a.MX&&e<Math.PI*a.Nu*a.MX}if(this.roll.horizontal){let i=(t+Math.PI*a.MX)%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}if(this.roll.vertical){let i=t%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}return!1}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){for(let t of this.container.particles.updaters)t.reset?.(this)}_calcPosition=(t,i)=>{let e=a.rq,r=t?_.p.create(t.x,t.y,i):void 0,n=this.container,h=n.particlePositionPlugins,o=this.options.move.outModes,l=this.getRadius(),c=n.canvas.size,{signal:d}=new AbortController;for(;!d.aborted;){for(let t of h){let e=t.particlePosition?.(r,this);if(e)return _.p.create(e.x,e.y,i)}let t=(0,s.Nx)({size:c,position:r}),d=_.p.create(t.x,t.y,i);this._fixHorizontal(d,l,o.left??o.default),this._fixHorizontal(d,l,o.right??o.default),this._fixVertical(d,l,o.top??o.default),this._fixVertical(d,l,o.bottom??o.default);let p=!0;for(let t of n.particles.checkParticlePositionPlugins)if(!(p=t.checkParticlePosition?.(this,d,e)??!0))break;if(p)return d;e+=a.Eo,r=void 0}return r};_calculateVelocity=()=>{let t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===g.F.inside||i.direction===g.F.outside)return t;let e=(0,s.pu)((0,s.VG)(i.angle.value)),r=(0,s.pu)((0,s.VG)(i.angle.offset)),n={left:r-e*a.MX,right:r+e*a.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(n.left,n.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t};_fixHorizontal=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.x,maxCoord:this.container.canvas.size.width,setCb:i=>t.x+=i,radius:i})};_fixVertical=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.y,maxCoord:this.container.canvas.size.height,setCb:i=>t.y+=i,radius:i})};_getRollColor=t=>t&&this.roll&&(this.backColor||this.roll.alter)&&this.isShowingBack()?this.backColor?this.backColor:this.roll.alter?(0,r.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t;_initPosition=t=>{let i=this.container,e=(0,s.VG)(this.options.zIndex.value),r=this._calcPosition(t,(0,s.qE)(e,a.X_,i.zLayers));if(!r)throw Error("a valid position cannot be found for particle");this.position=r,this.initialPosition=this.position.copy();let h=i.canvas.size;switch(this.moveCenter={...(0,n.E9)(this.options.move.center,h),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case g.F.inside:this.outType=P.x.inside;break;case g.F.outside:this.outType=P.x.outside}this.offset=_.M.origin}}var v=e(2714),b=e(1636);class z{rectangle;capacity;_divided;_points;_subs;constructor(t,i){this.rectangle=t,this.capacity=i,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){let e=[];if(!t.intersects(this.rectangle))return[];for(let a of this._points)!t.contains(a.position)&&(0,s.Yf)(t.position,a.position)>a.particle.getRadius()&&(!i||i(a.particle))||e.push(a.particle);if(this._divided)for(let s of this._subs)e.push(...s.query(t,i));return e}queryCircle(t,i,e){return this.query(new b.jl(t.x,t.y,i),e)}queryRectangle(t,i,e){return this.query(new b.M_(t.x,t.y,i.width,i.height),e)}_subdivide=()=>{let{x:t,y:i}=this.rectangle.position,{width:e,height:s}=this.rectangle.size,{capacity:r}=this;for(let n=0;n<a.Pg;n++){let h=n%a.gd;this._subs.push(new z(new b.M_(t+e*a.MX*h,i+s*a.MX*(Math.round(n*a.MX)-h),e*a.MX,s*a.MX),r))}this._divided=!0}}var S=e(567);let C=t=>{let{height:i,width:e}=t;return new b.M_(a.un*e,a.un*i,a.Rh*e,a.Rh*i)};class D{availablePathGenerators;checkParticlePositionPlugins;effectDrawers;movers;pathGenerators;quadTree;shapeDrawers;updaters;_array;_container;_engine;_groupLimits;_limit;_maxZIndex;_minZIndex;_needsSort;_nextId;_particleResetPlugins;_particleUpdatePlugins;_pool;_postParticleUpdatePlugins;_postUpdatePlugins;_resizeFactor;_updatePlugins;_zArray;constructor(t,i){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._minZIndex=0,this._maxZIndex=0;const e=i.canvas.size;this.quadTree=new z(C(e),a.Kw),this.effectDrawers=new Map,this.movers=[],this.availablePathGenerators=new Map,this.pathGenerators=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}get count(){return this._array.length}addParticle(t,i,e,s){let r=this._container.actualOptions.particles.number.limit.mode,n=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,h=this.count;if(n>a.ou)switch(r){case u.d.delete:{let t=h+a.nq-n;t>a.wM&&this.removeQuantity(t);break}case u.d.wait:if(h>=n)return}try{let a=this._pool.pop()??new w(this._engine,this._container);a.init(this._nextId,t,i,e);let r=!0;if(s&&(r=s(a)),!r)return void this._pool.push(a);return this._array.push(a),this._zArray.push(a),this._nextId++,this._engine.dispatchEvent(d.B.particleAdded,{container:this._container,data:{particle:a}}),a}catch(t){(0,S.t)().warning(`error adding particle: ${t}`)}}clear(){this._array=[],this._zArray=[]}destroy(){let t=this._container;for(let[,i]of this.effectDrawers)i.destroy?.(t);for(let[,i]of this.shapeDrawers)i.destroy?.(t);this._array=[],this._pool.length=0,this._zArray=[],this.effectDrawers=new Map,this.movers=[],this.availablePathGenerators=new Map,this.pathGenerators=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}drawParticles(t){for(let i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}async init(){let t=this._container,i=t.actualOptions;for(let i of(this._minZIndex=0,this._maxZIndex=0,this._needsSort=!1,this.checkParticlePositionPlugins=[],this._updatePlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._particleResetPlugins=[],this._postParticleUpdatePlugins=[],t.plugins))i.redrawInit&&await i.redrawInit(),i.checkParticlePosition&&this.checkParticlePositionPlugins.push(i),i.update&&this._updatePlugins.push(i),i.particleUpdate&&this._particleUpdatePlugins.push(i),i.postUpdate&&this._postUpdatePlugins.push(i),i.particleReset&&this._particleResetPlugins.push(i),i.postParticleUpdate&&this._postParticleUpdatePlugins.push(i);for(let i of(await this.initPlugins(),this.effectDrawers.values()))await i.init?.(t);for(let i of this.shapeDrawers.values())await i.init?.(t);let e=!1;for(let i of t.plugins)if(e=i.particlesInitialization?.()??e)break;if(!e){let t=i.particles,e=t.groups;for(let i in e){let s=e[i];if(s)for(let e=this.count,a=0;a<s.number.value&&e<t.number.value;e++,a++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){let t=this._container;for(let i of(this.effectDrawers=await this._engine.getEffectDrawers(t,!0),this.movers=await this._engine.getMovers(t,!0),this.availablePathGenerators=await this._engine.getPathGenerators(t,!0),this.pathGenerators=new Map,this.shapeDrawers=await this._engine.getShapeDrawers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0),this.pathGenerators.values()))i.init()}push(t,i,e,s){for(let a=0;a<t;a++)this.addParticle(i,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=a.xd,e,s){if(t<a.z9||t>this.count)return;let r=0;for(let a=t;r<i&&a<this.count;a++)this._removeParticle(a,e,s)&&(a--,r++)}removeQuantity(t,i){this.removeAt(a.z9,t,i)}setDensity(){let t=this._container.actualOptions,i=t.particles.groups,e=0;for(let t of this._container.plugins)t.particlesDensityCount&&(e+=t.particlesDensityCount());for(let t in i){let s=i[t];if(!s)continue;let a=(0,m.y)(this._engine,this._container,s);this._applyDensity(a,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._needsSort||=t>=this._maxZIndex||t>this._minZIndex&&t<this._maxZIndex}setResizeFactor(t){this._resizeFactor=t}update(t){let i=this._container,e=new Set;for(let t of(this.quadTree=new z(C(i.canvas.size),a.Kw),this.pathGenerators.values()))t.update();for(let i of this._updatePlugins)i.update?.(t);let s=this._resizeFactor;for(let i of this._array){for(let t of(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._particleResetPlugins))t.particleReset?.(i);for(let e of this._particleUpdatePlugins){if(i.destroyed)break;e.particleUpdate?.(i,t)}for(let e of this.movers)e.isEnabled(i)&&e.move(i,t);if(i.destroyed){e.add(i);continue}this.quadTree.insert(new v.b(i.getPosition(),i))}if(e.size){let t=t=>!e.has(t);for(let i of(this._array=this.filter(t),this._zArray=this._zArray.filter(t),e))this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:i}});this._addToPool(...e)}for(let i of this._postUpdatePlugins)i.postUpdate?.(t);for(let i of this._array){for(let e of this.updaters)e.update(i,t);if(!i.destroyed&&!i.spawning)for(let e of this._postParticleUpdatePlugins)e.postParticleUpdate?.(i,t)}if(delete this._resizeFactor,this._needsSort){let t=this._zArray;t.sort((t,i)=>i.position.z-t.position.z||t.id-i.id);let i=t[a.z9],e=t[t.length-a.K3];if(!i||!e)return;this._maxZIndex=i.position.z,this._minZIndex=e.position.z,this._needsSort=!1}}_addToPool=(...t)=>{this._pool.push(...t)};_applyDensity=(t,i,e,s)=>{let r=t.number;if(!r.density.enable)return void(void 0===e?this._limit=r.limit.value:(s?.number.limit.value??r.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??r.limit.value));let n=this._initDensityFactor(r.density),h=r.value,o=r.limit.value>a.ou?r.limit.value:h,l=Math.min(h,o)*n+i,c=Math.min(this.count,this.filter(t=>t.group===e).length);void 0===e?this._limit=r.limit.value*n:this._groupLimits.set(e,r.limit.value*n),c<l?this.push(Math.abs(l-c),void 0,t,e):c>l&&this.removeQuantity(c-l,e)};_initDensityFactor=t=>{let i=this._container;if(!i.canvas.element||!t.enable)return a.lA;let e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**a.dm)};_removeParticle=(t,i,e)=>{let s=this._array[t];if(!s||s.group!==i)return!1;let r=this._zArray.indexOf(s);return this._array.splice(t,a.LD),this._zArray.splice(r,a.LD),s.destroy(e),this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0}}class x{container;maxSpeed;pixelRatio;reduceFactor;sizeAnimationSpeed;constructor(t){this.container=t,this.pixelRatio=a.$x,this.reduceFactor=a.Zp}init(){let t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:a.$x,this.reduceFactor=a.Zp;let e=this.pixelRatio,r=t.canvas;if(r.element){let t=r.element;r.size.width=t.offsetWidth*e,r.size.height=t.offsetHeight*e}let n=i.particles,h=n.move;this.maxSpeed=(0,s.VG)(h.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(n.size.animation.speed)*e}initParticle(t){let i=t.options,e=this.pixelRatio,a=i.move,r=a.distance,n=t.retina;n.moveDrift=(0,s.VG)(a.drift)*e,n.moveSpeed=(0,s.VG)(a.speed)*e,n.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;let h=n.maxDistance;h.horizontal=void 0!==r.horizontal?r.horizontal*e:void 0,h.vertical=void 0!==r.vertical?r.vertical*e:void 0,n.maxSpeed=(0,s.VG)(a.gravity.maxSpeed)*e}}function R(t){return!t.destroyed}function O(t,i,...e){let s=new p.J(t,i);return(0,m.Z)(s,...e),s}class M{actualOptions;canvas;destroyed;fpsLimit;hdr;id;pageHidden;particleCreatedPlugins;particleDestroyedPlugins;particlePositionPlugins;particles;plugins;retina;started;zLayers;_delay;_delayTimeout;_delta={value:0,factor:0};_drawAnimationFrame;_duration;_engine;_eventListeners;_firstStart;_initialSourceOptions;_lastFrameTime;_lifeTime;_options;_paused;_smooth;_sourceOptions;constructor(t,i,e){this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new x(this),this.canvas=new l(this,this._engine),this.particles=new D(this._engine,this),this.plugins=[],this.particleDestroyedPlugins=[],this.particleCreatedPlugins=[],this.particlePositionPlugins=[],this._options=O(this._engine,this),this.actualOptions=O(this._engine,this),this._eventListeners=new c(this),this._engine.dispatchEvent(d.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&R(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addLifeTime(t){this._lifeTime+=t}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(t=!0){if(R(this)){for(let t of(this.stop(),this.particles.destroy(),this.canvas.destroy(),this.plugins))t.destroy?.();if(this.plugins.length=0,this._engine.clearPlugins(this),this.destroyed=!0,t){let t=this._engine.items,i=t.indexOf(this);i>=a.vF&&t.splice(i,a.JC)}this._engine.dispatchEvent(d.B.containerDestroyed,{container:this})}}draw(t){if(!R(this))return;let i=t,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(let e of this.plugins){if(!e.export)continue;let s=await e.export(t,i);if(s.supported)return s.blob}(0,S.t)().error(`Export plugin with type ${t} not found`)}async init(){if(!R(this))return;let t=new Map;for(let i of this._engine.plugins){let e=await i.getPlugin(this);e.preInit&&await e.preInit(),t.set(i,e)}for(let[i,e]of(await this.particles.initPlugins(),this._options=O(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=O(this._engine,this,this._options),this.plugins.length=0,this.particleDestroyedPlugins.length=0,this.particleCreatedPlugins.length=0,this.particlePositionPlugins.length=0,t))i.needsPlugin(this.actualOptions)&&(this.plugins.push(e),e.particleCreated&&this.particleCreatedPlugins.push(e),e.particleDestroyed&&this.particleDestroyedPlugins.push(e),e.particlePosition&&this.particlePositionPlugins.push(e));this.retina.init(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();let{delay:i,duration:e,fpsLimit:r,hdr:n,smooth:h,zLayers:o}=this.actualOptions;for(let t of(this.hdr=n,this.zLayers=o,this._duration=(0,s.VG)(e)*a.Xu,this._delay=(0,s.VG)(i)*a.Xu,this._lifeTime=0,this.fpsLimit=r>a.DN?r:a.i8,this._smooth=h,this.plugins))await t.init?.();for(let t of(await this.particles.init(),this._engine.dispatchEvent(d.B.containerInit,{container:this}),this.particles.setDensity(),this.plugins))t.particlesSetup?.();this._engine.dispatchEvent(d.B.particlesSetup,{container:this})}pause(){if(R(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(let t of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(d.B.containerPaused,{container:this})}}play(t){if(!R(this))return;let i=this._paused||t;if(this._firstStart&&!this.actualOptions.autoPlay){this._firstStart=!1;return}if(this._paused&&(this._paused=!1),i)for(let t of this.plugins)t.play&&t.play();this._engine.dispatchEvent(d.B.containerPlay,{container:this}),this.draw(i??!1)}async refresh(){if(R(this))return this.stop(),this.start()}async reset(t){if(R(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=O(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=O(this._engine,this,this._options),this.refresh()}async start(){R(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise(t=>{let i=async()=>{for(let t of(this._eventListeners.addListeners(),this.plugins))await t.start?.();this._engine.dispatchEvent(d.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout(()=>void i(),this._delay)}))}stop(){if(R(this)&&this.started){for(let t of(this._delayTimeout&&(clearTimeout(this._delayTimeout),delete this._delayTimeout),this._firstStart=!0,this.started=!1,this._eventListeners.removeListeners(),this.pause(),this.particles.clear(),this.canvas.stop(),this.plugins))t.stop?.();this.particleCreatedPlugins.length=0,this.particleDestroyedPlugins.length=0,this.particlePositionPlugins.length=0,this._sourceOptions=this._options,this._engine.dispatchEvent(d.B.containerStopped,{container:this})}}updateActualOptions(){let t=!1;for(let i of this.plugins)i.updateActualOptions&&(t=i.updateActualOptions()||t);return t}_nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+a.Xu/this.fpsLimit||(this._lastFrameTime??=t,!function(t,i,e=a.z$,s=!1){t.value=i,t.factor=s?a.z$/e:a.z$*i/a.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>a.Xu))return void this.draw(!1);if(this.canvas.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,S.t)().error("error in animation loop",t)}}}}}]);
1
+ "use strict";(this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[515],{5515(t,i,e){e.d(i,{Container:()=>M});var s=e(493),a=e(7157),r=e(1963),n=e(2439),o=e(6720);function h(t,i,e=!1){if(!i)return;let s=t.style,a=new Set;for(let t=0;t<s.length;t++){let i=s.item(t);i&&a.add(i)}for(let t=0;t<i.length;t++){let e=i.item(t);e&&a.add(e)}for(let t of a){let a=i.getPropertyValue(t);a?s.setProperty(t,a,e?"important":""):s.removeProperty(t)}}class l{container;element;size;zoom=a.Pf;_canvasClearPlugins;_canvasPaintPlugins;_canvasSettings;_clearDrawPlugins;_colorPlugins;_context;_drawParticlePlugins;_drawParticlesCleanupPlugins;_drawParticlesSetupPlugins;_drawPlugins;_drawSettingsCleanupPlugins;_drawSettingsSetupPlugins;_engine;_generated;_mutationObserver;_originalStyle;_pointerEvents;_postDrawUpdaters;_preDrawUpdaters;_resizePlugins;_reusableColorStyles={};_reusablePluginColors=[void 0,void 0];_reusableTransform={};_standardSize;_zoomCenter;constructor(t,i){this.container=t,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._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this._pointerEvents="none"}get settings(){return this._canvasSettings}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw(t=>{(0,r.IU)(t,this.size)})}clear(){let t=!1;for(let i of this._canvasClearPlugins)if(t=i.canvasClear?.()??!1)break;t||this.canvasClear()}destroy(){if(this.stop(),this._generated){let t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[]}draw(t){let i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;let e=t.getRadius();if(e<=a.w2)return;let s=t.getFillColor(),n=t.getStrokeColor()??s,[h,l]=this._getPluginParticleColors(t);if(h??=s,l??=n,!h&&!l)return;let c=this.container,d=t.options.zIndex,p=a.RV-t.zIndexFactor,{opacity:u,strokeOpacity:_}=t.getOpacity(),g=this._reusableTransform,f=this._reusableColorStyles,P=h?(0,o.LC)(h,c.hdr,u):void 0,m=l?(0,o.LC)(l,c.hdr,_):P;g.a=g.b=g.c=g.d=void 0,f.fill=P,f.stroke=m,this.draw(s=>{for(let e of this._drawParticlesSetupPlugins)e.drawParticleSetup?.(s,t,i);for(let a of(this._applyPreDrawUpdaters(s,t,e,u,f,g),(0,r.p0)({container:c,context:s,particle:t,delta:i,colorStyles:f,radius:e*p**d.sizeRate,opacity:u,transform:g}),this._applyPostDrawUpdaters(t),this._drawParticlesCleanupPlugins))a.drawParticleCleanup?.(s,t,i)})}drawParticlePlugins(t,i){this.draw(e=>{for(let s of this._drawParticlePlugins)(0,r.Wb)(e,s,t,i)})}drawParticles(t){let{particles:i}=this.container;this.clear(),i.update(t),this.draw(e=>{for(let i of this._drawSettingsSetupPlugins)i.drawSettingsSetup?.(e,t);for(let i of this._drawPlugins)i.draw?.(e,t);for(let s of(i.drawParticles(t),this._clearDrawPlugins))s.clearDraw?.(e,t);for(let i of this._drawSettingsCleanupPlugins)i.drawSettingsCleanup?.(e,t)})}getZoomCenter(){let t=this.container.retina.pixelRatio,{width:i,height:e}=this.size;return this._zoomCenter?this._zoomCenter:{x:i*a.MX/t,y:e*a.MX/t}}init(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=(0,n.tG)(t=>{for(let i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()}),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver(t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){let{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;let s=e.style,a=(0,o.BN)(this._engine,i.color);a?s.backgroundColor=(0,o.xx)(a,t.hdr,i.opacity):s.backgroundColor="",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){for(let t of(this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesSetupPlugins=[],this._drawParticlesCleanupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this.container.plugins))t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t),t.canvasClear&&this._canvasClearPlugins.push(t),t.canvasPaint&&this._canvasPaintPlugins.push(t),t.drawParticle&&this._drawParticlePlugins.push(t),t.drawParticleSetup&&this._drawParticlesSetupPlugins.push(t),t.drawParticleCleanup&&this._drawParticlesCleanupPlugins.push(t),t.draw&&this._drawPlugins.push(t),t.drawSettingsSetup&&this._drawSettingsSetupPlugins.push(t),t.drawSettingsCleanup&&this._drawSettingsCleanupPlugins.push(t),t.clearDraw&&this._clearDrawPlugins.push(t)}initUpdaters(){for(let t of(this._preDrawUpdaters=[],this._postDrawUpdaters=[],this.container.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();let i=this.container;this._generated=a.eb in t.dataset?"true"===t.dataset[a.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,n.td)(this.element.style);let e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;let s=this.container.retina.pixelRatio,r=this.size;t.height=r.height=e.height*s,t.width=r.width=e.width*s;let o=(0,n.lV)("(color-gamut: p3)");this._canvasSettings={alpha:!0,colorSpace:o?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1},this._context=this.element.getContext("2d",this._canvasSettings),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(let i of this._canvasPaintPlugins)if(t=i.canvasPaint?.()??!1)break;t||this.paintBase()}paintBase(t){this.draw(i=>{(0,r.Sn)(i,this.size,t)})}paintImage(t,i){this.draw(e=>{(0,r.Md)(e,this.size,t,i)})}resize(){if(!this.element)return!1;let t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,a={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&a.height===this.element.height&&a.width===this.element.width)return!1;let r={...i};i.height=e.height,i.width=e.width;let n=this.size;return this.element.width=n.width=a.width,this.element.height=n.height=a.height,this.container.started&&t.particles.setResizeFactor({width:i.width/r.width,height:i.height/r.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}setZoom(t,i){this.zoom=t,this._zoomCenter=i}stop(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=void 0,this.draw(t=>{(0,r.IU)(t,this.size)})}async windowResize(){if(!this.element||!this.resize())return;let t=this.container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}_applyPostDrawUpdaters=t=>{for(let i of this._postDrawUpdaters)i.afterDraw?.(t)};_applyPreDrawUpdaters=(t,i,e,s,r,n)=>{for(let o of this._preDrawUpdaters){if(o.getColorStyles){let{fill:a,stroke:n}=o.getColorStyles(i,t,e,s);a&&(r.fill=a),n&&(r.stroke=n)}if(o.getTransformValues){let t=o.getTransformValues(i);for(let i in t)!function(t,i,e){let s=i[e];void 0!==s&&(t[e]=(t[e]??a.zs)*s)}(n,t,i)}o.beforeDraw?.(i)}};_applyResizePlugins=()=>{for(let t of this._resizePlugins)t.resize?.()};_getPluginParticleColors=t=>{let i,e;for(let s of this._colorPlugins)if(!i&&s.particleFillColor&&(i=(0,o.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,o.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors};_initStyle=()=>{let t=this.element,i=this.container.actualOptions;if(t)for(let e in this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle(),i.style){if(!e||!Object.hasOwn(i.style,e))continue;let s=i.style[e];s&&t.style.setProperty(e,s,"important")}};_repairStyle=()=>{let t=this.element;if(!t)return;this._safeMutationObserver(t=>{t.disconnect()}),this._initStyle(),this.initBackground();let i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver(i=>{t instanceof Node&&i.observe(t,{attributes:!0})})};_resetOriginalStyle=()=>{let t=this.element,i=this._originalStyle;t&&i&&h(t,i,!0)};_safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)};_setFullScreenStyle=()=>{let t=this.element;t&&h(t,(0,n.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)}}class c{container;_handlers;_resizeObserver;_resizeTimeout;constructor(t){this.container=t,this._handlers={visibilityChange:()=>{this._handleVisibilityChange()},resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}_handleVisibilityChange=()=>{let t=this.container;t.actualOptions.pauseOnBlur&&((0,n.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))};_handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);let t=async()=>{let t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout(()=>void t(),this.container.actualOptions.resize.delay*a.Xu)};_manageListeners=t=>{let i=this._handlers;this._manageResize(t),(0,n.Kp)(document,a.nK,i.visibilityChange,t,!1)};_manageResize=t=>{let i=this._handlers,e=this.container;if(!e.actualOptions.resize.enable)return;if("u"<typeof ResizeObserver)return void(0,n.Kp)(globalThis,a.NF,i.resize,t);let s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver(t=>{t.find(t=>t.target===s)&&this._handleWindowResize()}),this._resizeObserver.observe(s))}}var d=e(6911),p=e(5872),u=e(1610),_=e(1808),g=e(3702),f=e(3849),P=e(3457),m=e(9875);function y(t){if(!(0,n.hn)(t.outMode,t.checkModes))return;let i=t.radius*a.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class w{container;backColor;bubble;color;destroyed;direction;effect;effectClose;effectData;effectFill;group;id;ignoresResizeRatio;initialPosition;initialVelocity;isRotating;lastPathTime;misplaced;moveCenter;moveDecay;offset;opacity;options;outType;pathDelay;pathGenerator;pathRotation;position;randomIndexData;retina;roll;rotation;shape;shapeClose;shapeData;shapeFill;sides;size;slow;spawning;strokeColor;strokeOpacity;strokeWidth;unbreakable;velocity;zIndexFactor;_cachedOpacityData={opacity:a.hv,strokeOpacity:a.hv};_cachedPosition=_.p.origin;_cachedRotateData={sin:0,cos:0};_cachedTransform={a:1,b:0,c:0,d:1};_engine;constructor(t,i){this.container=i,this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;let i=this.container,e=this.pathGenerator,s=this.shape?i.particles.shapeDrawers.get(this.shape):void 0;for(let e of(s?.particleDestroy?.(this),i.particleDestroyedPlugins))e.particleDestroyed?.(this,t);for(let e of i.particles.updaters)e.particleDestroyed?.(this,t);e?.reset(this),this._engine.dispatchEvent(d.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){let i=this.container.canvas;i.drawParticlePlugins(this,t),i.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:a.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.color))}getMass(){return this.getRadius()**a.dm*Math.PI*a.MX}getOpacity(){let t=this.options.zIndex,i=a.RV-this.zIndexFactor,e=i**t.opacityRate,r=this.bubble.opacity??(0,s.VG)(this.opacity?.value??a.hv),n=this.strokeOpacity??r;return this._cachedOpacityData.opacity=r*e,this._cachedOpacityData.strokeOpacity=n*e,this._cachedOpacityData}getPosition(){return this._cachedPosition.x=this.position.x+this.offset.x,this._cachedPosition.y=this.position.y+this.offset.y,this._cachedPosition.z=this.position.z,this._cachedPosition}getRadius(){return this.bubble.radius??this.size.value}getRotateData(){let t=this.getAngle();return this._cachedRotateData.sin=Math.sin(t),this._cachedRotateData.cos=Math.cos(t),this._cachedRotateData}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.strokeColor))}getTransformData(t){let i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??a.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??a.D_):t.b??a.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??a.D_):t.c??a.Ug.c,this._cachedTransform.d=i.cos*(t.d??a.Ug.d),this._cachedTransform}init(t,i,e,r){var o,h,l,c;let d,p,u,_,g=this.container;this.id=t,this.group=r,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=P.x.normal,this.ignoresResizeRatio=!0;let f=g.retina.pixelRatio,y=g.actualOptions,w=(0,m.y)(this._engine,g,y.particles),v=w.reduceDuplicates,b=w.effect.type,z=w.shape.type;this.effect=(0,n.TA)(b,this.id,v),this.shape=(0,n.TA)(z,this.id,v);let S=w.effect,C=w.shape;if(e){if(e.effect?.type){let t=e.effect.type,i=(0,n.TA)(t,this.id,v);i&&(this.effect=i,S.load(e.effect))}if(e.shape?.type){let t=e.shape.type,i=(0,n.TA)(t,this.id,v);i&&(this.shape=i,C.load(e.shape))}}if(this.effect===a.mR){let t=[...this.container.particles.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===a.mR){let t=[...this.container.particles.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?(o=this.effect,h=this.id,u=S.options[o],(0,n.zw)({close:S.close,fill:S.fill},(0,n.TA)(u,h,v))):void 0,this.shapeData=this.shape?(l=this.shape,c=this.id,_=C.options[l],(0,n.zw)({close:C.close,fill:C.fill},(0,n.TA)(_,c,v))):void 0,w.load(e);let D=this.effectData;D&&w.load(D.particles);let x=this.shapeData;x&&w.load(x.particles),this.effectFill=D?.fill??w.effect.fill,this.effectClose=D?.close??w.effect.close,this.shapeFill=x?.fill??w.shape.fill,this.shapeClose=x?.close??w.shape.close,this.options=w;let R=this.options.move.path;if(this.pathDelay=(0,s.VG)(R.delay.value)*a.Xu,R.generator){let t=this.container.particles.pathGenerators.get(R.generator);!t&&(t=this.container.particles.availablePathGenerators.get(R.generator))&&(this.container.particles.pathGenerators.set(R.generator,t),t.init()),this.pathGenerator=t}g.retina.initParticle(this),this.size=(0,n.Xs)(this.options.size,f),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy(),this.moveDecay=a.WH-(0,s.VG)(this.options.move.decay);let O=g.particles;O.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/g.zLayers,this.sides=24,this.effect&&(d=g.particles.effectDrawers.get(this.effect)),d?.loadEffect&&d.loadEffect(this),this.shape&&(p=g.particles.shapeDrawers.get(this.shape)),p?.loadShape&&p.loadShape(this);let M=p?.getSidesCount;for(let t of(M&&(this.sides=M(this)),this.spawning=!1,O.updaters))t.init(this);for(let t of O.movers)t.init(this);for(let t of(d?.particleInit?.(g,this),p?.particleInit?.(g,this),g.particleCreatedPlugins))t.particleCreated?.(this)}isInsideCanvas(){let t=this.getRadius(),i=this.container.canvas.size,e=this.position;return e.x>=-t&&e.y>=-t&&e.y<=i.height+t&&e.x<=i.width+t}isShowingBack(){if(!this.roll)return!1;let t=this.roll.angle;if(this.roll.horizontal&&this.roll.vertical){let i=t%a.R1,e=i<a.tA?i+a.R1:i;return e>=Math.PI*a.MX&&e<Math.PI*a.Nu*a.MX}if(this.roll.horizontal){let i=(t+Math.PI*a.MX)%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}if(this.roll.vertical){let i=t%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}return!1}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){for(let t of this.container.particles.updaters)t.reset?.(this)}_calcPosition=(t,i)=>{let e=a.rq,r=t?_.p.create(t.x,t.y,i):void 0,n=this.container,o=n.particlePositionPlugins,h=this.options.move.outModes,l=this.getRadius(),c=n.canvas.size,{signal:d}=new AbortController;for(;!d.aborted;){for(let t of o){let e=t.particlePosition?.(r,this);if(e)return _.p.create(e.x,e.y,i)}let t=(0,s.Nx)({size:c,position:r}),d=_.p.create(t.x,t.y,i);this._fixHorizontal(d,l,h.left??h.default),this._fixHorizontal(d,l,h.right??h.default),this._fixVertical(d,l,h.top??h.default),this._fixVertical(d,l,h.bottom??h.default);let p=!0;for(let t of n.particles.checkParticlePositionPlugins)if(!(p=t.checkParticlePosition?.(this,d,e)??!0))break;if(p)return d;e+=a.Eo,r=void 0}return r};_calculateVelocity=()=>{let t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===g.F.inside||i.direction===g.F.outside)return t;let e=(0,s.pu)((0,s.VG)(i.angle.value)),r=(0,s.pu)((0,s.VG)(i.angle.offset)),n={left:r-e*a.MX,right:r+e*a.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(n.left,n.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t};_fixHorizontal=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.x,maxCoord:this.container.canvas.size.width,setCb:i=>t.x+=i,radius:i})};_fixVertical=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.y,maxCoord:this.container.canvas.size.height,setCb:i=>t.y+=i,radius:i})};_getRollColor=t=>t&&this.roll&&(this.backColor||this.roll.alter)&&this.isShowingBack()?this.backColor?this.backColor:this.roll.alter?(0,r.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t;_initPosition=t=>{let i=this.container,e=(0,s.VG)(this.options.zIndex.value),r=this._calcPosition(t,(0,s.qE)(e,a.X_,i.zLayers));if(!r)throw Error("a valid position cannot be found for particle");this.position=r,this.initialPosition=this.position.copy();let o=i.canvas.size;switch(this.moveCenter={...(0,n.E9)(this.options.move.center,o),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case g.F.inside:this.outType=P.x.inside;break;case g.F.outside:this.outType=P.x.outside}this.offset=_.M.origin}}var v=e(2714),b=e(1636);class z{rectangle;capacity;_divided;_points;_subs;constructor(t,i){this.rectangle=t,this.capacity=i,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){let e=[];if(!t.intersects(this.rectangle))return[];for(let a of this._points)!t.contains(a.position)&&(0,s.Yf)(t.position,a.position)>a.particle.getRadius()&&(!i||i(a.particle))||e.push(a.particle);if(this._divided)for(let s of this._subs)e.push(...s.query(t,i));return e}queryCircle(t,i,e){return this.query(new b.jl(t.x,t.y,i),e)}queryRectangle(t,i,e){return this.query(new b.M_(t.x,t.y,i.width,i.height),e)}_subdivide=()=>{let{x:t,y:i}=this.rectangle.position,{width:e,height:s}=this.rectangle.size,{capacity:r}=this;for(let n=0;n<a.Pg;n++){let o=n%a.gd;this._subs.push(new z(new b.M_(t+e*a.MX*o,i+s*a.MX*(Math.round(n*a.MX)-o),e*a.MX,s*a.MX),r))}this._divided=!0}}var S=e(567);let C=t=>{let{height:i,width:e}=t;return new b.M_(a.un*e,a.un*i,a.Rh*e,a.Rh*i)};class D{availablePathGenerators;checkParticlePositionPlugins;effectDrawers;movers;pathGenerators;quadTree;shapeDrawers;updaters;_array;_container;_engine;_groupLimits;_limit;_maxZIndex;_minZIndex;_needsSort;_nextId;_particleResetPlugins;_particleUpdatePlugins;_pool;_postParticleUpdatePlugins;_postUpdatePlugins;_resizeFactor;_updatePlugins;_zArray;constructor(t,i){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._minZIndex=0,this._maxZIndex=0;const e=i.canvas.size;this.quadTree=new z(C(e),a.Kw),this.effectDrawers=new Map,this.movers=[],this.availablePathGenerators=new Map,this.pathGenerators=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}get count(){return this._array.length}addParticle(t,i,e,s){let r=this._container.actualOptions.particles.number.limit.mode,n=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,o=this.count;if(n>a.ou)switch(r){case u.d.delete:{let t=o+a.nq-n;t>a.wM&&this.removeQuantity(t);break}case u.d.wait:if(o>=n)return}try{let a=this._pool.pop()??new w(this._engine,this._container);a.init(this._nextId,t,i,e);let r=!0;if(s&&(r=s(a)),!r)return void this._pool.push(a);return this._array.push(a),this._zArray.push(a),this._nextId++,this._engine.dispatchEvent(d.B.particleAdded,{container:this._container,data:{particle:a}}),a}catch(t){(0,S.t)().warning(`error adding particle: ${t}`)}}clear(){this._array=[],this._zArray=[]}destroy(){let t=this._container;for(let[,i]of this.effectDrawers)i.destroy?.(t);for(let[,i]of this.shapeDrawers)i.destroy?.(t);this._array=[],this._pool.length=0,this._zArray=[],this.effectDrawers=new Map,this.movers=[],this.availablePathGenerators=new Map,this.pathGenerators=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}drawParticles(t){for(let i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}async init(){let t=this._container,i=t.actualOptions;for(let i of(this._minZIndex=0,this._maxZIndex=0,this._needsSort=!1,this.checkParticlePositionPlugins=[],this._updatePlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._particleResetPlugins=[],this._postParticleUpdatePlugins=[],t.plugins))i.redrawInit&&await i.redrawInit(),i.checkParticlePosition&&this.checkParticlePositionPlugins.push(i),i.update&&this._updatePlugins.push(i),i.particleUpdate&&this._particleUpdatePlugins.push(i),i.postUpdate&&this._postUpdatePlugins.push(i),i.particleReset&&this._particleResetPlugins.push(i),i.postParticleUpdate&&this._postParticleUpdatePlugins.push(i);for(let i of(await this.initPlugins(),this.effectDrawers.values()))await i.init?.(t);for(let i of this.shapeDrawers.values())await i.init?.(t);let e=!1;for(let i of t.plugins)if(e=i.particlesInitialization?.()??e)break;if(!e){let t=i.particles,e=t.groups;for(let i in e){let s=e[i];if(s)for(let e=this.count,a=0;a<s.number.value&&e<t.number.value;e++,a++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){let t=this._container;for(let i of(this.effectDrawers=await this._engine.getEffectDrawers(t,!0),this.movers=await this._engine.getMovers(t,!0),this.availablePathGenerators=await this._engine.getPathGenerators(t,!0),this.pathGenerators=new Map,this.shapeDrawers=await this._engine.getShapeDrawers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0),this.pathGenerators.values()))i.init()}push(t,i,e,s){for(let a=0;a<t;a++)this.addParticle(i,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=a.xd,e,s){if(t<a.z9||t>this.count)return;let r=0;for(let a=t;r<i&&a<this.count;a++)this._removeParticle(a,e,s)&&(a--,r++)}removeQuantity(t,i){this.removeAt(a.z9,t,i)}setDensity(){let t=this._container.actualOptions,i=t.particles.groups,e=0;for(let t of this._container.plugins)t.particlesDensityCount&&(e+=t.particlesDensityCount());for(let t in i){let s=i[t];if(!s)continue;let a=(0,m.y)(this._engine,this._container,s);this._applyDensity(a,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._needsSort||=t>=this._maxZIndex||t>this._minZIndex&&t<this._maxZIndex}setResizeFactor(t){this._resizeFactor=t}update(t){let i=this._container,e=new Set;for(let t of(this.quadTree=new z(C(i.canvas.size),a.Kw),this.pathGenerators.values()))t.update();for(let i of this._updatePlugins)i.update?.(t);let s=this._resizeFactor;for(let i of this._array){for(let t of(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._particleResetPlugins))t.particleReset?.(i);for(let e of this._particleUpdatePlugins){if(i.destroyed)break;e.particleUpdate?.(i,t)}for(let e of this.movers)e.isEnabled(i)&&e.move(i,t);if(i.destroyed){e.add(i);continue}this.quadTree.insert(new v.b(i.getPosition(),i))}if(e.size){let t=t=>!e.has(t);for(let i of(this._array=this.filter(t),this._zArray=this._zArray.filter(t),e))this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:i}});this._addToPool(...e)}for(let i of this._postUpdatePlugins)i.postUpdate?.(t);for(let i of this._array){for(let e of this.updaters)e.update(i,t);if(!i.destroyed&&!i.spawning)for(let e of this._postParticleUpdatePlugins)e.postParticleUpdate?.(i,t)}if(delete this._resizeFactor,this._needsSort){let t=this._zArray;t.sort((t,i)=>i.position.z-t.position.z||t.id-i.id);let i=t[a.z9],e=t[t.length-a.K3];if(!i||!e)return;this._maxZIndex=i.position.z,this._minZIndex=e.position.z,this._needsSort=!1}}_addToPool=(...t)=>{this._pool.push(...t)};_applyDensity=(t,i,e,s)=>{let r=t.number;if(!r.density.enable)return void(void 0===e?this._limit=r.limit.value:(s?.number.limit.value??r.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??r.limit.value));let n=this._initDensityFactor(r.density),o=r.value,h=r.limit.value>a.ou?r.limit.value:o,l=Math.min(o,h)*n+i,c=Math.min(this.count,this.filter(t=>t.group===e).length);void 0===e?this._limit=r.limit.value*n:this._groupLimits.set(e,r.limit.value*n),c<l?this.push(Math.abs(l-c),void 0,t,e):c>l&&this.removeQuantity(c-l,e)};_initDensityFactor=t=>{let i=this._container;if(!i.canvas.element||!t.enable)return a.lA;let e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**a.dm)};_removeParticle=(t,i,e)=>{let s=this._array[t];if(!s||s.group!==i)return!1;let r=this._zArray.indexOf(s);return this._array.splice(t,a.LD),this._zArray.splice(r,a.LD),s.destroy(e),this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0}}class x{container;maxSpeed;pixelRatio;reduceFactor;sizeAnimationSpeed;constructor(t){this.container=t,this.pixelRatio=a.$x,this.reduceFactor=a.Zp}init(){let t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:a.$x,this.reduceFactor=a.Zp;let e=this.pixelRatio,r=t.canvas;if(r.element){let t=r.element;r.size.width=t.offsetWidth*e,r.size.height=t.offsetHeight*e}let n=i.particles,o=n.move;this.maxSpeed=(0,s.VG)(o.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(n.size.animation.speed)*e}initParticle(t){let i=t.options,e=this.pixelRatio,a=i.move,r=a.distance,n=t.retina;n.moveDrift=(0,s.VG)(a.drift)*e,n.moveSpeed=(0,s.VG)(a.speed)*e,n.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;let o=n.maxDistance;o.horizontal=void 0!==r.horizontal?r.horizontal*e:void 0,o.vertical=void 0!==r.vertical?r.vertical*e:void 0,n.maxSpeed=(0,s.VG)(a.gravity.maxSpeed)*e}}function R(t){return!t.destroyed}function O(t,i,...e){let s=new p.J(t,i);return(0,m.Z)(s,...e),s}class M{actualOptions;canvas;destroyed;fpsLimit;hdr;id;pageHidden;particleCreatedPlugins;particleDestroyedPlugins;particlePositionPlugins;particles;plugins;retina;started;zLayers;_delay;_delayTimeout;_delta={value:0,factor:0};_drawAnimationFrame;_duration;_engine;_eventListeners;_firstStart;_initialSourceOptions;_lastFrameTime;_lifeTime;_options;_paused;_smooth;_sourceOptions;constructor(t,i,e){this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new x(this),this.canvas=new l(this,this._engine),this.particles=new D(this._engine,this),this.plugins=[],this.particleDestroyedPlugins=[],this.particleCreatedPlugins=[],this.particlePositionPlugins=[],this._options=O(this._engine,this),this.actualOptions=O(this._engine,this),this._eventListeners=new c(this),this._engine.dispatchEvent(d.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&R(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addLifeTime(t){this._lifeTime+=t}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(t=!0){if(R(this)){for(let t of(this.stop(),this.particles.destroy(),this.canvas.destroy(),this.plugins))t.destroy?.();if(this.plugins.length=0,this._engine.clearPlugins(this),this.destroyed=!0,t){let t=this._engine.items,i=t.indexOf(this);i>=a.vF&&t.splice(i,a.JC)}this._engine.dispatchEvent(d.B.containerDestroyed,{container:this})}}draw(t){if(!R(this))return;let i=t,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(let e of this.plugins){if(!e.export)continue;let s=await e.export(t,i);if(s.supported)return s.blob}(0,S.t)().error(`Export plugin with type ${t} not found`)}async init(){if(!R(this))return;let t=new Map;for(let i of this._engine.plugins){let e=await i.getPlugin(this);e.preInit&&await e.preInit(),t.set(i,e)}for(let[i,e]of(await this.particles.initPlugins(),this._options=O(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=O(this._engine,this,this._options),this.plugins.length=0,this.particleDestroyedPlugins.length=0,this.particleCreatedPlugins.length=0,this.particlePositionPlugins.length=0,t))i.needsPlugin(this.actualOptions)&&(this.plugins.push(e),e.particleCreated&&this.particleCreatedPlugins.push(e),e.particleDestroyed&&this.particleDestroyedPlugins.push(e),e.particlePosition&&this.particlePositionPlugins.push(e));this.retina.init(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();let{delay:i,duration:e,fpsLimit:r,hdr:n,smooth:o,zLayers:h}=this.actualOptions;for(let t of(this.hdr=n,this.zLayers=h,this._duration=(0,s.VG)(e)*a.Xu,this._delay=(0,s.VG)(i)*a.Xu,this._lifeTime=0,this.fpsLimit=r>a.DN?r:a.i8,this._smooth=o,this.plugins))await t.init?.();for(let t of(await this.particles.init(),this._engine.dispatchEvent(d.B.containerInit,{container:this}),this.particles.setDensity(),this.plugins))t.particlesSetup?.();this._engine.dispatchEvent(d.B.particlesSetup,{container:this})}pause(){if(R(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(let t of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(d.B.containerPaused,{container:this})}}play(t){if(!R(this))return;let i=this._paused||t;if(this._firstStart&&!this.actualOptions.autoPlay){this._firstStart=!1;return}if(this._paused&&(this._paused=!1),i)for(let t of this.plugins)t.play&&t.play();this._engine.dispatchEvent(d.B.containerPlay,{container:this}),this.draw(i??!1)}async refresh(){if(R(this))return this.stop(),this.start()}async reset(t){if(R(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=O(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=O(this._engine,this,this._options),this.refresh()}async start(){R(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise(t=>{let i=async()=>{for(let t of(this._eventListeners.addListeners(),this.plugins))await t.start?.();this._engine.dispatchEvent(d.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout(()=>void i(),this._delay)}))}stop(){if(R(this)&&this.started){for(let t of(this._delayTimeout&&(clearTimeout(this._delayTimeout),delete this._delayTimeout),this._firstStart=!0,this.started=!1,this._eventListeners.removeListeners(),this.pause(),this.particles.clear(),this.canvas.stop(),this.plugins))t.stop?.();this.particleCreatedPlugins.length=0,this.particleDestroyedPlugins.length=0,this.particlePositionPlugins.length=0,this._sourceOptions=this._options,this._engine.dispatchEvent(d.B.containerStopped,{container:this})}}updateActualOptions(){let t=!1;for(let i of this.plugins)i.updateActualOptions&&(t=i.updateActualOptions()||t);return t}_nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+a.Xu/this.fpsLimit||(this._lastFrameTime??=t,!function(t,i,e=a.z$,s=!1){t.value=i,t.factor=s?a.z$/e:a.z$*i/a.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>a.Xu))return void this.draw(!1);if(this.canvas.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,S.t)().error("error in animation loop",t)}}}}}]);
@@ -1,6 +1,6 @@
1
1
  import { clear, drawParticle, drawParticlePlugin, paintBase, paintImage } from "../Utils/CanvasUtils.js";
2
2
  import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
3
- import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
3
+ import { defaultTransformValue, defaultZoom, generatedAttribute, half, minimumSize, zIndexFactorOffset, } from "./Utils/Constants.js";
4
4
  import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
5
5
  const fColorIndex = 0, sColorIndex = 1;
6
6
  function setTransformValue(factor, newFactor, key) {
@@ -42,6 +42,7 @@ export class Canvas {
42
42
  container;
43
43
  element;
44
44
  size;
45
+ zoom = defaultZoom;
45
46
  _canvasClearPlugins;
46
47
  _canvasPaintPlugins;
47
48
  _canvasSettings;
@@ -66,6 +67,7 @@ export class Canvas {
66
67
  _reusablePluginColors = [undefined, undefined];
67
68
  _reusableTransform = {};
68
69
  _standardSize;
70
+ _zoomCenter;
69
71
  constructor(container, engine) {
70
72
  this.container = container;
71
73
  this._engine = engine;
@@ -220,6 +222,16 @@ export class Canvas {
220
222
  }
221
223
  });
222
224
  }
225
+ getZoomCenter() {
226
+ const pxRatio = this.container.retina.pixelRatio, { width, height } = this.size;
227
+ if (this._zoomCenter) {
228
+ return this._zoomCenter;
229
+ }
230
+ return {
231
+ x: (width * half) / pxRatio,
232
+ y: (height * half) / pxRatio,
233
+ };
234
+ }
223
235
  init() {
224
236
  this._safeMutationObserver(obs => {
225
237
  obs.disconnect();
@@ -419,6 +431,10 @@ export class Canvas {
419
431
  this._pointerEvents = type;
420
432
  this._repairStyle();
421
433
  }
434
+ setZoom(zoomLevel, center) {
435
+ this.zoom = zoomLevel;
436
+ this._zoomCenter = center;
437
+ }
422
438
  stop() {
423
439
  this._safeMutationObserver(obs => {
424
440
  obs.disconnect();
@@ -87,7 +87,7 @@ export class Engine {
87
87
  return this._domArray;
88
88
  }
89
89
  get version() {
90
- return "4.0.0-alpha.22";
90
+ return "4.0.0-alpha.23";
91
91
  }
92
92
  addColorManager(name, manager) {
93
93
  this.colorManagers.set(name, manager);
@@ -7,4 +7,4 @@ export const generatedAttribute = "generated", resizeEvent = "resize", visibilit
7
7
  b: 0,
8
8
  c: 0,
9
9
  d: 1,
10
- }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0;
10
+ }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
@@ -1,4 +1,4 @@
1
- import { lFactor, minStrokeWidth, originPoint } from "../Core/Utils/Constants.js";
1
+ import { defaultZoom, lFactor, minStrokeWidth, originPoint } from "../Core/Utils/Constants.js";
2
2
  import { AlterType } from "../Enums/Types/AlterType.js";
3
3
  export function paintBase(context, dimension, baseColor) {
4
4
  context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
@@ -16,7 +16,10 @@ export function clear(context, dimension) {
16
16
  context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
17
17
  }
18
18
  export function drawParticle(data) {
19
- const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, pos = particle.getPosition(), transformData = particle.getTransformData(transform);
19
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
20
+ x: pos.x,
21
+ y: pos.y,
22
+ };
20
23
  context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
21
24
  if (colorStyles.fill) {
22
25
  context.fillStyle = colorStyles.fill;
@@ -30,13 +33,23 @@ export function drawParticle(data) {
30
33
  context,
31
34
  particle,
32
35
  radius,
36
+ drawRadius: radius * drawScale,
33
37
  opacity,
34
38
  delta,
35
39
  pixelRatio: container.retina.pixelRatio,
36
40
  fill: particle.shapeFill,
37
41
  stroke: strokeWidth > minStrokeWidth || !particle.shapeFill,
38
42
  transformData,
43
+ position: {
44
+ x: pos.x,
45
+ y: pos.y,
46
+ },
47
+ drawPosition,
48
+ drawScale,
39
49
  };
50
+ for (const plugin of container.plugins) {
51
+ plugin.drawParticleTransform?.(drawData);
52
+ }
40
53
  drawBeforeEffect(container, drawData);
41
54
  drawShapeBeforeDraw(container, drawData);
42
55
  drawShape(container, drawData);
@@ -1,6 +1,6 @@
1
1
  import { clear, drawParticle, drawParticlePlugin, paintBase, paintImage } from "../Utils/CanvasUtils.js";
2
2
  import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
3
- import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
3
+ import { defaultTransformValue, defaultZoom, generatedAttribute, half, minimumSize, zIndexFactorOffset, } from "./Utils/Constants.js";
4
4
  import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
5
5
  const fColorIndex = 0, sColorIndex = 1;
6
6
  function setTransformValue(factor, newFactor, key) {
@@ -42,6 +42,7 @@ export class Canvas {
42
42
  container;
43
43
  element;
44
44
  size;
45
+ zoom = defaultZoom;
45
46
  _canvasClearPlugins;
46
47
  _canvasPaintPlugins;
47
48
  _canvasSettings;
@@ -66,6 +67,7 @@ export class Canvas {
66
67
  _reusablePluginColors = [undefined, undefined];
67
68
  _reusableTransform = {};
68
69
  _standardSize;
70
+ _zoomCenter;
69
71
  constructor(container, engine) {
70
72
  this.container = container;
71
73
  this._engine = engine;
@@ -220,6 +222,16 @@ export class Canvas {
220
222
  }
221
223
  });
222
224
  }
225
+ getZoomCenter() {
226
+ const pxRatio = this.container.retina.pixelRatio, { width, height } = this.size;
227
+ if (this._zoomCenter) {
228
+ return this._zoomCenter;
229
+ }
230
+ return {
231
+ x: (width * half) / pxRatio,
232
+ y: (height * half) / pxRatio,
233
+ };
234
+ }
223
235
  init() {
224
236
  this._safeMutationObserver(obs => {
225
237
  obs.disconnect();
@@ -419,6 +431,10 @@ export class Canvas {
419
431
  this._pointerEvents = type;
420
432
  this._repairStyle();
421
433
  }
434
+ setZoom(zoomLevel, center) {
435
+ this.zoom = zoomLevel;
436
+ this._zoomCenter = center;
437
+ }
422
438
  stop() {
423
439
  this._safeMutationObserver(obs => {
424
440
  obs.disconnect();
@@ -87,7 +87,7 @@ export class Engine {
87
87
  return this._domArray;
88
88
  }
89
89
  get version() {
90
- return "4.0.0-alpha.22";
90
+ return "4.0.0-alpha.23";
91
91
  }
92
92
  addColorManager(name, manager) {
93
93
  this.colorManagers.set(name, manager);
@@ -7,4 +7,4 @@ export const generatedAttribute = "generated", resizeEvent = "resize", visibilit
7
7
  b: 0,
8
8
  c: 0,
9
9
  d: 1,
10
- }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0;
10
+ }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
@@ -1,4 +1,4 @@
1
- import { lFactor, minStrokeWidth, originPoint } from "../Core/Utils/Constants.js";
1
+ import { defaultZoom, lFactor, minStrokeWidth, originPoint } from "../Core/Utils/Constants.js";
2
2
  import { AlterType } from "../Enums/Types/AlterType.js";
3
3
  export function paintBase(context, dimension, baseColor) {
4
4
  context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
@@ -16,7 +16,10 @@ export function clear(context, dimension) {
16
16
  context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
17
17
  }
18
18
  export function drawParticle(data) {
19
- const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, pos = particle.getPosition(), transformData = particle.getTransformData(transform);
19
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
20
+ x: pos.x,
21
+ y: pos.y,
22
+ };
20
23
  context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
21
24
  if (colorStyles.fill) {
22
25
  context.fillStyle = colorStyles.fill;
@@ -30,13 +33,23 @@ export function drawParticle(data) {
30
33
  context,
31
34
  particle,
32
35
  radius,
36
+ drawRadius: radius * drawScale,
33
37
  opacity,
34
38
  delta,
35
39
  pixelRatio: container.retina.pixelRatio,
36
40
  fill: particle.shapeFill,
37
41
  stroke: strokeWidth > minStrokeWidth || !particle.shapeFill,
38
42
  transformData,
43
+ position: {
44
+ x: pos.x,
45
+ y: pos.y,
46
+ },
47
+ drawPosition,
48
+ drawScale,
39
49
  };
50
+ for (const plugin of container.plugins) {
51
+ plugin.drawParticleTransform?.(drawData);
52
+ }
40
53
  drawBeforeEffect(container, drawData);
41
54
  drawShapeBeforeDraw(container, drawData);
42
55
  drawShape(container, drawData);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * tsParticles Engine v4.0.0-alpha.22
2
+ * tsParticles Engine v4.0.0-alpha.23
3
3
  * Author: Matteo Bruni
4
4
  * MIT license: https://opensource.org/licenses/MIT
5
5
  * Website: https://particles.js.org/
@@ -25,7 +25,7 @@
25
25
  \*************************************/
26
26
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
27
27
 
28
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Canvas: () => (/* binding */ Canvas)\n/* harmony export */ });\n/* harmony import */ var _Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Utils/CanvasUtils.js */ \"./dist/browser/Utils/CanvasUtils.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Utils/ColorUtils.js */ \"./dist/browser/Utils/ColorUtils.js\");\n\n\n\n\nconst fColorIndex = 0, sColorIndex = 1;\nfunction setTransformValue(factor, newFactor, key) {\n const newValue = newFactor[key];\n if (newValue !== undefined) {\n factor[key] = (factor[key] ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultTransformValue) * newValue;\n }\n}\nfunction setStyle(canvas, style, important = false) {\n if (!style) {\n return;\n }\n const element = canvas, elementStyle = element.style, keys = new Set();\n for(let i = 0; i < elementStyle.length; i++){\n const key = elementStyle.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for(let i = 0; i < style.length; i++){\n const key = style.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for (const key of keys){\n const value = style.getPropertyValue(key);\n if (value) {\n elementStyle.setProperty(key, value, important ? \"important\" : \"\");\n } else {\n elementStyle.removeProperty(key);\n }\n }\n}\nclass Canvas {\n container;\n element;\n size;\n _canvasClearPlugins;\n _canvasPaintPlugins;\n _canvasSettings;\n _clearDrawPlugins;\n _colorPlugins;\n _context;\n _drawParticlePlugins;\n _drawParticlesCleanupPlugins;\n _drawParticlesSetupPlugins;\n _drawPlugins;\n _drawSettingsCleanupPlugins;\n _drawSettingsSetupPlugins;\n _engine;\n _generated;\n _mutationObserver;\n _originalStyle;\n _pointerEvents;\n _postDrawUpdaters;\n _preDrawUpdaters;\n _resizePlugins;\n _reusableColorStyles = {};\n _reusablePluginColors = [\n undefined,\n undefined\n ];\n _reusableTransform = {};\n _standardSize;\n constructor(container, engine){\n this.container = container;\n this._engine = engine;\n this._standardSize = {\n height: 0,\n width: 0\n };\n const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;\n this.size = {\n height: stdSize.height * pxRatio,\n width: stdSize.width * pxRatio\n };\n this._context = null;\n this._generated = false;\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n this._pointerEvents = \"none\";\n }\n get settings() {\n return this._canvasSettings;\n }\n get _fullScreen() {\n return this.container.actualOptions.fullScreen.enable;\n }\n canvasClear() {\n if (!this.container.actualOptions.clear) {\n return;\n }\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n clear() {\n let pluginHandled = false;\n for (const plugin of this._canvasClearPlugins){\n pluginHandled = plugin.canvasClear?.() ?? false;\n if (pluginHandled) {\n break;\n }\n }\n if (pluginHandled) {\n return;\n }\n this.canvasClear();\n }\n destroy() {\n this.stop();\n if (this._generated) {\n const element = this.element;\n element?.remove();\n this.element = undefined;\n } else {\n this._resetOriginalStyle();\n }\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n }\n draw(cb) {\n const ctx = this._context;\n if (!ctx) {\n return;\n }\n return cb(ctx);\n }\n drawParticle(particle, delta) {\n if (particle.spawning || particle.destroyed) {\n return;\n }\n const radius = particle.getRadius();\n if (radius <= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.minimumSize) {\n return;\n }\n const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor() ?? pfColor;\n let [fColor, sColor] = this._getPluginParticleColors(particle);\n fColor ??= pfColor;\n sColor ??= psColor;\n if (!fColor && !sColor) {\n return;\n }\n const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.zIndexFactorOffset - particle.zIndexFactor, { opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(fColor, container.hdr, opacity) : undefined, stroke = sColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(sColor, container.hdr, strokeOpacity) : fill;\n transform.a = transform.b = transform.c = transform.d = undefined;\n colorStyles.fill = fill;\n colorStyles.stroke = stroke;\n this.draw((context)=>{\n for (const plugin of this._drawParticlesSetupPlugins){\n plugin.drawParticleSetup?.(context, particle, delta);\n }\n this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticle)({\n container,\n context,\n particle,\n delta,\n colorStyles,\n radius: radius * zIndexFactor ** zIndexOptions.sizeRate,\n opacity: opacity,\n transform\n });\n this._applyPostDrawUpdaters(particle);\n for (const plugin of this._drawParticlesCleanupPlugins){\n plugin.drawParticleCleanup?.(context, particle, delta);\n }\n });\n }\n drawParticlePlugins(particle, delta) {\n this.draw((ctx)=>{\n for (const plugin of this._drawParticlePlugins){\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticlePlugin)(ctx, plugin, particle, delta);\n }\n });\n }\n drawParticles(delta) {\n const { particles } = this.container;\n this.clear();\n particles.update(delta);\n this.draw((ctx)=>{\n for (const plugin of this._drawSettingsSetupPlugins){\n plugin.drawSettingsSetup?.(ctx, delta);\n }\n for (const plugin of this._drawPlugins){\n plugin.draw?.(ctx, delta);\n }\n particles.drawParticles(delta);\n for (const plugin of this._clearDrawPlugins){\n plugin.clearDraw?.(ctx, delta);\n }\n for (const plugin of this._drawSettingsCleanupPlugins){\n plugin.drawSettingsCleanup?.(ctx, delta);\n }\n });\n }\n init() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMutationObserver)((records)=>{\n for (const record of records){\n if (record.type === \"attributes\" && record.attributeName === \"style\") {\n this._repairStyle();\n }\n }\n });\n this.resize();\n this._initStyle();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n this.initUpdaters();\n this.initPlugins();\n this.paint();\n }\n initBackground() {\n const { container } = this, options = container.actualOptions, background = options.background, element = this.element;\n if (!element) {\n return;\n }\n const elementStyle = element.style, color = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToRgb)(this._engine, background.color);\n if (color) {\n elementStyle.backgroundColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromRgb)(color, container.hdr, background.opacity);\n } else {\n elementStyle.backgroundColor = \"\";\n }\n elementStyle.backgroundImage = background.image || \"\";\n elementStyle.backgroundPosition = background.position || \"\";\n elementStyle.backgroundRepeat = background.repeat || \"\";\n elementStyle.backgroundSize = background.size || \"\";\n }\n initPlugins() {\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n for (const plugin of this.container.plugins){\n if (plugin.resize) {\n this._resizePlugins.push(plugin);\n }\n if (plugin.particleFillColor ?? plugin.particleStrokeColor) {\n this._colorPlugins.push(plugin);\n }\n if (plugin.canvasClear) {\n this._canvasClearPlugins.push(plugin);\n }\n if (plugin.canvasPaint) {\n this._canvasPaintPlugins.push(plugin);\n }\n if (plugin.drawParticle) {\n this._drawParticlePlugins.push(plugin);\n }\n if (plugin.drawParticleSetup) {\n this._drawParticlesSetupPlugins.push(plugin);\n }\n if (plugin.drawParticleCleanup) {\n this._drawParticlesCleanupPlugins.push(plugin);\n }\n if (plugin.draw) {\n this._drawPlugins.push(plugin);\n }\n if (plugin.drawSettingsSetup) {\n this._drawSettingsSetupPlugins.push(plugin);\n }\n if (plugin.drawSettingsCleanup) {\n this._drawSettingsCleanupPlugins.push(plugin);\n }\n if (plugin.clearDraw) {\n this._clearDrawPlugins.push(plugin);\n }\n }\n }\n initUpdaters() {\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n for (const updater of this.container.particles.updaters){\n if (updater.afterDraw) {\n this._postDrawUpdaters.push(updater);\n }\n if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {\n this._preDrawUpdaters.push(updater);\n }\n }\n }\n loadCanvas(canvas) {\n if (this._generated && this.element) {\n this.element.remove();\n }\n const container = this.container;\n this._generated = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute in canvas.dataset ? canvas.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute] === \"true\" : this._generated;\n this.element = canvas;\n this.element.ariaHidden = \"true\";\n this._originalStyle = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.cloneStyle)(this.element.style);\n const standardSize = this._standardSize;\n standardSize.height = canvas.offsetHeight;\n standardSize.width = canvas.offsetWidth;\n const pxRatio = this.container.retina.pixelRatio, retinaSize = this.size;\n canvas.height = retinaSize.height = standardSize.height * pxRatio;\n canvas.width = retinaSize.width = standardSize.width * pxRatio;\n const canSupportHdrQuery = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMatchMedia)(\"(color-gamut: p3)\");\n this._canvasSettings = {\n alpha: true,\n colorSpace: canSupportHdrQuery?.matches && container.hdr ? \"display-p3\" : \"srgb\",\n desynchronized: true,\n willReadFrequently: false\n };\n this._context = this.element.getContext(\"2d\", this._canvasSettings);\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n container.retina.init();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n }\n paint() {\n let handled = false;\n for (const plugin of this._canvasPaintPlugins){\n handled = plugin.canvasPaint?.() ?? false;\n if (handled) {\n break;\n }\n }\n if (handled) {\n return;\n }\n this.paintBase();\n }\n paintBase(baseColor) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintBase)(ctx, this.size, baseColor);\n });\n }\n paintImage(image, opacity) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintImage)(ctx, this.size, image, opacity);\n });\n }\n resize() {\n if (!this.element) {\n return false;\n }\n const container = this.container, currentSize = container.canvas._standardSize, newSize = {\n width: this.element.offsetWidth,\n height: this.element.offsetHeight\n }, pxRatio = container.retina.pixelRatio, retinaSize = {\n width: newSize.width * pxRatio,\n height: newSize.height * pxRatio\n };\n if (newSize.height === currentSize.height && newSize.width === currentSize.width && retinaSize.height === this.element.height && retinaSize.width === this.element.width) {\n return false;\n }\n const oldSize = {\n ...currentSize\n };\n currentSize.height = newSize.height;\n currentSize.width = newSize.width;\n const canvasSize = this.size;\n this.element.width = canvasSize.width = retinaSize.width;\n this.element.height = canvasSize.height = retinaSize.height;\n if (this.container.started) {\n container.particles.setResizeFactor({\n width: currentSize.width / oldSize.width,\n height: currentSize.height / oldSize.height\n });\n }\n return true;\n }\n setPointerEvents(type) {\n const element = this.element;\n if (!element) {\n return;\n }\n this._pointerEvents = type;\n this._repairStyle();\n }\n stop() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = undefined;\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n async windowResize() {\n if (!this.element || !this.resize()) {\n return;\n }\n const container = this.container, needsRefresh = container.updateActualOptions();\n container.particles.setDensity();\n this._applyResizePlugins();\n if (needsRefresh) {\n await container.refresh();\n }\n }\n _applyPostDrawUpdaters = (particle)=>{\n for (const updater of this._postDrawUpdaters){\n updater.afterDraw?.(particle);\n }\n };\n _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform)=>{\n for (const updater of this._preDrawUpdaters){\n if (updater.getColorStyles) {\n const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);\n if (fill) {\n colorStyles.fill = fill;\n }\n if (stroke) {\n colorStyles.stroke = stroke;\n }\n }\n if (updater.getTransformValues) {\n const updaterTransform = updater.getTransformValues(particle);\n for(const key in updaterTransform){\n setTransformValue(transform, updaterTransform, key);\n }\n }\n updater.beforeDraw?.(particle);\n }\n };\n _applyResizePlugins = ()=>{\n for (const plugin of this._resizePlugins){\n plugin.resize?.();\n }\n };\n _getPluginParticleColors = (particle)=>{\n let fColor, sColor;\n for (const plugin of this._colorPlugins){\n if (!fColor && plugin.particleFillColor) {\n fColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleFillColor(particle));\n }\n if (!sColor && plugin.particleStrokeColor) {\n sColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleStrokeColor(particle));\n }\n if (fColor && sColor) {\n break;\n }\n }\n this._reusablePluginColors[fColorIndex] = fColor;\n this._reusablePluginColors[sColorIndex] = sColor;\n return this._reusablePluginColors;\n };\n _initStyle = ()=>{\n const element = this.element, options = this.container.actualOptions;\n if (!element) {\n return;\n }\n if (this._fullScreen) {\n this._setFullScreenStyle();\n } else {\n this._resetOriginalStyle();\n }\n for(const key in options.style){\n if (!key || !Object.hasOwn(options.style, key)) {\n continue;\n }\n const value = options.style[key];\n if (!value) {\n continue;\n }\n element.style.setProperty(key, value, \"important\");\n }\n };\n _repairStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n this._safeMutationObserver((observer)=>{\n observer.disconnect();\n });\n this._initStyle();\n this.initBackground();\n const pointerEvents = this._pointerEvents;\n element.style.pointerEvents = pointerEvents;\n element.setAttribute(\"pointer-events\", pointerEvents);\n this._safeMutationObserver((observer)=>{\n if (!(element instanceof Node)) {\n return;\n }\n observer.observe(element, {\n attributes: true\n });\n });\n };\n _resetOriginalStyle = ()=>{\n const element = this.element, originalStyle = this._originalStyle;\n if (!element || !originalStyle) {\n return;\n }\n setStyle(element, originalStyle, true);\n };\n _safeMutationObserver = (callback)=>{\n if (!this._mutationObserver) {\n return;\n }\n callback(this._mutationObserver);\n };\n _setFullScreenStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n setStyle(element, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.getFullScreenStyle)(this.container.actualOptions.fullScreen.zIndex), true);\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Canvas.js?\n}");
28
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Canvas: () => (/* binding */ Canvas)\n/* harmony export */ });\n/* harmony import */ var _Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Utils/CanvasUtils.js */ \"./dist/browser/Utils/CanvasUtils.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Utils/ColorUtils.js */ \"./dist/browser/Utils/ColorUtils.js\");\n\n\n\n\nconst fColorIndex = 0, sColorIndex = 1;\nfunction setTransformValue(factor, newFactor, key) {\n const newValue = newFactor[key];\n if (newValue !== undefined) {\n factor[key] = (factor[key] ?? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultTransformValue) * newValue;\n }\n}\nfunction setStyle(canvas, style, important = false) {\n if (!style) {\n return;\n }\n const element = canvas, elementStyle = element.style, keys = new Set();\n for(let i = 0; i < elementStyle.length; i++){\n const key = elementStyle.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for(let i = 0; i < style.length; i++){\n const key = style.item(i);\n if (!key) {\n continue;\n }\n keys.add(key);\n }\n for (const key of keys){\n const value = style.getPropertyValue(key);\n if (value) {\n elementStyle.setProperty(key, value, important ? \"important\" : \"\");\n } else {\n elementStyle.removeProperty(key);\n }\n }\n}\nclass Canvas {\n container;\n element;\n size;\n zoom = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.defaultZoom;\n _canvasClearPlugins;\n _canvasPaintPlugins;\n _canvasSettings;\n _clearDrawPlugins;\n _colorPlugins;\n _context;\n _drawParticlePlugins;\n _drawParticlesCleanupPlugins;\n _drawParticlesSetupPlugins;\n _drawPlugins;\n _drawSettingsCleanupPlugins;\n _drawSettingsSetupPlugins;\n _engine;\n _generated;\n _mutationObserver;\n _originalStyle;\n _pointerEvents;\n _postDrawUpdaters;\n _preDrawUpdaters;\n _resizePlugins;\n _reusableColorStyles = {};\n _reusablePluginColors = [\n undefined,\n undefined\n ];\n _reusableTransform = {};\n _standardSize;\n _zoomCenter;\n constructor(container, engine){\n this.container = container;\n this._engine = engine;\n this._standardSize = {\n height: 0,\n width: 0\n };\n const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;\n this.size = {\n height: stdSize.height * pxRatio,\n width: stdSize.width * pxRatio\n };\n this._context = null;\n this._generated = false;\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n this._pointerEvents = \"none\";\n }\n get settings() {\n return this._canvasSettings;\n }\n get _fullScreen() {\n return this.container.actualOptions.fullScreen.enable;\n }\n canvasClear() {\n if (!this.container.actualOptions.clear) {\n return;\n }\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n clear() {\n let pluginHandled = false;\n for (const plugin of this._canvasClearPlugins){\n pluginHandled = plugin.canvasClear?.() ?? false;\n if (pluginHandled) {\n break;\n }\n }\n if (pluginHandled) {\n return;\n }\n this.canvasClear();\n }\n destroy() {\n this.stop();\n if (this._generated) {\n const element = this.element;\n element?.remove();\n this.element = undefined;\n } else {\n this._resetOriginalStyle();\n }\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n }\n draw(cb) {\n const ctx = this._context;\n if (!ctx) {\n return;\n }\n return cb(ctx);\n }\n drawParticle(particle, delta) {\n if (particle.spawning || particle.destroyed) {\n return;\n }\n const radius = particle.getRadius();\n if (radius <= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.minimumSize) {\n return;\n }\n const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor() ?? pfColor;\n let [fColor, sColor] = this._getPluginParticleColors(particle);\n fColor ??= pfColor;\n sColor ??= psColor;\n if (!fColor && !sColor) {\n return;\n }\n const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.zIndexFactorOffset - particle.zIndexFactor, { opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(fColor, container.hdr, opacity) : undefined, stroke = sColor ? (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromHsl)(sColor, container.hdr, strokeOpacity) : fill;\n transform.a = transform.b = transform.c = transform.d = undefined;\n colorStyles.fill = fill;\n colorStyles.stroke = stroke;\n this.draw((context)=>{\n for (const plugin of this._drawParticlesSetupPlugins){\n plugin.drawParticleSetup?.(context, particle, delta);\n }\n this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticle)({\n container,\n context,\n particle,\n delta,\n colorStyles,\n radius: radius * zIndexFactor ** zIndexOptions.sizeRate,\n opacity: opacity,\n transform\n });\n this._applyPostDrawUpdaters(particle);\n for (const plugin of this._drawParticlesCleanupPlugins){\n plugin.drawParticleCleanup?.(context, particle, delta);\n }\n });\n }\n drawParticlePlugins(particle, delta) {\n this.draw((ctx)=>{\n for (const plugin of this._drawParticlePlugins){\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.drawParticlePlugin)(ctx, plugin, particle, delta);\n }\n });\n }\n drawParticles(delta) {\n const { particles } = this.container;\n this.clear();\n particles.update(delta);\n this.draw((ctx)=>{\n for (const plugin of this._drawSettingsSetupPlugins){\n plugin.drawSettingsSetup?.(ctx, delta);\n }\n for (const plugin of this._drawPlugins){\n plugin.draw?.(ctx, delta);\n }\n particles.drawParticles(delta);\n for (const plugin of this._clearDrawPlugins){\n plugin.clearDraw?.(ctx, delta);\n }\n for (const plugin of this._drawSettingsCleanupPlugins){\n plugin.drawSettingsCleanup?.(ctx, delta);\n }\n });\n }\n getZoomCenter() {\n const pxRatio = this.container.retina.pixelRatio, { width, height } = this.size;\n if (this._zoomCenter) {\n return this._zoomCenter;\n }\n return {\n x: width * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.half / pxRatio,\n y: height * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.half / pxRatio\n };\n }\n init() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMutationObserver)((records)=>{\n for (const record of records){\n if (record.type === \"attributes\" && record.attributeName === \"style\") {\n this._repairStyle();\n }\n }\n });\n this.resize();\n this._initStyle();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n this.initUpdaters();\n this.initPlugins();\n this.paint();\n }\n initBackground() {\n const { container } = this, options = container.actualOptions, background = options.background, element = this.element;\n if (!element) {\n return;\n }\n const elementStyle = element.style, color = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToRgb)(this._engine, background.color);\n if (color) {\n elementStyle.backgroundColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.getStyleFromRgb)(color, container.hdr, background.opacity);\n } else {\n elementStyle.backgroundColor = \"\";\n }\n elementStyle.backgroundImage = background.image || \"\";\n elementStyle.backgroundPosition = background.position || \"\";\n elementStyle.backgroundRepeat = background.repeat || \"\";\n elementStyle.backgroundSize = background.size || \"\";\n }\n initPlugins() {\n this._resizePlugins = [];\n this._colorPlugins = [];\n this._canvasClearPlugins = [];\n this._canvasPaintPlugins = [];\n this._clearDrawPlugins = [];\n this._drawParticlePlugins = [];\n this._drawParticlesSetupPlugins = [];\n this._drawParticlesCleanupPlugins = [];\n this._drawPlugins = [];\n this._drawSettingsSetupPlugins = [];\n this._drawSettingsCleanupPlugins = [];\n for (const plugin of this.container.plugins){\n if (plugin.resize) {\n this._resizePlugins.push(plugin);\n }\n if (plugin.particleFillColor ?? plugin.particleStrokeColor) {\n this._colorPlugins.push(plugin);\n }\n if (plugin.canvasClear) {\n this._canvasClearPlugins.push(plugin);\n }\n if (plugin.canvasPaint) {\n this._canvasPaintPlugins.push(plugin);\n }\n if (plugin.drawParticle) {\n this._drawParticlePlugins.push(plugin);\n }\n if (plugin.drawParticleSetup) {\n this._drawParticlesSetupPlugins.push(plugin);\n }\n if (plugin.drawParticleCleanup) {\n this._drawParticlesCleanupPlugins.push(plugin);\n }\n if (plugin.draw) {\n this._drawPlugins.push(plugin);\n }\n if (plugin.drawSettingsSetup) {\n this._drawSettingsSetupPlugins.push(plugin);\n }\n if (plugin.drawSettingsCleanup) {\n this._drawSettingsCleanupPlugins.push(plugin);\n }\n if (plugin.clearDraw) {\n this._clearDrawPlugins.push(plugin);\n }\n }\n }\n initUpdaters() {\n this._preDrawUpdaters = [];\n this._postDrawUpdaters = [];\n for (const updater of this.container.particles.updaters){\n if (updater.afterDraw) {\n this._postDrawUpdaters.push(updater);\n }\n if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {\n this._preDrawUpdaters.push(updater);\n }\n }\n }\n loadCanvas(canvas) {\n if (this._generated && this.element) {\n this.element.remove();\n }\n const container = this.container;\n this._generated = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute in canvas.dataset ? canvas.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_2__.generatedAttribute] === \"true\" : this._generated;\n this.element = canvas;\n this.element.ariaHidden = \"true\";\n this._originalStyle = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.cloneStyle)(this.element.style);\n const standardSize = this._standardSize;\n standardSize.height = canvas.offsetHeight;\n standardSize.width = canvas.offsetWidth;\n const pxRatio = this.container.retina.pixelRatio, retinaSize = this.size;\n canvas.height = retinaSize.height = standardSize.height * pxRatio;\n canvas.width = retinaSize.width = standardSize.width * pxRatio;\n const canSupportHdrQuery = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeMatchMedia)(\"(color-gamut: p3)\");\n this._canvasSettings = {\n alpha: true,\n colorSpace: canSupportHdrQuery?.matches && container.hdr ? \"display-p3\" : \"srgb\",\n desynchronized: true,\n willReadFrequently: false\n };\n this._context = this.element.getContext(\"2d\", this._canvasSettings);\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n container.retina.init();\n this.initBackground();\n this._safeMutationObserver((obs)=>{\n if (!this.element || !(this.element instanceof Node)) {\n return;\n }\n obs.observe(this.element, {\n attributes: true\n });\n });\n }\n paint() {\n let handled = false;\n for (const plugin of this._canvasPaintPlugins){\n handled = plugin.canvasPaint?.() ?? false;\n if (handled) {\n break;\n }\n }\n if (handled) {\n return;\n }\n this.paintBase();\n }\n paintBase(baseColor) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintBase)(ctx, this.size, baseColor);\n });\n }\n paintImage(image, opacity) {\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.paintImage)(ctx, this.size, image, opacity);\n });\n }\n resize() {\n if (!this.element) {\n return false;\n }\n const container = this.container, currentSize = container.canvas._standardSize, newSize = {\n width: this.element.offsetWidth,\n height: this.element.offsetHeight\n }, pxRatio = container.retina.pixelRatio, retinaSize = {\n width: newSize.width * pxRatio,\n height: newSize.height * pxRatio\n };\n if (newSize.height === currentSize.height && newSize.width === currentSize.width && retinaSize.height === this.element.height && retinaSize.width === this.element.width) {\n return false;\n }\n const oldSize = {\n ...currentSize\n };\n currentSize.height = newSize.height;\n currentSize.width = newSize.width;\n const canvasSize = this.size;\n this.element.width = canvasSize.width = retinaSize.width;\n this.element.height = canvasSize.height = retinaSize.height;\n if (this.container.started) {\n container.particles.setResizeFactor({\n width: currentSize.width / oldSize.width,\n height: currentSize.height / oldSize.height\n });\n }\n return true;\n }\n setPointerEvents(type) {\n const element = this.element;\n if (!element) {\n return;\n }\n this._pointerEvents = type;\n this._repairStyle();\n }\n setZoom(zoomLevel, center) {\n this.zoom = zoomLevel;\n this._zoomCenter = center;\n }\n stop() {\n this._safeMutationObserver((obs)=>{\n obs.disconnect();\n });\n this._mutationObserver = undefined;\n this.draw((ctx)=>{\n (0,_Utils_CanvasUtils_js__WEBPACK_IMPORTED_MODULE_0__.clear)(ctx, this.size);\n });\n }\n async windowResize() {\n if (!this.element || !this.resize()) {\n return;\n }\n const container = this.container, needsRefresh = container.updateActualOptions();\n container.particles.setDensity();\n this._applyResizePlugins();\n if (needsRefresh) {\n await container.refresh();\n }\n }\n _applyPostDrawUpdaters = (particle)=>{\n for (const updater of this._postDrawUpdaters){\n updater.afterDraw?.(particle);\n }\n };\n _applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform)=>{\n for (const updater of this._preDrawUpdaters){\n if (updater.getColorStyles) {\n const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);\n if (fill) {\n colorStyles.fill = fill;\n }\n if (stroke) {\n colorStyles.stroke = stroke;\n }\n }\n if (updater.getTransformValues) {\n const updaterTransform = updater.getTransformValues(particle);\n for(const key in updaterTransform){\n setTransformValue(transform, updaterTransform, key);\n }\n }\n updater.beforeDraw?.(particle);\n }\n };\n _applyResizePlugins = ()=>{\n for (const plugin of this._resizePlugins){\n plugin.resize?.();\n }\n };\n _getPluginParticleColors = (particle)=>{\n let fColor, sColor;\n for (const plugin of this._colorPlugins){\n if (!fColor && plugin.particleFillColor) {\n fColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleFillColor(particle));\n }\n if (!sColor && plugin.particleStrokeColor) {\n sColor = (0,_Utils_ColorUtils_js__WEBPACK_IMPORTED_MODULE_3__.rangeColorToHsl)(this._engine, plugin.particleStrokeColor(particle));\n }\n if (fColor && sColor) {\n break;\n }\n }\n this._reusablePluginColors[fColorIndex] = fColor;\n this._reusablePluginColors[sColorIndex] = sColor;\n return this._reusablePluginColors;\n };\n _initStyle = ()=>{\n const element = this.element, options = this.container.actualOptions;\n if (!element) {\n return;\n }\n if (this._fullScreen) {\n this._setFullScreenStyle();\n } else {\n this._resetOriginalStyle();\n }\n for(const key in options.style){\n if (!key || !Object.hasOwn(options.style, key)) {\n continue;\n }\n const value = options.style[key];\n if (!value) {\n continue;\n }\n element.style.setProperty(key, value, \"important\");\n }\n };\n _repairStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n this._safeMutationObserver((observer)=>{\n observer.disconnect();\n });\n this._initStyle();\n this.initBackground();\n const pointerEvents = this._pointerEvents;\n element.style.pointerEvents = pointerEvents;\n element.setAttribute(\"pointer-events\", pointerEvents);\n this._safeMutationObserver((observer)=>{\n if (!(element instanceof Node)) {\n return;\n }\n observer.observe(element, {\n attributes: true\n });\n });\n };\n _resetOriginalStyle = ()=>{\n const element = this.element, originalStyle = this._originalStyle;\n if (!element || !originalStyle) {\n return;\n }\n setStyle(element, originalStyle, true);\n };\n _safeMutationObserver = (callback)=>{\n if (!this._mutationObserver) {\n return;\n }\n callback(this._mutationObserver);\n };\n _setFullScreenStyle = ()=>{\n const element = this.element;\n if (!element) {\n return;\n }\n setStyle(element, (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.getFullScreenStyle)(this.container.actualOptions.fullScreen.zIndex), true);\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Canvas.js?\n}");
29
29
 
30
30
  /***/ },
31
31
 
@@ -1,6 +1,6 @@
1
1
  import { clear, drawParticle, drawParticlePlugin, paintBase, paintImage } from "../Utils/CanvasUtils.js";
2
2
  import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
3
- import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
3
+ import { defaultTransformValue, defaultZoom, generatedAttribute, half, minimumSize, zIndexFactorOffset, } from "./Utils/Constants.js";
4
4
  import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
5
5
  const fColorIndex = 0, sColorIndex = 1;
6
6
  function setTransformValue(factor, newFactor, key) {
@@ -42,6 +42,7 @@ export class Canvas {
42
42
  container;
43
43
  element;
44
44
  size;
45
+ zoom = defaultZoom;
45
46
  _canvasClearPlugins;
46
47
  _canvasPaintPlugins;
47
48
  _canvasSettings;
@@ -66,6 +67,7 @@ export class Canvas {
66
67
  _reusablePluginColors = [undefined, undefined];
67
68
  _reusableTransform = {};
68
69
  _standardSize;
70
+ _zoomCenter;
69
71
  constructor(container, engine) {
70
72
  this.container = container;
71
73
  this._engine = engine;
@@ -220,6 +222,16 @@ export class Canvas {
220
222
  }
221
223
  });
222
224
  }
225
+ getZoomCenter() {
226
+ const pxRatio = this.container.retina.pixelRatio, { width, height } = this.size;
227
+ if (this._zoomCenter) {
228
+ return this._zoomCenter;
229
+ }
230
+ return {
231
+ x: (width * half) / pxRatio,
232
+ y: (height * half) / pxRatio,
233
+ };
234
+ }
223
235
  init() {
224
236
  this._safeMutationObserver(obs => {
225
237
  obs.disconnect();
@@ -419,6 +431,10 @@ export class Canvas {
419
431
  this._pointerEvents = type;
420
432
  this._repairStyle();
421
433
  }
434
+ setZoom(zoomLevel, center) {
435
+ this.zoom = zoomLevel;
436
+ this._zoomCenter = center;
437
+ }
422
438
  stop() {
423
439
  this._safeMutationObserver(obs => {
424
440
  obs.disconnect();
@@ -87,7 +87,7 @@ export class Engine {
87
87
  return this._domArray;
88
88
  }
89
89
  get version() {
90
- return "4.0.0-alpha.22";
90
+ return "4.0.0-alpha.23";
91
91
  }
92
92
  addColorManager(name, manager) {
93
93
  this.colorManagers.set(name, manager);
@@ -7,4 +7,4 @@ export const generatedAttribute = "generated", resizeEvent = "resize", visibilit
7
7
  b: 0,
8
8
  c: 0,
9
9
  d: 1,
10
- }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0;
10
+ }, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
@@ -1,4 +1,4 @@
1
- import { lFactor, minStrokeWidth, originPoint } from "../Core/Utils/Constants.js";
1
+ import { defaultZoom, lFactor, minStrokeWidth, originPoint } from "../Core/Utils/Constants.js";
2
2
  import { AlterType } from "../Enums/Types/AlterType.js";
3
3
  export function paintBase(context, dimension, baseColor) {
4
4
  context.fillStyle = baseColor ?? "rgba(0,0,0,0)";
@@ -16,7 +16,10 @@ export function clear(context, dimension) {
16
16
  context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
17
17
  }
18
18
  export function drawParticle(data) {
19
- const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, pos = particle.getPosition(), transformData = particle.getTransformData(transform);
19
+ const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
20
+ x: pos.x,
21
+ y: pos.y,
22
+ };
20
23
  context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
21
24
  if (colorStyles.fill) {
22
25
  context.fillStyle = colorStyles.fill;
@@ -30,13 +33,23 @@ export function drawParticle(data) {
30
33
  context,
31
34
  particle,
32
35
  radius,
36
+ drawRadius: radius * drawScale,
33
37
  opacity,
34
38
  delta,
35
39
  pixelRatio: container.retina.pixelRatio,
36
40
  fill: particle.shapeFill,
37
41
  stroke: strokeWidth > minStrokeWidth || !particle.shapeFill,
38
42
  transformData,
43
+ position: {
44
+ x: pos.x,
45
+ y: pos.y,
46
+ },
47
+ drawPosition,
48
+ drawScale,
39
49
  };
50
+ for (const plugin of container.plugins) {
51
+ plugin.drawParticleTransform?.(drawData);
52
+ }
40
53
  drawBeforeEffect(container, drawData);
41
54
  drawShapeBeforeDraw(container, drawData);
42
55
  drawShape(container, drawData);