Here is the end effect:
http://www.webdevlogs.com/2007/03/30/simple-version-matrix-like-animated-dropping-character-effect-in-php

Like most animated effects I will ever make, it needs GIFEncoder class.

include('GIFEncoder.class.php');
ob_start();
$msg = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()-_=+`[]{};:?/.,<>\\|"';
$length = strlen($msg);
$max_x = 400; //image x size
$max_y = 400; //image y size
$font_file = 'cour.ttf';//font, best monospace
$font_size = 10;//font site
$grid = 10;//gridient of the fonts
$measuer = imagettfbbox(10,0,$font_file,'1');
$space = 5;//space between letters
$char_height = $measuer[1] - $measuer[7] + $space;
$char_width = $measuer[2] - $measuer[0] + $space;
$i = 1;
$colorimage = imagecreatetruecolor(1,1);
$color[1] = imagecolorallocate($colorimage, 255, 255, 255);
while($i<$grid){

$color[] = imagecolorallocate($colorimage, 0, 255-20*$i, 0);
++$i;
}
imagedestroy($colorimage);
//ENOUGH TEXT TO FILL THE PAGE.
$width = ceil($max_x/$char_width);
$height = ceil($max_y/$char_height);

$x = 0;
while($x < $width){
    $y = 0;
    while($y < $height){
        $text[$x][$y] = $msg[rand(0,$length)];
        ++$y;
    }
    $drop[$x] = rand(0, $width);
    ++$x;
}
$i = 0;
while($i<$height+$grid){
    $image = imagecreatetruecolor($max_x, $max_y);
    $x = 0;
    while($x < $width){
        $y = 0;

    while($y < $drop[$x]){
        if($drop[$x]-$y<=$grid){
            imagettftext($image, $font_size, 0, $x*$char_width, ($y+1)*$char_height-$space, $color[$drop[$x]-$y], $font_file, $text[$x][$y]);
        }
        ++$y;
    }
    if($drop[$x]<$height+$grid){
        ++$drop[$x];
    }else{
        $drop[$x] = 0;
    }
    ++$x;
}
imagegif($image);
$imagedata[$i] = ob_get_contents();
imagedestroy($image);
ob_clean();
++$i;
}

$gif = new GIFEncoder(
                            $imagedata,
                            100,
                            0,
                            2,
                            0, 0, 0,
                            "bin"
        );
Header ( 'Content-type:image/gif' );
echo    $gif->GetAnimation ();

    Very nifty.

    That's all I really have to say lol!

      Write a Reply...