var canv = document.getElementById("canv"); height="height"; width="width"; canv[height]=400; canv[width]=innerWidth; $=canv.getContext("2d"); //assigning $ variable to canvas (shortcut) $.fillStyle="#000"; $.fillRect(0,0,canv[width], canv[height]); K=9; //K will represent number of lines shooting from origin point A=0.1;//A will be the length - the height of each line. Higher the #, lower the height (small like a loader). N=12; //N is representing the radius of the circle when all lines are formed outward. var t=0, //t is time s=10, //radius of inner circle flag=0; //flow control //the animation pulse = function(){ $.save(); $.translate(canv[width]/2,canv[height]/2); for(var i=0;i50) flag=1; else{ s+=Math.exp(-A*t)*N; t++; } }else{ if(t<0) flag=0; else{ t--; s-=Math.exp(-A*t)*N; } } $.restore(); $.fillStyle="rgba(0,0,0,0.1)"; $.fillRect(0,0,canv[width],canv[height]); }; setInterval(pulse,40);