<! DOCTYPE html>
<title></title>
<body>
<canvas id= "Clock" width= "height=" ></canvas>
<script src= ". /js/jquery-1.9.0.js "></script>
<script type= "Text/javascript" >
function Canvasclock (ID) {
var canvas = document.getElementById (ID);
var context = Canvas.getcontext ("2d");
Context.clearrect (0, 0, 400, 400);
Draw a Circle
Context.strokestyle = "Purple";
Context.beginpath ();
Context.arc (0, Math.PI * 2, true);
Context.closepath ();
Context.stroke ();
Draw minute Ticks
for (var i = 0; i <; i++) {
if (i% 5 = = 0) {
Continue
}
Context.save ();
Context.linewidth = 1;
Context.strokestyle = "#000";
Context.translate (150, 150);
Context.rotate (i * 6 * math.pi/180);
Context.beginpath ();
Context.moveto (0,-100);
Context.lineto (0,-90);
Context.closepath ();
Context.stroke ();
Context.restore ();
};
Draw the clock scale
for (var i = 0; i <; i++) {
Context.save ();
Context.linewidth = 2;
Context.strokestyle = "#000";
Context.translate (150, 150);
Context.rotate (i * * math.pi/180);
Context.beginpath ();
Context.moveto (0,-100);
Context.lineto (0,-85);
Context.closepath ();
Context.stroke ();
Context.restore ();
};
var date = new Date ();
var hour = date.gethours ();
var minutes = date.getminutes ();
var sec = Date.getseconds ();
Hour = hour + minutes/60;
hour = hour > 12? Hour-12:hour;
Clock line
Context.save ();
Context.linewidth = 5;
Context.strokestyle = "#4cff00";
Context.translate (150, 150);
Context.rotate (Hour * * math.pi/180);
Context.beginpath ();
Context.moveto (0,-70);
Context.lineto (0, 10);
Context.closepath ();
Context.stroke ();
Context.restore ();
Minute line
Context.save ();
Context.linewidth = 3;
Context.strokestyle = "#b200ff";
Context.translate (150, 150);
Context.rotate (minutes * 6 * math.pi/180);
Context.beginpath ();
Context.moveto (0,-80);
Context.lineto (0, 10);
Context.closepath ();
Context.stroke ();
Context.restore ();
Seconds line
Context.save ();
Context.linewidth = 1.5;
Context.strokestyle = "#ff00dc";
Context.translate (150, 150);
Context.rotate (SEC * 6 * math.pi/180);
Context.beginpath ();
Context.moveto (0,-90);
Context.lineto (0, 10);
Context.closepath ();
Context.stroke ();
Context.restore ();
};
SetInterval (function () {
Canvasclock ("clock");
}, 1000);
</script>
</body>
Canvas Draw Clock