Php+javascript Analog Matrix Screen

Source: Internet
Author: User
Directly save as *.php file to run.

?
$color _back= "#000000";
$number _w=8;
$number _h=6;
$space = 1;
$font _size=20;
$speed = 0;
?>
<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 ()", the 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>

?
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>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.