时钟项目:

Posted yan1314

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了时钟项目:相关的知识,希望对你有一定的参考价值。

 

 

 

 

技术分享图片
canvas.resize(600,400);
var clkbg = new Sprite(‘https://rss.leaplearner.com/teachfiles/Media/clk_bg-03.jpg‘,0,0,600,400);
var clockDial = new Circle(205,188,112);

//将指针调整回零点
var hourHand = new Line(205,188,205,138);
var minuteHand = new Line(205,188,205,108);
var secondHand = new Line(205,188,205,88);
var marks = new Sprite(‘https://rss.leaplearner.com/teachfiles/Media/clockDial1.png‘, 100, 83, 210, 210);
var cat = new Sprite(‘https://rss.leaplearner.com/Image/Role/CAT3.png‘, 127, 110, 150, 160);

var secondAngle = 0;
var minuteAngle = 0;
var hourAngle = 0;

secondHand.strokeStyle = "orange";
secondHand.lineWidth = 3;
minuteHand.strokeStyle = "blue";
minuteHand.lineWidth = 5;
hourHand.strokeStyle = "red";
hourHand.lineWidth = 8;
clockDial.strokeStyle = "black";
clockDial.fillStyle = "white";
clockDial.lineWidth = 7;

secondHand.setAnchor(205,188);
minuteHand.setAnchor(205,188);
hourHand.setAnchor(205,188);

function Main() {
    secondAngle += 6;
    if(secondAngle ==360)
    {
        secondAngle = 0;
        minuteAngle += 6;
    }
    if(minuteAngle == 360)
    {
        minuteAngle = 0;
        hourAngle += 30;
    }
    if(hourAngle == 360)
    {
        hourAngle = 0;
    }
    
    clkbg.draw();
    clockDial.draw();
    marks.draw();
    cat.draw();
    hourHand.rotate(hourAngle)
    hourHand.draw();
    minuteHand.rotate(minuteAngle);
    minuteHand.draw();
    secondHand.rotate(secondAngle);
    secondHand.draw();
}

setInterval(Main,1000);
View Code

 

以上是关于时钟项目:的主要内容,如果未能解决你的问题,请参考以下文章

开源天气时钟项目删减和更新

串行通信协议

单片机课设-电子时钟设计(仿真图代码全)

微信小程序代码片段

[Java项目01][数字时钟]

python 用于数据探索的Python代码片段(例如,在数据科学项目中)