source:
trunk/examples/script/context2d/scripts/clock.js@
1168
Last change on this file since 1168 was 2, checked in by , 16 years ago | |
---|---|
File size: 1.9 KB |
Line | |
---|---|
1 | function init(){ |
2 | clock(); |
3 | setInterval('clock()',1000); |
4 | } |
5 | function clock(){ |
6 | var now = new Date(); |
7 | var ctx = document.getElementById('tutorial').getContext('2d'); |
8 | ctx.save(); |
9 | ctx.clearRect(0,0,150,150); |
10 | ctx.translate(75,75); |
11 | ctx.scale(0.4,0.4); |
12 | ctx.rotate(-Math.PI/2); |
13 | ctx.strokeStyle = "black"; |
14 | ctx.fillStyle = "white"; |
15 | ctx.lineWidth = 8; |
16 | ctx.lineCap = "round"; |
17 | |
18 | // Hour marks |
19 | ctx.save(); |
20 | ctx.beginPath(); |
21 | for (i=0;i<12;i++){ |
22 | ctx.rotate(Math.PI/6); |
23 | ctx.moveTo(100,0); |
24 | ctx.lineTo(120,0); |
25 | } |