手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Php编程>列表

PHP Javascript模拟Matrix画面

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
直接存为*.php文件运行即可。

<?
$color_back="#000000";
$number_w=8;
$number_h=6;
$space=1;
$font_size=20;
$speed=0;
?>
<html>
<head>
<title>The Matrix</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<script language="javascript">
// *****************************************************************
// Written By Caocao
// caocao@eastday.com
// http://caocao.oso.com.cn
// *****************************************************************
number_h=<? echo $number_h;?>;
number_w=<? echo $number_w;?>;
step=5;
text=new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
grad=new Array("#000000","#004000","#008000","#00C000","#00FF00");

function line()
{
this.start=100;
this.end=60;
this.restart=0;
}

function randchar()
{
return (text[Math.round(Math.random()*25)]);
}

function initial()
{
matrix=new Array();
light=new Array();
for (i=0;i<number_h;i )
{
for (j=0;j<number_w;j )
{
matrix[i*number_h j]="<? echo $color_back;?>";
}
}
for (j=0;j<number_w;j )
{
light[j]=new line();
}
}

function new_light()
{
for (j=0;j<number_w;j )
{
if (light[j].restart==0)
{
light[j].start=0;
light[j].end=-10-Math.round(Math.random()*20);
light[j].restart=light[j].end-Math.round(Math.random()*20);
}
else
{
light[j].start ;
light[j].end ;
light[j].restart ;
}
}
}

function new_color(i,j)
{
if ((light[j].start-i)<5&&(light[j].start-i)>0)
{
return (light[j].start-i);
}
if ((i-light[j].end)<5&&(i-light[j].end)>0)
{
return (i-light[j].end);
}
if ((i-light[j].end)>4&&(light[j].start-i)>4)
{
return (4);
}
return (0);
}

function display()
{
for (i=0;i<number_h;i )
{
for (j=0;j<number_w;j )
{
eval("w" i "h" j).innerHTML="<font color=" grad[new_color(i,j)] ">" randchar() "</font>";
}
}
}

function show()
{
new_light();
display();
setTimeout("show()",<? echo $speed;?>);
}
</script>
<style type="text/css">
<!--
<?
echo ".size,tr,td { font-size: ".$font_size."pt; line-height: ".$font_size."pt ;color:#00FF00}n";
?>
-->
</style>
</head>

<?
echo "<body bgcolor=".$color_back.">";

echo "<table width=".($number_w*$font_size)." border=0 cellspacing=".$space." cellpadding=0>";
for ($i=0;$i<$number_h;$i )
{
echo "<tr>";
for ($j=0;$j<$number_w;$j )
{
echo "<td id=w".$i."h".$j.">M</td>";
}
echo "</tr>";
}
echo "</table>";
?>

<script language="javascript">
initial();
show();
</script>
</body>
</html>

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!