You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
3.6 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{368:function(t,e,i){"use strict";i.r(e),i.d(e,"DefaultOptions",(function(){return a})),i.d(e,"default",(function(){return h}));var s=i(18),n=i.n(s);function r(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function o(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){n()(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}const a={maxCount:150,speed:3,frameInterval:15,alpha:1,gradient:!1};class h{constructor(t){n()(this,"options",void 0),n()(this,"context",null),n()(this,"supportsAnimationFrame",window.requestAnimationFrame),n()(this,"colors",["rgba(30,144,255,","rgba(107,142,35,","rgba(255,215,0,","rgba(255,192,203,","rgba(106,90,205,","rgba(173,216,230,","rgba(238,130,238,","rgba(152,251,152,","rgba(70,130,180,","rgba(244,164,96,","rgba(210,105,30,","rgba(220,20,60,"]),n()(this,"lastFrameTime",Date.now()),n()(this,"particles",[]),n()(this,"waveAngle",0),n()(this,"isRunning",void 0),n()(this,"start",async(t,e=3e3)=>{if(!t)return;this.context=t.getContext("2d"),this.particles=[];const i=this.options.maxCount;for(;this.particles.length<i;)this.particles.push(this.resetParticle({},t.width,t.height));this.isRunning=!0,this.runAnimation(),e&&window.setTimeout(this.stop,e)}),n()(this,"stop",async()=>{this.isRunning=!1}),n()(this,"resetParticle",(t,e,i)=>(t.color=this.colors[Math.random()*this.colors.length|0]+(this.options.alpha+")"),this.options.gradient?t.color2=this.colors[Math.random()*this.colors.length|0]+(this.options.alpha+")"):t.color2=t.color,t.x=Math.random()*e,t.y=Math.random()*-i,t.diameter=10*Math.random()+5,t.tilt=-10*Math.random(),t.tiltAngleIncrement=.07*Math.random()+.05,t.tiltAngle=Math.random()*Math.PI,t)),n()(this,"runAnimation",()=>{if(this.context&&this.context.canvas)if(0===this.particles.length)this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height);else{const t=Date.now(),e=t-this.lastFrameTime;(!this.supportsAnimationFrame||e>this.options.frameInterval)&&(this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height),this.updateParticles(),this.drawParticles(this.context),this.lastFrameTime=t-e%this.options.frameInterval),requestAnimationFrame(this.runAnimation)}}),n()(this,"drawParticles",t=>{if(!this.context||!this.context.canvas)return;let e,i,s;for(const n of this.particles){if(this.context.beginPath(),t.lineWidth=n.diameter,i=n.x+n.tilt,e=i+n.diameter/2,s=n.y+n.tilt+n.diameter/2,this.options.gradient){const r=t.createLinearGradient(e,n.y,i,s);r.addColorStop(0,n.color),r.addColorStop(1,n.color2),t.strokeStyle=r}else t.strokeStyle=n.color;t.moveTo(e,n.y),t.lineTo(i,s),t.stroke()}}),n()(this,"updateParticles",()=>{if(!this.context||!this.context.canvas)return;const t=this.context.canvas.width,e=this.context.canvas.height;let i;this.waveAngle+=.01;for(let s=0;s<this.particles.length;s++)i=this.particles[s],!this.isRunning&&i.y<-15?i.y=e+100:(i.tiltAngle+=i.tiltAngleIncrement,i.x+=Math.sin(this.waveAngle)-.5,i.y+=.5*(Math.cos(this.waveAngle)+i.diameter+this.options.speed),i.tilt=15*Math.sin(i.tiltAngle)),(i.x>t+20||i.x<-20||i.y>e)&&(this.isRunning&&this.particles.length<=this.options.maxCount?this.resetParticle(i,t,e):(this.particles.splice(s,1),s--))}),this.options=o(o({},a),t)}}}}]);
//# sourceMappingURL=0.js.map