国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > HTML > 正文

html5使用canvas_繪制太陽系效果

2020-03-24 15:53:56
字體:
來源:轉載
供稿:網友

星球 變量名 公轉周期 光色 暗色 水星 Mercury 87.70 #a69697 #5c3e40 金星 Venus 224.701.70 #c4bbac #1f1315 地球 Earth 365.2422 #78b1e8 #050c12 火星 Mars 686.98 #cec9b6 #76422d 木星 Jupiter 4332.589 #c0a48e #322 土星 Saturn 10759.95 #f7f9e3 #5c4553 天王星 Uranus 30799.095 #a7e115 #19243a 海王星 Neptune 60152.95 #0661b2 #1E3b73

<canvas id="canvas" width="1000" height="1000" style="background-color: #000;"></canvas>

代碼如下:

var canvas=document.getElementById("canvas");

var cxt=canvas.getContext("2d");



function DrawTrack(){

for(var i=0;i<8;i++){

cxt.beginPath();

cxt.arc(500,500,(i+1)*50,0,360,false);

cxt.closePath();

cxt.strokeStyle="#fff";

cxt.stroke();

}

}

function DrawStart(x,y,radius,cycle,sColor,eColor){

//畫出星球需要哪些屬性



//星球的坐標點

this.x=x;

this.y=y;

//星球的半徑

this.radius=radius;

//星球的顏色(開始色,結束色)

this.sColor=sColor;

this.eColor=eColor;

//創建一個漸變色空對象

this.color=null;

this.time=0;

//公共周期

this.cycle=cycle;

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=c
11個字網名[www.la240.com/html2017/1/1/]xt.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;

}

}</p> <p> function Sun(){//太陽1

DrawStart.call(this,0,0,20,0,"#f00","#f90");

}

function Mercury(){//水星2

DrawStart.call(this,0,-50,10,87.70,"#A69697","#5c3e40");

}

function Venus(){//金星3

DrawStart.call(this,0,-100,10,224.71,"#c4bbac","#1f1315");

}

function Earth(){//地球4

DrawStart.call(this,0,-150,10,365.224,"#78b1e8","#050c12");

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浙江省| 天峻县| 班戈县| 麦盖提县| 平武县| 满城县| 梓潼县| 精河县| 彭山县| 旌德县| 泸州市| 新乡县| 湖州市| 铜川市| 深水埗区| 双鸭山市| 泰兴市| 津南区| 定州市| 凯里市| 永顺县| 奉贤区| 赤壁市| 松阳县| 调兵山市| 新河县| 平江县| 沁源县| 阳江市| 大埔区| 通道| 缙云县| 甘南县| 南安市| 静海县| 大厂| 阿拉善左旗| 那曲县| 南昌县| 区。| 本溪|