The canvas H5 complete dynamic clock

First, a need to draw the canvas in the body, then draw on the canvas clock, the main clock used in the drawing to draw a circle,

Because the clock is graduated, so that will be used to traverse the array, and then have to get the current time, it will use some of the date of the API;

Renderings:

Drawing brushes and disc, and a drawing scale, and each scale corresponding to arc

 

Draw the hour, minute and second hands, center

 

 

 

Get the current time as a parameter to the function, set the timer, called once every second

Summary: In the process of doing, while drawing attention to the clock function of two parameters, in conjunction with the life of common sense,

For example: time 6:30, the clock does not refer to an intermediate position 6 and 7 but 6.

 

Guess you like

Origin www.cnblogs.com/hyh888/p/11586694.html