var width=2*document.body.clientWidth,height=2*document.body.clientHeight,canvas=document.getElementById("canvas"),ctx=canvas.getContext("2d"),fps=60,frameTime=1e3/fps,ua=navigator.userAgent,getRandomInt=function(t,e){return Math.floor(Math.random()*(e-t))+t},getDegree=function(t){return t/Math.PI*180},getRadian=function(t){return t*Math.PI/180},getDistance=function(t,e,r,i){var n=t-r,s=e-i;return Math.sqrt(n*n+s*s)},easing=function(t,e,r,i,n){switch(t){case"linear":return i*e/n+r;case"easeInCubic":return e/=n,i*e*e*e+r;case"easeOutCubic":return e/=n,e--,i*(e*e*e+1)+r;case"easeInExpo":return i*Math.pow(2,10*(e/n-1))+r;case"easeOutExpo":return i*(-1*Math.pow(2,-10*e/n)+1)+r}},debounce=function(t,e,r){var i;t.addEventListener(e,function(){clearTimeout(i),i=setTimeout(function(){r()},500)},!1)},canvasResize=function(){width=2*document.body.clientWidth,height=2*document.body.clientHeight,canvas.width=width,canvas.height=height,canvas.style.width=width/2+"px",canvas.style.height=height/2+"px"};debounce(window,"resize",function(){canvasResize()}),canvasResize();var animeObjArr=[],animeObjNum=0,spredObjArr=[],spredObjNum=0,lastTimeRender=+new Date,lastTimeSpredObjPush=+new Date,point={x:width/2,y:height/2},pointSpred={x:0,y:0},baseLength=0,isTouchMove=!1,instance=0,elmInstance=document.getElementById("instanceNum"),resetSize=function(){point.x=width/2,point.y=height/2,baseLength=width>height?height:width};resetSize(),debounce(window,"resize",function(){resetSize()});var animeObj=function(t,e){this.br=getRandomInt(baseLength/80,baseLength/40),this.r=this.br,this.t=0,this.x=t,this.y=e,this.d=500,this.color={r:0,g:0,b:0},this.colorPattern=getRandomInt(0,3),0==this.colorPattern&&(this.color.r=120,this.color.g=210,this.color.b=255),1==this.colorPattern&&(this.color.r=255,this.color.g=120,this.color.b=210),2==this.colorPattern&&(this.color.r=210,this.color.g=255,this.color.b=120),this.o=1};animeObj.prototype.move=function(){this.t+=frameTime,this.r=easing("easeOutExpo",this.t,0,this.br,this.d),this.t>.5*this.d&&(this.o=1-(this.t-.5*this.d)/(.5*this.d))},animeObj.prototype.render=function(){instance++,ctx.beginPath(),ctx.arc(this.x,this.y,this.r,0,Math.PI/180,!0),ctx.fillStyle="rgba("+this.color.r+", "+this.color.g+", "+this.color.b+", "+this.o+")",ctx.fill(),ctx.closePath()},animeObj.prototype.isLast=function(){return this.t>this.d?!0:!1};var spredObj=function(t,e){this.r=0,this.rMin=baseLength/5,this.rMax=baseLength/4,this.t=0,this.x=t,this.y=e,this.d=200,this.objArr=[],this.objNum=0,this.lastTimeObjPush=0};spredObj.prototype.spred=function(){this.t+=frameTime,this.r=easing("linear",this.t,this.rMin,this.rMax-this.rMin,this.d)},spredObj.prototype.constructor=function(){var t=+new Date;if(t-this.lastTimeObjPush>=frameTime&&this.t<=this.d){for(var e=0;30>e;e++){var r=getRandomInt(0,360),i=this.r,n=this.x+Math.cos(getRadian(r))*i,s=this.y+Math.sin(getRadian(r))*i;this.objArr.push(new animeObj(n,s,!0))}this.lastTimeObjPush=+new Date}},spredObj.prototype.render=function(){this.objNum=0;for(var t=this.objArr.length-1;t>=0;t--)this.objArr[t]&&(this.objNum++,this.objArr[t].move(),this.objArr[t].render(),this.objArr[t].isLast()&&delete this.objArr[t])},spredObj.prototype.isLast=function(){return this.t>this.d&&this.objNum<1?!0:!1};var render=function(){instance=0,ctx.clearRect(0,0,width,height),ctx.globalCompositeOperation="lighter",animeObjNum=0;for(var t=0;t=frameTime&&(render(),lastTimeRender=+new Date),t-lastTimeSpredObjPush>=200){var e=getRandomInt(0,width),r=getRandomInt(0,height);spredObjArr.push(new spredObj(e,r)),lastTimeSpredObjPush=+new Date}elmInstance.textContent=instance};renderloop(),document.addEventListener("mousedown",function(t){t.preventDefault(),lastTimeTouchStart=+new Date},!1),document.addEventListener("mouseup",function(t){var e=+new Date;e-lastTimeTouchStart<100&&(pointSpred.x=2*t.clientX,pointSpred.y=2*t.clientY,spredObjArr.push(new spredObj(pointSpred.x,pointSpred.y)))},!1),document.addEventListener("touchstart",function(t){t.preventDefault(),lastTimeTouchStart=+new Date,pointSpred.x=2*t.touches[0].pageX,pointSpred.y=2*t.touches[0].pageY},!1),document.addEventListener("touchend",function(t){t.preventDefault();var e=+new Date;isTouchMove=!1,e-lastTimeTouchStart<100&&spredObjArr.push(new spredObj(pointSpred.x,pointSpred.y))},!1);