Skip to content

Instantly share code, notes, and snippets.

@guillaumebort
Created September 5, 2010 19:33
Show Gist options
  • Save guillaumebort/566259 to your computer and use it in GitHub Desktop.
Save guillaumebort/566259 to your computer and use it in GitHub Desktop.
c=document.getElementById('c');g=[];c.width=c.height=500;d=c.getContext('2d');h=20;w=40;m=10;z=100;v=50;k=10;_=.9375;a=Math.ceil;e=function(a,b,c){d[c?'moveTo':'lineTo'](a,b)};u=function(t,b,c,n){p=2.75;q=p*p;return n?c*(t/=v)*t*t+b:((t/=v)<(1/p)?c*(q*t*t)+b:(t<(2/p)?c*(q*(t-=(1.5/p))*t+p-2)+b:(t<(2.5/p)?c*(q*(t-=(2.25/p))*t+_)+b:c*(q*(t-=1)*t+_)+b)))};$=function(){d.clearRect(0,0,500,500);for(j=0;j<9;j++){for(i=0;i<9;i++){x=i*w+((9-j)*h)-(i*h)+45;y=j*m+z+(i*m);try{l=g[i][j];if(l++){y=l<v?u(l,y,-v,1):u(l-v,y-v,v);g[i][j]=l==z?0:l}}catch(e){}d.beginPath();e(x+h,y+h,1);e(x+h,y+z);e(x+w,y+k,1);e(x+w,y+90);e(x+h,y+z);e(x,y+90);e(x,y+k);d.fillStyle='rgba(100,'+a(255-16*i)+','+a(255-16*j)+',.9)';d.fill();d.stroke();d.beginPath();e(x,y+k,1);e(x+h,y);e(x+w,y+k);e(x+h,y+h);e(x,y+k);d.fillStyle='rgba(35,'+a(190-16*i)+','+a(190-16*j)+',.9)';d.fill();d.stroke()}}};c.onmousemove=function(e){r=e.clientX-8;s=e.clientY-8;o=a((r+2*s-485)/w);p=a((r-2*s-85)/-w)-2;if(!g[o])g[o]=[];if(!g[o][p])g[o][p]=h};setInterval($,k)//~gbort~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment