functioninit(){canvas=document.getElementById('world');if(canvas&&canvas.getContext){context=canvas.getContext('2d');createParticles();windowResizeHandler();setInterval(loop,1000/60);}}functionloop(){if(mouseIsDown){// Scale upward to the max scale
RADIUS_SCALE+=(RADIUS_SCALE_MAX-RADIUS_SCALE)*(0.02);}else{// Scale downward to the min scale
RADIUS_SCALE-=(RADIUS_SCALE-RADIUS_SCALE_MIN)*(0.02);}RADIUS_SCALE=Math.min(RADIUS_SCALE,RADIUS_SCALE_MAX);// Fade out the lines slowly by drawing a rectangle over the entire canvas
context.fillStyle='rgba(0,0,0,0.05)';context.fillRect(0,0,context.canvas.width,context.canvas.height);for(i=0,len=particles.length;i<len;i++){varparticle=particles[i];varlp={x:particle.position.x,y:particle.position.y};// Offset the angle to keep the spin going
particle.angle+=particle.speed;// Follow mouse with some lag
particle.shift.x+=(mouseX-particle.shift.x)*(particle.speed);particle.shift.y+=(mouseY-particle.shift.y)*(particle.speed);// Apply position
particle.position.x=particle.shift.x+Math.cos(i+particle.angle)*(particle.orbit*RADIUS_SCALE);particle.position.y=particle.shift.y+Math.sin(i+particle.angle)*(particle.orbit*RADIUS_SCALE);// Limit to screen bounds
particle.position.x=Math.max(Math.min(particle.position.x,SCREEN_WIDTH),0);particle.position.y=Math.max(Math.min(particle.position.y,SCREEN_HEIGHT),0);particle.size+=(particle.targetSize-particle.size)*0.05;// If we're at the target size, set a new one. Think of it like a regular day at work.
if(Math.round(particle.size)==Math.round(particle.targetSize)){particle.targetSize=1+Math.random()*7;}context.beginPath();context.fillStyle=particle.fillColor;context.strokeStyle=particle.fillColor;context.lineWidth=particle.size;context.moveTo(lp.x,lp.y);context.lineTo(particle.position.x,particle.position.y);context.stroke();context.arc(particle.position.x,particle.position.y,particle.size/2,0,Math.PI*2,true);context.fill();}}