|
m=Math;R=m.random;P=m.pow;D=c.width=c.height=600;t=12;T=D-t;O=256;l=e=E=N=0;setInterval(function(){if(!E&&(e>=N||L&&e<N&&l--))e=L=0,A=[],A.length=5*++l,N=l*(l+1)/2;a.fillStyle=e<N?"#778":"#eef";a.fillRect(0,0,D,D);a.strokeText(e+"/"+N,9,9);for(i=A.length;i--;)with(A[i]||(A[i]={s:L,d:L,M:40*R()+20,x:L?L.clientX:R()*T+6,y:L?L.clientY:R()*T+6,v:R()*t-6,z:R()*t-6,C:"rgb("+[R()*O|0,R()*O|0,R()*O|0].join()+")",r:6,t:30/l|0}))!d&&A.some(function(b){return b.d&&P(r+b.r,2)>P(x-b.x,2)+P(y-b.y,2)&&(s=d=1,E++,e++)}),s?t?2==s?t--:++r>M&&(s=2):--r||(A.splice(i,1),E--):(x+=v,y+=z,x<r|x+r>D&&(v=-v),y<r|y+r>D&&(z=-z)),a.beginPath(),a.fillStyle=C,a.arc(x,y,r,0,7),a.fill()},50);c.onclick=function(b){L||(L=b,E++,A.push(0))}; |