旋转的文字
这段程序放在<body>与</body>之间
<script language=javascript>
Phrase="时时真情在,处处爱飞来"
Balises=""
Taille=40;
Midx=100;
Decal=0.5;
Nb=Phrase.length;
for (x=0;x<Nb;x++){
Balises=Balises + '<DIV Id=L' + x + ' STYLE="width:3;font-family: Courier New;font-weight:bold;position:absolute;top:320;left:400;z-index:0">' + Phrase.charAt(x) + '</DIV>'
}
document.write (Balises);
Time=window.setInterval("Alors()",10);
Alpha=5;
I_Alpha=0.05;
function Alors(){
Alpha=Alpha-I_Alpha;
for (x=0;x<Nb;x++){
Alpha1=Alpha+Decal*x;
Cosine=Math.cos(Alpha1);
Ob=document.all("L"+x);
Ob.style.posLeft=Midx+100*Math.sin(Alpha1)+400;
Ob.style.zIndex=20*Cosine;
Ob.style.fontSize=Taille+25*Cosine;
Ob.style.color="rgb("+ (233+Cosine*80+50) + ","+ (127+Cosine*80+50) + ",0)";
}
}
</script>
Phrase="时时真情在,处处爱飞来" Balises="" Taille=40; Midx=100; Decal=0.5; Nb=Phrase.length; |
声明一些变量,并赋初值。 |
for (x=0;x<Nb;x++) { Balises=Balises + '<DIV Id=L' + x + ' STYLE= "width:3;font-family: Courier New; fontweight:bold;position:absolute; top:320;left:400;z-index:0">' + Phrase.charAt(x) + '</DIV>' }
|
定义要显示的字的颜色,位置,字体。 |
document.write (Balises); Time=window.setInterval("Alors()",10);
|
输出文字,每10毫秒,变化一次。 |
Alpha=5; I_Alpha=0.05;
|
声明一些变量,并赋初值。 |
function Alors() { Alpha=Alpha-I_Alpha; for (x=0;x<Nb;x++) { Alpha1=Alpha+Decal*x;
|
设置文字的透明度的变化。 |
Cosine=Math.cos(Alpha1);
|
声明变量Cosine,值是一个余弦函数在0到360度之间的变化。 |
Ob=document.all("L"+x); Ob.style.posLeft=Midx+ 100*Math.sin(Alpha1)+400; Ob.style.zIndex=20*Cosine; Ob.style.fontSize=Taille+25*Cosine;
|
定义输出文字的位置,深度和字体大小。 |
Ob.style.color="rgb("+ (233+Cosine*80+50) + ","+ (127+Cosine*80+50) + ",0)"; } } |
定义输出文字的颜色。 | |
留言区(共0条)