码迷,mamicode.com
首页 > 其他好文 > 详细

时钟项目:

时间:2018-05-12 19:24:48      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:lock   res   image   .com   hit   ide   cti   img   cond   

 

 

 

 

技术分享图片
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

 

时钟项目:

标签:lock   res   image   .com   hit   ide   cti   img   cond   

原文地址:https://www.cnblogs.com/yan1314/p/9029431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!