JS1K

#2: the original

Source for demo by yent.

window.onload=function(){
	a=(o=document.getElementById('c')).getContext('2d');

	a.w=o.width;a.h=o.height;

	$c=Math.cos;

	$s=Math.sin;

	$p=Math.PI;

	$r=Math.sqrt;

	_i=function(p){return [$r(2)*(p[0]-p[1])/2,$r(2/3)*p[2]-(p[0]+p[1])/$r(6)]};

	_s=function(sp,ep){

		with(a){

			beginPath();

			var p=_i(sp);

			moveTo(p[0]+w/2,h/2-p[1]);

			p=_i(ep);

			lineTo(p[0]+w/2,h/2-p[1]);

			closePath();

			stroke()

		}

	};

	

	_v=function(p,s,r,h,c){

		a.strokeStyle=c;

		var i=2*$p/s;

		for(t=p;t<2*$p+p;t+=i){

			_s([r*$c(t),r*$s(t),h/-2],[r*$c(t+i),r*$s(t+i),h/-2]);

			_s([r*$c(t),r*$s(t),h/-2],[r*$c(t),r*$s(t),h/2]);

			_s([r*$c(t),r*$s(t),h/2],[r*$c(t+i),r*$s(t+i),h/2]);

		}

	};

	

	$a=0,$b=0;

	this.setInterval(function(){

		o.width=a.w;

		_v(0,1,1,200,'#000');

		$a+=($p/64)%(2*$p);

		_v($a,16,30,75,'#a00');

		_v($a,4,75,75,'#0a0');

	},30);

}