请高手翻译一下这段JS的代码,非常谢谢,急!
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><metahttp-equiv=...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<STYLE type=text/css>.light {
FILTER: Light
}
.date {
COLOR: #000000; FONT-FAMILY: "Geneva", "Arial", "Helvetica", "san-serif"; FONT-SIZE: 12px; FONT-WEIGHT: bold; TEXT-ALIGN: center
}
</STYLE>
<SCRIPT>
function setLights(){
var sx=Math.cos(slightDir)*slightr;
var sy=Math.sin(slightDir)*slightr;
var mx=Math.cos(mlightDir)*mlightr;
var my=Math.sin(mlightDir)*mlightr;
var hx=Math.cos(hlightDir)*hlightr;
var hy=Math.sin(hlightDir)*hlightr;
sconDiv.filters.Light.clear();
sconDiv.filters.Light.addCone(sx+72,sy+72,1,73,72,215,255,5,20,1);
sconDiv.filters.Light.addCone(mx+72,my+72,1,73,72,255,10,0,20,2);
sconDiv.filters.Light.addCone(hx+72,hy+72,1,73,72,15,100,255,20,4);
sconDiv.filters.Light.addAmbient(155,155,155,100);
}
function timeGo(){
var tt=new Date();
slightDir=(tt.getSeconds())/60*6.28-1.57;
mlightDir=(tt.getMinutes())/60*6.28-1.57;
hlightDir=(tt.getHours())/12*6.28-1.57+mlightDir/6.28*0.52+0.05;
dateDiv.innerText=tt.getMonth()+1+"-"+tt.getDate();
setLights();
}
function InitClock(){
slightr=110;
mlightr=90;
hlightr=60;
timeGo();
setInterval("timeGo()",1000);
}
window.onload=InitClock;
</SCRIPT>
<DIV id=clockDiv
style="HEIGHT: 222px; LEFT: 145px; POSITION: absolute; TOP: 12px; WIDTH: 233px; Z-INDEX: 1">
<DIV class=light id=sconDiv
style="HEIGHT: 70px; LEFT: 27px; POSITION: absolute; TOP: 22px; WIDTH: 70px; Z-INDEX: 1"><IMG
height=144 src="http://www.zuiyu.net/images/clockm.gif" width=144></DIV><IMG height=200
src="http://www.zuiyu.net/images/clock2.gif" width=200>
<DIV id=clLayer
style="HEIGHT: 25px; LEFT: 88px; POSITION: absolute; TOP: 80px; WIDTH: 25px; Z-INDEX: 2"><IMG
height=26 src="http://www.zuiyu.net/images/clockd.gif" width=26></DIV>
<DIV class=date id=dateDiv
style="HEIGHT: 16px; LEFT: 85px; POSITION: absolute; TOP: 178px; WIDTH: 32px; Z-INDEX: 3">12-2</DIV></DIV>
</body>
</html>
主要是slightDir=(tt.getSeconds())/60*6.28-1.57;和sconDiv.filters.Light.addCone(mx+72,my+72,1,73,72,255,10,0,20,2);
是什么意思,请前辈解释的详细点,谢谢了!
我看的懂了,我们的坐标都是从0横向开始,而时钟以垂直向上方向开始,所以得旋转90度,当半径为1的时候,化为弧度为1.57,至于前面的是旋转了几弧度,还是谢谢各位了! 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<STYLE type=text/css>.light {
FILTER: Light
}
.date {
COLOR: #000000; FONT-FAMILY: "Geneva", "Arial", "Helvetica", "san-serif"; FONT-SIZE: 12px; FONT-WEIGHT: bold; TEXT-ALIGN: center
}
</STYLE>
<SCRIPT>
function setLights(){
var sx=Math.cos(slightDir)*slightr;
var sy=Math.sin(slightDir)*slightr;
var mx=Math.cos(mlightDir)*mlightr;
var my=Math.sin(mlightDir)*mlightr;
var hx=Math.cos(hlightDir)*hlightr;
var hy=Math.sin(hlightDir)*hlightr;
sconDiv.filters.Light.clear();
sconDiv.filters.Light.addCone(sx+72,sy+72,1,73,72,215,255,5,20,1);
sconDiv.filters.Light.addCone(mx+72,my+72,1,73,72,255,10,0,20,2);
sconDiv.filters.Light.addCone(hx+72,hy+72,1,73,72,15,100,255,20,4);
sconDiv.filters.Light.addAmbient(155,155,155,100);
}
function timeGo(){
var tt=new Date();
slightDir=(tt.getSeconds())/60*6.28-1.57;
mlightDir=(tt.getMinutes())/60*6.28-1.57;
hlightDir=(tt.getHours())/12*6.28-1.57+mlightDir/6.28*0.52+0.05;
dateDiv.innerText=tt.getMonth()+1+"-"+tt.getDate();
setLights();
}
function InitClock(){
slightr=110;
mlightr=90;
hlightr=60;
timeGo();
setInterval("timeGo()",1000);
}
window.onload=InitClock;
</SCRIPT>
<DIV id=clockDiv
style="HEIGHT: 222px; LEFT: 145px; POSITION: absolute; TOP: 12px; WIDTH: 233px; Z-INDEX: 1">
<DIV class=light id=sconDiv
style="HEIGHT: 70px; LEFT: 27px; POSITION: absolute; TOP: 22px; WIDTH: 70px; Z-INDEX: 1"><IMG
height=144 src="http://www.zuiyu.net/images/clockm.gif" width=144></DIV><IMG height=200
src="http://www.zuiyu.net/images/clock2.gif" width=200>
<DIV id=clLayer
style="HEIGHT: 25px; LEFT: 88px; POSITION: absolute; TOP: 80px; WIDTH: 25px; Z-INDEX: 2"><IMG
height=26 src="http://www.zuiyu.net/images/clockd.gif" width=26></DIV>
<DIV class=date id=dateDiv
style="HEIGHT: 16px; LEFT: 85px; POSITION: absolute; TOP: 178px; WIDTH: 32px; Z-INDEX: 3">12-2</DIV></DIV>
</body>
</html>
主要是slightDir=(tt.getSeconds())/60*6.28-1.57;和sconDiv.filters.Light.addCone(mx+72,my+72,1,73,72,255,10,0,20,2);
是什么意思,请前辈解释的详细点,谢谢了!
我看的懂了,我们的坐标都是从0横向开始,而时钟以垂直向上方向开始,所以得旋转90度,当半径为1的时候,化为弧度为1.57,至于前面的是旋转了几弧度,还是谢谢各位了! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询