来源:flash,as,js兴趣爱好者html5+js时钟效果 <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>html5时钟</title>
</head>
<body>
<canvas id="clock" width="500" height="500" style="background-color:black;">你的浏览器不支持canvas</canvas>
<script type="text/javascript">
var canvas = document.getElementById("clock");
var cxt = canvas.getContext("2d");
function drawClock() {
var now = new Date();
var sec = now.getSeconds();
var min = now.getMinutes();
var hour = now.getHours();
hour > 12 ? hour - 12 : hour;
hour += (min / 60);
//先清空画布
cxt.clearRect(0, 0, canvas.width, canvas.height);
//美女图片作为表盘背景
var img = new Image();
img.src = "http://t-1.tuzhan.com/ebd0af03090a/p-2/l/2013/11/30/17/515a5c953dc94172bc2c96953cf6a8e2.jpg";
cxt.drawImage(img, 0, 0);
cxt.strokeStyle = "#00FFFF";
cxt.lineWidth = 10;
cxt.beginPath();
cxt.arc(250, 250, 200, 0, 360);
cxt.stroke();
cxt.closePath();
//时刻度
for (var i = 0; i < 12; i++) {
cxt.save();//保存当前状态
cxt.lineWidth = 7;
cxt.strokeStyle = "#FFFF00";
//设置原点
cxt.translate(250, 250);
//设置旋转角度
余下内容请看http://www.flash14.com/index.asp?f=flash_js_20131130174716