1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| var ctx = document.getElementById("canvas").getContext("2d");
function drawTrack(){ for(var i = 0;i < 8;i++){ ctx.beginPath(); ctx.arc(500,500,(i+1) * 50,0,360,false); ctx.strokeStyle = "#fff"; ctx.stroke(); ctx.closePath(); } }
function Star(x,y,radius,cycle,sColor,eColor){ this.x = x; this.y = y; this.radius = radius; this.cycle = cycle; this.eColor = eColor; this.sColor = sColor; this.color = null; this.time = 0; this.draw = function(){ ctx.save(); ctx.translate(500,500); ctx.rotate(this.time * (360/this.cycle) * Math.PI / 180); ctx.beginPath(); ctx.arc(this.x,this.y,this.radius,0,360,false); ctx.closePath(); this.color = ctx.createRadialGradient(this.x,this.y,0,this.x,this.y,this.radius); this.color.addColorStop(0,this.sColor); this.color.addColorStop(0,this.eColor); ctx.fillStyle = this.color; ctx.fill(); ctx.restore(); this.time +=1; } }
function Sun(){ Star.call(this,0,0,20,0,"#F00","#f90"); }
function Mercury(){ Star.call(this,0,-50,10,87.70,"#A69697","#5C3E40"); }
function Venus(){ Star.call(this,0,-100,10,224.701,"#C4BBAC","#1F1315"); }
function Earth(){ Star.call(this,0,-150,10,365.224,"#78B1E8","#050C12"); }
function Mars(){ Star.call(this,0,-200,10,686.98,"#CEC9B6","#76422D"); }
function Jupiter(){ Star.call(this,0,-250,10,4332.589,"#C0A48E","#322222"); }
function Saturn(){ Star.call(this,0,-300,10,10759.5,"#F7F9E3","#5C4533"); } function Uranus(){ Star.call(this,0,-350,10,30799.095,"#A7E1E5","#19243A"); }
function Neptune(){ Star.call(this,0,-400,10,60152,"#0661B2","#1E3B73"); }
var sun=new Sun();
var water=new Mercury();
var gold=new Venus();
var diqiu=new Earth();
var fire=new Mars();
var wood=new Jupiter();
var soil=new Saturn();
var god=new Uranus();
var sea=new Neptune();
function move(){ ctx.clearRect(0,0,1000,1000); drawTrack(); sun.draw(); water.draw(); gold.draw(); diqiu.draw(); fire.draw(); wood.draw(); soil.draw(); god.draw(); sea.draw(); }
setInterval(move,10);
|