麻烦大家看看这程序的第55行,sec=-1.57+Math.PI*secs/30;为什么前面要有-1.57以及后面为什么要除以30位置固定的时钟位置固定的时钟--fCol = '000000'; //面板颜色sCol = 'ff0000'; //秒针颜色mCol = '000000'; //

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/01 16:45:01

麻烦大家看看这程序的第55行,sec=-1.57+Math.PI*secs/30;为什么前面要有-1.57以及后面为什么要除以30位置固定的时钟位置固定的时钟--fCol = '000000'; //面板颜色sCol = 'ff0000'; //秒针颜色mCol = '000000'; //
麻烦大家看看这程序的第55行,sec=-1.57+Math.PI*secs/30;为什么前面要有-1.57以及后面为什么要除以30



位置固定的时钟


位置固定的时钟

--
fCol = '000000'; //面板颜色
sCol = 'ff0000'; //秒针颜色
mCol = '000000'; //分针颜色
hCol = '000000'; //时针颜色
H = '.';
H = H.split('');
M = '.';
M = M.split('');
S = '.';
S = S.split('');
Ypos = 0;
Xpos = 0;
Ybase = 8;
Xbase = 8;
dots = 12;
ns = (document.layers)?1:0;
document.write('

');
for (i = 1; i < dots+1; i++)
{
document.write('
'+i+'
');
}
document.write('
')
document.write('
');
for (i = 0; i < M.length; i++) {
document.write('
');
}
document.write('
')
document.write('
')
document.write('
');
for (i = 0; i < H.length; i++) {
document.write('
');
}
document.write('
')
document.write('
');
for (i = 0; i < S.length; i++) {
document.write('
');
}
document.write('
')
function clock()
{
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360;
Ypos = document.body.scrollTop + window.document.body.clientHeight - 60;
Xpos = document.body.scrollLeft + window.document.body.clientWidth - 60;
for (i=0; i < dots; ++i)
{
ieDigits[i].style.pixelTop = Ypos - 15 + 40 * Math.sin(-0.49+dots+i/1.9);
ieDigits[i].style.pixelLeft = Xpos - 14 + 40 * Math.cos(-0.49+dots+i/1.9);
}
for (i=0; i < S.length; i++)
{
x[i].style.pixelTop = Ypos + i * Ybase * Math.sin(sec);
x[i].style.pixelLeft = Xpos + i * Xbase * Math.cos(sec);
}
for (i=0; i < M.length; i++)
{
y[i].style.pixelTop = Ypos + i * Ybase * Math.sin(min);
y[i].style.pixelLeft = Xpos + i * Xbase * Math.cos(min);
}
for (i=0; i < H.length; i++)
{
z[i].style.pixelTop = Ypos + i * Ybase*Math.sin(hrs);
z[i].style.pixelLeft = Xpos + i * Xbase*Math.cos(hrs);
}
setTimeout('clock()',50);
}
if (document.all) window.onload = clock;
//-->


麻烦大家看看这程序的第55行,sec=-1.57+Math.PI*secs/30;为什么前面要有-1.57以及后面为什么要除以30位置固定的时钟位置固定的时钟--fCol = '000000'; //面板颜色sCol = 'ff0000'; //秒针颜色mCol = '000000'; //
换算成弧度,显示在圆盘上,360°,每格30°,1.57=0.5*派,就是反转180°
比如现在是30分,就是1派-1.57=1.57

bu hui

4ru2h254rf5hb4rtf56rs4db