绿树红花(chrome).html  返回列表

<html><head>
		<title>JS1k, 1k demo submission [893]</title>
		<meta charset="utf-8">
	</head>
	<body>
		<canvas id="c" width="1260" height="830"></canvas>
		<script>
			var b = document.body;
			var c = document.getElementsByTagName('canvas')[0];
			var a = c.getContext('2d');
			document.body.clientWidth; // fix bug in webkit: http://qfox.nl/weblog/218
		</script>
		<script>
			// start of submission //
			M=Math;
			MR=M.random;
			W=c.width=window.innerWidth-20;
			H=c.height=window.innerHeight-20;
			MI=0;
			var D;var S=100;
			pi=M.PI;
			var X=3;
			function F(x,y){
				MI=M.round(MR()*4)+4;
				X=M.ceil(MR()*10);
				//a.strokeStyle='rgba(255,255,255,1)';
				D=[];
				if(!x){
					x=(MR()-1/2)*W/S;
					y=(MR()-1/2)*H/S
				}
				for(var i=0;i<MI;i++){
					D.push(MR()/2+1/3)
				}
				for(var i=0;i<X;i++){
					//B(i*pi/3,1,x,y,0,1)
					B(i*pi/(X/2),1,0.5,0.4,0,1)
				}
				
			}
			function CLS(){
				a.fillStyle="rgba(0,0,0,0.75)";
				a.fillRect(0,0,W,H);
				a.fill()
			}
			function B(r,l,x,y,G,T){
				setTimeout(function(){
				r=(r+2*pi)%(2*pi);
				var x2=M.cos(r)*l+x;
				var y2=M.sin(r)*l+y;
				var l2=l*D[G];
				var G2=G+1;
				a.beginPath();
				a.lineWidth=M.ceil(l*10);
				a.strokeStyle='rgb(0,'+(55 + Math.floor((1 - l) * 200))+',0)';
				a.moveTo(S*x+W/2,S*y+H/2);
				a.lineTo(S*x2+W/2,S*y2+H/2);
				a.closePath();
				a.stroke();
				a.beginPath();
				a.strokeStyle='rgb('+(55 + Math.floor((1 - l) * 200))+',0,0)';
				a.arc(S*x+W/2,S*y+H/2,M.ceil(l*20),0,Math.PI*2,true);
				a.closePath();
				a.stroke();
				if(G<MI && l>1/S){
					B(r-pi/3,l2,x2,y2,G2);
					B(r+pi/3,l2,x2,y2,G2);
					if(T)B(r,l*0.8,x2,y2,G2,T);
					else B(r,l2,x2,y2,G2)
				}
				},0);
			}
			a.fillStyle="black";
			a.fillRect(0,0,W,H);
			F();
			//F();
			//F();
			setInterval("F();CLS();",1500);
			//setInterval("CLS()",4000);
			// end of submission //
		</script>
</body></html>
Add New Content