January 2016
Beginner
188 pages
3h 22m
English
We are going to draw an analog clock and make it work as a real clock. In your body part of the HTML document, type the following code:
<canvas id="myclock" height="500" width="500"></canvas> In your <script></script> tags, take the following variables: Var canvas; // the clock canvas var canvasElement; // canvas's elements // clock settings var cX = 0; var cY = 0; var radius = 150;
Here, cX and cY are the center coordinates of our clock. We took 150 px as the clock's radius. You can increase or decrease it.
Then, we need to initialize the variables. Make an init(); function after defining the preceding variables.
The function should look similar to the following:
function init() { canvas = document.getElementById("myclock"); //Called ...Read now
Unlock full access