时钟_滚动 scroll
2005.6.
//4.设置时钟中心(跟随正文滚动 scroll)
var Ypos = document.body.scrollTop +220;
var Xpos = document.body.scrollLeft +400;
//5.根据小时刻度的角度值计算坐标:r*cos(-PI/2+(2*PI/12)(i+1)
//调整时钟刻度中心(x-22,y-22)
for (var i=0; i < dots; ++i)
{
dot_Digits[i].style.pixelTop
= Ypos -22 + 180 * Math.sin(-Math.PI/2+2*Math.PI*(i+1)/12);
dot_Digits[i].style.pixelLeft
= Xpos -22 + 180 * Math.cos(-Math.PI/2+2*Math.PI*(i+1)/12);
}
//5.1 根据秒针的角度值计算坐标:i* Xbase*cos(-PI/2+(2*PI/60)*sec)
var sec = -Math.PI/2 + 2*Math.PI * secs/60; //秒针角度
for (i=0; i < S.length; i++)
{
s_dots[i].style.pixelTop = Ypos + i * Ybase * Math.sin(sec);
s_dots[i].style.pixelLeft = Xpos + i * Xbase * Math.cos(sec);
}
//5.2 根据分针的角度值计算坐标:i* Xbase*cos(-PI/2+(2*PI/60)*mins)
var min = -Math.PI/2 + 2*Math.PI * mins/60; //分针角度
for (i=0; i < M.length; i++)
{
m_dots[i].style.pixelTop = Ypos + i * Ybase * Math.sin(min);
m_dots[i].style.pixelLeft = Xpos + i * Xbase * Math.cos(min);
}
//5.3 根据时针的角度值计算坐标:i* Xbase*cos(-PI/2+(2*PI/12)*(hrs+mins/60))
// 1小时30分对应小时刻度为(1+1/2)
var hr = -Math.PI/2 + 2*Math.PI * (hrs+mins/60)/12; //时针角度
for (i=0; i < H.length; i++)
{
h_dots[i].style.pixelTop = Ypos + i * Ybase*Math.sin(hr);
h_dots[i].style.pixelLeft = Xpos + i * Xbase*Math.cos(hr);
}