第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為啥我的秒針轉(zhuǎn)動是按照小時轉(zhuǎn)的,而不是秒???

1 回答

?
西蘭花偉大炮

TA貢獻376條經(jīng)驗 獲得超318個贊

<!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title></title>
????<style>
????????#canvas{
????????????border:?1px?solid?#e9e0b5;
????????????margin:?200px?auto;
????????????display:?block;
????????}
????</style>
</head>
<body>
<canvas?id="canvas"?width="300"?height="300"></canvas>
<script>
????var?canvas?=?document.getElementById("canvas");
????var?ctx?=?canvas.getContext("2d");
????var?width?=?ctx.canvas.width;
????var?height?=?ctx.canvas.height;
????var?r?=?width?/2;

????function?drawbackground(ctx){
????????ctx.save();
????????ctx.translate(r,r);
????????ctx.beginPath();
????????ctx.lineWidth?=?10;
????????ctx.arc(0?,0?,?r-5,?0,?Math.PI?*?2);
????????ctx.stroke();
????????ctx.closePath();
????????ctx.textAlign?=?"center";
????????ctx.textBaseline?=?"middle";
????????ctx.font?=?"18px?Arial";
????????var?hourNumber?=?[3,4,5,6,7,8,9,10,11,12,1,2];
????????hourNumber.forEach(function?(number,i)?{
????????????var?rad?=?Math.PI?*?2?/?12?*?i;
????????????var?x?=?Math.cos(rad)?*?(r?-?40);
????????????var?y?=?Math.sin(rad)?*?(r?-?40);
????????????ctx.fillText(number,x,y);
????????});

????????for(var?i?=?0;i?<?60;i++){
????????????var?raddot?=?Math.PI?*?2?/?60?*?i;
????????????var?x?=?Math.cos(raddot)?*?(r?-?25);
????????????var?y?=?Math.sin(raddot)?*?(r?-?25);
????????????ctx.beginPath();
????????????if(i?%?5?===?0){
????????????????ctx.arc(x,y,3,0,Math.PI?*?2);
????????????????ctx.fillStyle?=?"#000";
????????????}else
????????????{
????????????????ctx.arc(x,y,3,0,Math.PI?*?2);
????????????????ctx.fillStyle?=?"gray";
????????????}
????????????ctx.fill();

????????}
????}
????function?drawhour(hour,minute){
????????ctx.save();
????????ctx.beginPath();
????????var?radhour?=?Math.PI?*?2?/12?*?hour;
????????var?radminute?=?Math.PI?*?2?/12?/?60?*?minute;
????????ctx.rotate(radhour?+?radminute);
????????ctx.lineWidth?=?6;
????????ctx.lineCap?=?"round";
????????ctx.moveTo(0,10);
????????ctx.lineTo(0,-r?+?50);
????????ctx.stroke();
????????ctx.restore();
????}
????function?drawminute(minute){
????????ctx.save();
????????ctx.beginPath();
????????var?radhour?=?Math.PI?*?2?/60?*?minute;
????????ctx.rotate(radhour);
????????ctx.lineWidth?=?3;
????????ctx.lineCap?=?"round";
????????ctx.moveTo(0,15);
????????ctx.lineTo(0,-r?+?40);
????????ctx.stroke();
????????ctx.restore();
????}
????function?drawsecond(second){
????????ctx.save();
????????ctx.beginPath();
????????var?radsecond?=?Math.PI?*?2?/60?*?second;
????????ctx.rotate(radsecond);
????????ctx.moveTo(-2,20);
????????ctx.lineTo(2,20);
????????ctx.lineTo(-1,-r?+?35);
????????ctx.lineTo(1,-r?+?35);
????????ctx.fillStyle?=?"red";
????????ctx.fill();
????????ctx.restore();
????}
????function?draw(){
????????ctx.clearRect(0,0,width,height);
????????var?now?=?new?Date();
????????var?hour?=?now.getHours();
????????var?minute?=?now.getMinutes();
????????var?second?=?now.getSeconds();
????????drawbackground(ctx);
????????drawhour(hour,minute);
????????drawminute(minute);
????????drawsecond(second);
????????ctx.restore();
????}
????draw();
????setInterval(draw,1000);
</script>
</body>
</html>

你又不貼代碼,還要看你課程才知道你問的是什么,看你的問題,應(yīng)該是時間轉(zhuǎn)換錯了,對比一下上面的吧

查看完整回答
2 反對 回復(fù) 2017-03-12
  • 1 回答
  • 0 關(guān)注
  • 1323 瀏覽

添加回答

了解更多

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號