Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

16 lines (15 sloc) 1.211 kb
<!doctype html>
<html>
<head>
<title>JS1k, 1k demo submission [424]</title>
<meta charset="utf-8" />
</head>
<body>
<canvas id="c"></canvas>
<script>
function r(){for(;;){S=f(x/b);T=f(y/b);if(S<0||S>7||T<0||T>7)return 1E4;if(k[T]&1<<7-S)break;x+=I;y+=J}return e(e(n-x)/C*D)}Z=1;function U(R,V,W,X,Y){c.fillStyle="rgb("+R+","+R+","+R+")";c.fillRect(V,W,X,Y)}
function h(){if(Z){a=320;b=64;w=document.getElementById("c");w.width=w.height=a;c=w.getContext("2d");m=Math;t=m.tan;d=m.cos;f=m.floor;e=m.abs;g=m.random;j=0.017453;k=[255,197,129,135,131,163,129,255];l=30;n=o=p=q=224;u=s=0;E=90;F=180;G=270;H=360;Z=0}U(0,0,0,a,a);v=s+l;for(i=0;i<a;i++){if(v<0)v=H+v;if(v>=H)v-=H;A=v*j;B=t(A);C=d(A);D=d((s-v)*j);y=f(o/b)*b;y=v<F?y-1:y+b;J=v<F?-b:b;x=n+(o-y)/B;I=b/B;if(v>F)I*=-1;K=r();x=f(n/b)*b;x=v>E&&v<G?x-1:x+b;I=v>E&&v<G?-b:b;y=o+(n-x)*B;J=b*B;if(v>G||v<E)J*=-1;L=
r();M=K<L?K:L;N=b/M*a/2/t(l*j);z=f(255-M/1.5);U(z,i,a/2-N/2,1,N);v-=l*2/a}if(s==u)if(p==n&&q==o){do{u=f(g()*4)*E;O=f(g()*2)?2:-2;p=u==0?n+b:u==F?n-b:n;q=u==E?o-b:u==G?o+b:o;P=f(p/b);Q=f(q/b)}while(k[Q]&1<<7-P)}else{if(p!=n)n+=n>p?-2:2;if(q!=o)o+=o>q?-2:2}else s+=O;s=s>=H?s-H:s<0?H+s:s;setTimeout(h,22)}; h();
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.