var _r,_g,_b,_a=.5,rad=100,particleList,system,particleColor,systemSize=3,lots=true,pcMode=false,fadeStage=false,grayScale=true,dx=2,dy=4,lineColor='rgba(100,100,100,.1)',particleCount=0,particleList={};function draw(){if(system){system.update()}}function initParticleSystem(){system=new ParticleSystem();system.init(systemSize)}function ParticleSystem(){}ParticleSystem.prototype.init=function(_systemSize){this.list=[];var i=0;for(i=0;i<_systemSize+1;i++){this.createParticle()}};ParticleSystem.prototype.createParticle=function(){var newParticle=new Particle();newParticle.init();this.list.push(newParticle)};ParticleSystem.prototype.update=function(){var i=0;for(i=0;i<systemSize-1;i++){this.list[i].draw()}};function Particle(){}Particle.prototype.init=function(){setColor(this);this.x=Math.random()*WIDTH;this.y=Math.random()*HEIGHT;this.vel=Math.random()*5+1;this.ang=Math.random()*(Math.PI);this.diameter=Math.random()*5+1;this.oldX=this.x;this.oldY=this.y;this.speedModX=Math.random()*20+8;this.speedModY=Math.random()*20+8;this.speedModTargX=Math.random()*3+2;this.speedModTargY=Math.random()*3+2;this.maxSpeed=Math.random()*20+5;this.speedX=0;this.speedY=0};Particle.prototype.draw=function(){ctx.fillStyle=this.color;var _x=this.x;var _y=this.y;var _d=this.diameter;var _vel=this.vel;var _ang=this.ang;var _smx=this.speedModX;var _smy=this.speedModY;var _sX=this.speedX;var _sY=this.speedY;this.oldX=_x;this.oldY=_y;var targSpeedX=(cursorX-_x)/this.speedModTargX;var targSpeedY=(cursorY-_y)/this.speedModTargY;var maxSpeed=this.maxSpeed;if(Math.abs(_sX)>maxSpeed){if(_sX>0){_sX=maxSpeed}else{_sX=0-maxSpeed}}if(Math.abs(_sY)>maxSpeed){if(_sY>0){_sY=maxSpeed}else{_sY=0-maxSpeed}}_sX+=(targSpeedX-_sX)/_smx;_sY+=(targSpeedY-_sY)/_smy;_x+=_sX;_y+=_sY;this.speedX=_sX;this.speedY=_sY;this.x=_x;this.y=_y;this.vel=_vel;this.ang=_ang;particleLine(this)};function particleLine(p){var _x=p.x;var _y=p.y;var _oldX=p.oldX;var _oldY=p.oldY;ctx.lineWidth=.5;if(p.colorTint>5){ctx.lineWidth=1.2}ctx.strokeStyle=p.color;ctx.beginPath();ctx.moveTo(_oldX,_oldY);ctx.lineTo(_x,_y);ctx.stroke()}function setColor(targ){if(grayScale){var gryV=Math.round(Math.random()*100);var gryA=(Math.random()*.8);targ.color='rgba('+gryV+','+gryV+','+gryV+','+gryA+')'}}
