使用canvas 做动态时钟特效
1) shizhong.html
<style type="text/css">
div{
text-align: center;
margin: 250px;
}
#clock{
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div>
<canvas id="clock" height="300px" width="300px"></canvas>
</div>
<script type="text/javascript" src="js/clock.js"></script>
</body>
2) js/clock.js
var dom=document.getElementById(‘clock’);
var ctx=dom.getContext(‘2d’);
var width=ctx.canvas.width;
var height=ctx.canvas.height;
var r=width/2;
var rem=width/200;
function drawBackground(){
ctx.save();
ctx.translate(r,r);
ctx.beginPath();
ctx.lineWi