Skip to content

Commit 94e41c9

Browse files
author
jikeytang
committed
update
1 parent 9d9d34f commit 94e41c9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

d/04/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@
3232
ctx.closePath();
3333
ctx.stroke();
3434
}
35+
function drawNumbers(){
36+
var angle = 0,
37+
nWidth = 0;
38+
ctx.save();
39+
ctx.translate(250, 250);
40+
ctx.font="19px Arial";
41+
for(var i = 1; i <= 12; i++){
42+
if(!(i % 3)){
43+
angle = Math.PI / 6 * (i - 3);
44+
nWidth = ctx.measureText(i).width;
45+
ctx.fillText(i, Math.cos(angle) * 150 - nWidth/2, Math.sin(angle) * 150 + nWidth/2);
46+
}
47+
}
48+
ctx.restore();
49+
}
3550
// 时针刻度
3651
function drawHourDegree(){
3752
for(var i = 0; i < 12; i++){
@@ -117,6 +132,7 @@
117132
ctx.clearRect(0, 0, 500, 500);
118133
now();
119134
drawBase();
135+
drawNumbers();
120136
drawMinDegree();
121137
drawHourDegree();
122138
drawHour();

0 commit comments

Comments
 (0)