File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 14
14
( function ( ) {
15
15
var canvas = document . getElementById ( 'canvas' ) ;
16
16
var ctx = canvas . getContext ( '2d' ) ;
17
- var d , h , m , s ;
17
+ var h , m , s ;
18
18
function now ( ) {
19
- d = new Date ( ) ;
19
+ var d = new Date ( ) ;
20
20
h = d . getHours ( ) ;
21
21
m = d . getMinutes ( ) ;
22
22
s = d . getSeconds ( ) ;
64
64
ctx . restore ( ) ;
65
65
}
66
66
}
67
- // 针
67
+ // 时针
68
68
function drawHour ( ) {
69
69
ctx . save ( ) ;
70
70
ctx . translate ( 250 , 250 ) ;
78
78
ctx . stroke ( ) ;
79
79
ctx . restore ( ) ;
80
80
}
81
- // 针
81
+ // 分针
82
82
function drawMin ( ) {
83
83
ctx . save ( ) ;
84
84
ctx . translate ( 250 , 250 ) ;
105
105
ctx . translate ( 250 , 250 ) ;
106
106
ctx . rotate ( s * 6 * Math . PI / 180 ) ; // 6 每秒转过的角度
107
107
ctx . beginPath ( ) ;
108
- ctx . moveTo ( 0 , 150 ) ;
108
+ ctx . moveTo ( 0 , - 150 ) ;
109
109
ctx . lineWidth = 3 ;
110
110
ctx . strokeStyle = 'red' ;
111
- ctx . lineTo ( 0 , - 25 ) ;
111
+ ctx . lineTo ( 0 , 25 ) ;
112
112
ctx . closePath ( ) ;
113
113
ctx . stroke ( ) ;
114
114
ctx . restore ( ) ;
You can’t perform that action at this time.
0 commit comments