時針顯示不正確
function drawHour(hour,minute){
ctx.save();
ctx.beginPath();
var rad ?= 2 * Math.PI / 12 * hour;
var mrad ?= 2 * Math.PI / 12 /60 * minute;?
ctx.rotate(rad + mrad);
ctx.lineWidth = 6;
ctx.lineCap = 'round';
ctx.moveTo(0,10);
ctx.lineTo(0,-r/2);
ctx.stroke();
ctx.restore();
}
function drawMinute(minute){
ctx.save();
ctx.beginPath();
var rad = rad = 2*Math.PI/60 * minute;?
ctx.rotate(rad);
ctx.lineWidth = 3;
ctx.lineCap = 'round';
ctx.moveTo(0,10);
ctx.lineTo(0,-r + 10);
ctx.stroke();
ctx.restore();
}
drawBackground();
drawHour(4);
drawMinute(30);
2018-02-27
drawHour(4);改為drawHour(4,30);
2018-02-27
rad=hour/6*Math.PI? = = 一圈360°是2π 分為12份? 那么6份就是π? 小時數(shù)除于6 表示有幾份π