婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > html5繪制時鐘動畫

html5繪制時鐘動畫

熱門標(biāo)簽:外呼系統(tǒng)電話怎么投訴 外呼線穩(wěn)定線路 呼和浩特外呼電銷系統(tǒng)排名 邢臺縣地圖標(biāo)注app 申請400電話流程簡介 pageadm實現(xiàn)地圖標(biāo)注 南通數(shù)據(jù)外呼系統(tǒng)推廣 阜陽企業(yè)外呼系統(tǒng) 地圖標(biāo)注位置能賺錢嗎

<canvas id="clock" width="500" height="500" style="background-color: yellow"></canvas>


復(fù)制代碼
代碼如下:

var clock=document.getElementById("clock");
var cxt=clock.getContext("2d");
function drawNow(){
var now=new Date();
var hour=now.getHours();
var min=now.getMinutes();
var sec=now.getSeconds();
hour=hour>12?hour-12:hour;
hour=hour+min/60;
//表盤(藍(lán)色)
cxt.lineWidth=10;
cxt.strokeStyle="blue"
cxt.beginPath();
cxt.arc(250,250,200,0,360,false);
cxt.closePath();
cxt.stroke();
//刻度
//時刻度
for(var i=0;i<12;i++){
cxt.save();
cxt.lineWidth=7;
cxt.strokeStyle="black";
cxt.translate(250,250);
cxt.rotate(i*30*Math.PI/180);//旋轉(zhuǎn)角度 角度*Math.PI/180=弧度
cxt.beginPath();
cxt.moveTo(0,-170);
cxt.lineTo(0,-190);
cxt.closePath();
cxt.stroke();
cxt.restore();
}
//分刻度
for(var i=0;i<60;i++){
cxt.save();
//設(shè)置分刻度的粗細(xì)
cxt.lineWidth=5;
//重置畫布原點
cxt.translate(250,250);
//設(shè)置旋轉(zhuǎn)角度
cxt.rotate(i*6*Math.PI/180);
//畫分針刻度
cxt.strokeStyle="black";
cxt.beginPath();
cxt.moveTo(0,-180);
cxt.lineTo(0,-190);
cxt.closePath();
cxt.stroke();
cxt.restore();
}
//時針
cxt.save();
// 設(shè)置時針風(fēng)格
cxt.lineWidth=7;
cxt.strokeStyle="black";
cxt.translate(250,250);
cxt.rotate(hour*30*Math.PI/180);
cxt.beginPath();
cxt.moveTo(0,-140);
cxt.lineTo(0,10);
cxt.closePath();
cxt.stroke();
cxt.restore();
//分針
cxt.save();
cxt.lineWidth=5;
cxt.strokeStyle="black";
//設(shè)置異次元空間分針畫布的中心
cxt.translate(250,250);
cxt.rotate(min*6*Math.PI/180);
cxt.beginPath();
cxt.moveTo(0,-160);
cxt.lineTo(0,15);
cxt.closePath();
cxt.stroke()
cxt.restore();
//秒針
cxt.save();
//設(shè)置秒針的風(fēng)格
//顏色:紅色
cxt.strokeStyle="red";
cxt.lineWidth=3;
//重置原點
cxt.translate(250,250);
//設(shè)置角度
//cxt.rotate(330*Math.PI/180);
cxt.rotate(sec*6*Math.PI/180);
cxt.beginPath();
cxt.moveTo(0,-170);
cxt.lineTo(0,20);
cxt.closePath();
cxt.stroke();
//畫出時針,分針,秒針的交叉點
cxt.beginPath();
cxt.arc(0,0,5,0,360,false);
cxt.closePath();
//設(shè)置填充
cxt.fillStyle="gray";
cxt.fill();
//cxt.strokeStyle="red";
cxt.stroke();
//畫出秒針的小圓點
cxt.beginPath();
cxt.arc(0,-140,5,0,360,false);
cxt.closePath();
//設(shè)置填充
cxt.fillStyle="gray";
cxt.fill();
//cxt.strokeStyle="red";
cxt.stroke();</p> <p> cxt.restore();</p> <p>}
function drawClock(){
cxt.clearRect(0,0,500,500);
drawNow();
}
drawNow();
setInterval(drawClock,1000);

標(biāo)簽:內(nèi)蒙古 德州 蚌埠 黃山 楊凌 鶴崗 撫順 辛集

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《html5繪制時鐘動畫》,本文關(guān)鍵詞  html5,繪制,時鐘,動畫,html5,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《html5繪制時鐘動畫》相關(guān)的同類信息!
  • 本頁收集關(guān)于html5繪制時鐘動畫的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 呈贡县| 广元市| 济宁市| 肥乡县| 莱芜市| 霍州市| 安平县| 墨玉县| 临澧县| 武隆县| 临洮县| 财经| 赫章县| 桦甸市| 政和县| 社会| 巴彦县| 廊坊市| 岢岚县| 祥云县| 巴里| 喜德县| 北海市| 铜山县| 曲靖市| 商洛市| 天峨县| 涿鹿县| 福贡县| 乌拉特前旗| 会理县| 商丘市| 西城区| 大城县| 舟曲县| 务川| 云浮市| 祁阳县| 肃北| 芦山县| 工布江达县|