初学html5太阳系

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

<!doctype html>
<html>
	<head>
	<meta charset="utf-8"></head>
	<body>
		<canvas id="canvas" width="1000" height="1000" style="background:#000">	</canvas>
		<script>
			var cxt=document.getElementById('canvas').getContext('2d')
			
			function draw(){
				for(var i=0;i<8;i++){
					cxt.beginPath();
					cxt.strokeStyle="gray";
					cxt.closePath();
					cxt.arc(500,500,(i+1)*50,0,360,false);
					cxt.closePath();
					cxt.stroke();
				}
			}
			draw();
			function Star(x,y,radius,cycle,scolor,ecolor){
				this.x=x;
				this.y=y;
				this.radius=radius;
				this.cycle=cycle;
				this.scolor=scolor;
				this.ecolor=ecolor;
				this.color=null;
				this.time=0;
				this.draw=function(){
					cxt.save();
					cxt.translate(500,500);
					cxt.rotate(this.time*(360/this.cycle)*Math.PI/180);
					cxt.beginPath();
					cxt.arc(this.x,this.y,this.radius,0,360,false);
					cxt.closePath();
					this.color=cxt.createRadialGradient(this.x,this.y,0,this.x,this.y,this.radius);
					this.color.addColorStop(0,this.scolor);
					this.color.addColorStop(1,this.ecolor);
					cxt.fillStyle=this.color;
					cxt.fill();
					cxt.restore();
					this.time+=1;
				}
			}
				function Sun(){
				Star.call(this,0,0,20,0,"#ff0000","#ff9900");
			}
							var sun=new Sun();
				
				function di(){
					Star.call(this,0,-50,10,87,"#A69697","#5C3E40");
				}
				var di=new di();
				
				function water(){
					Star.call(this,0,-100,10,224.701,"#C4BBAC","#1F1315");
				}
				var water=new water();
				function jin(){
					Star.call(this,0,-150,10,365.2422,"#78B1E8","#050C12");
				}
				var jin=new jin();
				
				function huo(){
					Star.call(this,0,-200,10,686.98,"#CEC9B6","#76422D");
				}
				var huo=new huo();
				function mu(){
					Star.call(this,0,-250,10,4332.589,"#C0A48E","#322222");
				}
				var mu=new mu();
				function tu(){
					Star.call(this,0,-300,10,10759.5,"#F7F9E3","#5C4533");
				}
				var tu=new tu();
				function hai(){
					Star.call(this,0,-350,10,30799.095,"#A7E1E5","#19243A");
				}
				var hai=new hai();
				function ming(){
					Star.call(this,0,-400,10,164.8*365,"#0661B2","#1E3B73");
				}
				var ming=new ming();
				function move(){
				cxt.clearRect(0,0,1000,1000)
				draw();
				ming.draw();
				sun.draw();
				di.draw();
				water.draw();
				jin.draw();
				huo.draw();
				mu.draw();
				tu.draw();
				hai.draw();
				}
				setInterval(move,10);
		</script>
	</body>
</html>