变幻的文字(修改版)
<html xmlns="http://www.<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>变幻的文字(修改版)</title>
<STYLE type=text/css>
<!--
body
{
scrollbar-arrow-color: red;
scrollbar-base-color: aqua;
background:url(http://mat1.) no-repeat 250px 270px;
}
#idee
{
border:1px solid #e83476;
width: 42%;
height: 25px;
}
-->
</STYLE>
</head>
<body onload="startmotor(0)">
<script language="JavaScript1.2">
var size = 25;
var speed_between_messages=1500
var tekst = new Array()
{
tekst[0] = "故国三千里,深宫二十年。";
tekst[1] = "一声何满子,双泪落君前!";
tekst[2] = "自倚能歌日,先皇掌上怜。";
tekst[3] = "新声何处唱?肠断李延年。";
}
var klaar = 0;
var s = 0;
var veran =0;
var tel = 0;
function bereken(i,Lengte)
{
return (size*Math.abs(Math.sin(i/(Lengte/3.14))) );
}
function motor(p)
{
var output = "";
for(w=0;w<tekst[s].length-klaar;w++)
{
q = bereken(w/2 + p,16);
if (q > size - 0.5)
{klaar++;}
if (veran == 1) //当kaar达到最大植时, 进入下一句
{
veran = 0;
s++; //下一条诗句
if (s == tekst.length)
{s = 0;}
p = 0;
}
output += "<font style='font-size: "+ q +"pt'>" +tekst[s].substring(w,w+1)+ "</font>";
}
for(k=w;k<klaar+w;k++)
{
output += "<font style='font-size: " + size + "pt'>" +tekst[s].substring(k,k+1)+ "</font>";
}
idee.innerHTML = output;
}
/*以下为简要分析诗句长度与字体大小变化(q值)的开头阶段,如有误请指正。
document.write(tekst[2].length+"<p>"); //诗句长度
document.write(Math.sin((0+1)/(16/3.14))+"<br>"); //w=0
document.write(Math.sin((0.5+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((1+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((1.5+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((2+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((2.5+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((3+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((3.5+1)/(16/3.14))+"<br>"); //w=7
document.write(Math.sin((4+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((4.5+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((5+1)/(16/3.14))+"<br>"); //
document.write(Math.sin((5.5+1)/(16/3.14))+"<p>"); //w=11
document.write(Math.sin((0+2)/(16/3.14))+"<br>"); //w=0
document.write(Math.sin((0.5+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((1+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((1.5+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((2+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((2.5+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((3+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((3.5+2)/(16/3.14))+"<br>"); //w=7
document.write(Math.sin((4+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((4.5+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((5+2)/(16/3.14))+"<br>"); //
document.write(Math.sin((5.5+2)/(16/3.14))+"<p>"); //w=11, q>24.5, kaar=1
document.write(Math.sin((0+3)/(16/3.14))+"<br>"); //w=0
document.write(Math.sin((0.5+3)/(16/3.14))+"<br>"); //
document.write(Math.sin((1+3)/(16/3.14))+"<br>"); //
document.write(Math.sin((1.5+3)/(16/3.14))+"<br>"); //
document.write(Math.sin((2+3)/(16/3.14))+"<br>"); //
document.write(Math.sin((2.5+3)/(16/3.14))+"<br>"); //
document.write(Math.sin((3+3)/(16/3.14))+"<br>"); //
document.write(Math.sin((3.5+3)/(16/3.14))+"<br>"); //w=7
document.write(Math.sin((4+3)/(16/3.14))+"<br>"); //
document.write(Math.sin((4.5+3)/(16/3.14))+"<br>"); //w=9, q>24.5, kaar=2,进入下个循环if(k=w...)
document.write(Math.sin((4.5+3)/(16/3.14))+"<br>"); //k=w=9, (大小同上)
document.write(Math.sin((5+3)/(16/3.14))+"<p>"); //k=w=10,
document.write(Math.sin((0+4)/(16/3.14))+"<br>"); //w=0
document.write(Math.sin((0.5+4)/(16/3.14))+"<br>"); //
document.write(Math.sin((1+4)/(16/3.14))+"<br>"); //
document.write(Math.sin((1.5+4)/(16/3.14))+"<br>"); //
document.write(Math.sin((2+4)/(16/3.14))+"<br>"); //
document.write(Math.sin((2.5+4)/(16/3.14))+"<br>"); //
document.write(Math.sin((3+4)/(16/3.14))+"<br>"); //
document.write(Math.sin((3.5+4)/(16/3.14))+"<br>"); //w=7, q>24.5, kaar=3, 进入下个循环if(k=w...)
document.write(Math.sin((3.5+4)/(16/3.14))+"<br>"); //k=w=7, (大小同上)
document.write(Math.sin((4+4)/(16/3.14))+"<br>"); //k=w=8,
document.write(Math.sin((4.5+4)/(16/3.14))+"<br>"); //k=w=9,
document.write(Math.sin((5+4)/(16/3.14))+"<p>"); //k=w=10,
...
*/
function startmotor(p){
if (!document.all)
return
var loopxunhuan = motor(p); //这里可以省略方式直接写motor(p);
if (klaar == tekst[s].length)
{
klaar = 0;
veran = 1;
var time = setTimeout("startmotor(" + (p+1) + ")", speed_between_messages);
}
else
{
var time =setTimeout("startmotor(" + (p+1) + ")", 50);
}
}
</script>
<div ID="idee"></div>
</body>
</html>
[ 本帖最后由 js_friend 于 2011-5-31 19:06 编辑 ]