lecoffre-back/node_modules/tsparticles-updater-destroy/tsparticles.updater.destroy.min.js
2023-02-17 11:06:01 +01:00

2 lines
4.0 KiB
JavaScript

/*! For license information please see tsparticles.updater.destroy.min.js.LICENSE.txt */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],e);else{var o="object"==typeof exports?e(require("tsparticles-engine")):e(t.window);for(var s in o)("object"==typeof exports?exports:t)[s]=o[s]}}(this,(t=>(()=>{"use strict";var e={961:e=>{e.exports=t}},o={};function s(t){var i=o[t];if(void 0!==i)return i.exports;var n=o[t]={exports:{}};return e[t](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{s.r(i),s.d(i,{loadDestroyUpdater:()=>d});var t=s(961);class e{load(e){e&&(void 0!==e.bottom&&(this.bottom=(0,t.setRangeValue)(e.bottom)),void 0!==e.left&&(this.left=(0,t.setRangeValue)(e.left)),void 0!==e.right&&(this.right=(0,t.setRangeValue)(e.right)),void 0!==e.top&&(this.top=(0,t.setRangeValue)(e.top)))}}class o extends t.ValueWithRandom{constructor(){super(),this.value=3}}class n extends t.ValueWithRandom{constructor(){super(),this.value={min:4,max:9}}}class r{constructor(){this.count=1,this.factor=new o,this.rate=new n,this.sizeOffset=!0}load(e){e&&(void 0!==e.count&&(this.count=e.count),this.factor.load(e.factor),this.rate.load(e.rate),this.particles=(0,t.executeOnSingleOrMultiple)(e.particles,(e=>(0,t.deepExtend)({},e))),void 0!==e.sizeOffset&&(this.sizeOffset=e.sizeOffset))}}class a{constructor(){this.bounds=new e,this.mode="none",this.split=new r}load(t){t&&(t.mode&&(this.mode=t.mode),t.bounds&&this.bounds.load(t.bounds),this.split.load(t.split))}}class l{constructor(t,e){this.engine=t,this.container=e}init(e){const o=this.container,s=e.options.destroy;if(!s)return;e.splitCount=0;const i=s.bounds;e.destroyBounds||(e.destroyBounds={}),i.bottom&&(e.destroyBounds.bottom=(0,t.getRangeValue)(i.bottom)*o.canvas.size.height/100),i.left&&(e.destroyBounds.left=(0,t.getRangeValue)(i.left)*o.canvas.size.width/100),i.right&&(e.destroyBounds.right=(0,t.getRangeValue)(i.right)*o.canvas.size.width/100),i.top&&(e.destroyBounds.top=(0,t.getRangeValue)(i.top)*o.canvas.size.height/100)}isEnabled(t){return!t.destroyed}loadOptions(t,...e){t.destroy||(t.destroy=new a);for(const o of e)t.destroy.load(null==o?void 0:o.destroy)}particleDestroyed(t,e){if(e)return;const o=t.options.destroy;o&&"split"===o.mode&&this.split(t)}update(t){if(!this.isEnabled(t))return;const e=t.getPosition(),o=t.destroyBounds;o&&(void 0!==o.bottom&&e.y>=o.bottom||void 0!==o.left&&e.x<=o.left||void 0!==o.right&&e.x>=o.right||void 0!==o.top&&e.y<=o.top)&&t.destroy()}addSplitParticle(e,o){const s=e.options.destroy;if(!s)return;const i=s.split,n=(0,t.loadParticlesOptions)(this.engine,this.container,e.options),r=(0,t.getValue)(i.factor);n.color.load({value:{hsl:e.getFillColor()}}),n.move.load({center:{x:e.position.x,y:e.position.y,mode:"precise"}}),"number"==typeof n.size.value?n.size.value/=r:(n.size.value.min/=r,n.size.value.max/=r),n.load(o);const a=i.sizeOffset?(0,t.setRangeValue)(-e.size.value,e.size.value):0,l={x:e.position.x+(0,t.randomInRange)(a),y:e.position.y+(0,t.randomInRange)(a)};return this.container.particles.addParticle(l,n,e.group,(o=>{var s;return!(o.size.value<.5)&&(o.velocity.length=(0,t.randomInRange)((0,t.setRangeValue)(e.velocity.length,o.velocity.length)),o.splitCount=(null!==(s=e.splitCount)&&void 0!==s?s:0)+1,o.unbreakable=!0,setTimeout((()=>{o.unbreakable=!1}),500),!0)}))}split(e){const o=e.options.destroy;if(!o)return;const s=o.split;if(s.count>=0&&(void 0===e.splitCount||e.splitCount++>s.count))return;const i=(0,t.getValue)(s.rate),n=(0,t.itemFromSingleOrMultiple)(s.particles);for(let t=0;t<i;t++)this.addSplitParticle(e,n)}}async function d(t){await t.addParticleUpdater("destroy",(e=>new l(t,e)))}})(),i})()));