Matrix like effect in PHP(Animated)

This is an slow(give it a set_time_limit(10)) and dirty animated matrix ever changing data grid effect:
Matrix Data Grid Effect

You have to have the GIFEncoder class and GD library in order to use make this effect work

include('GIFEncoder.class.php');
$max_x = 468;
$max_y = 60;
$step = 10;
$font_file = 'cour.ttf';
$font_size = 10;
$color = pow(255,2);
$frames = 10;
//repeating frame
//first generate enough lines
$measuer = imagettfbbox(10,0,'cour.ttf','1');
$line_height = $measuer[1] - $measuer[7];
//measuer how many lines
 
$max_line = $max_y/$line_height;
$i = 0;
//Create a list of string
while($i<$frames){
	$n = 0;
	while($n<$max_line){
		$a = imagettfbbox($font_size, 0, $font_file, $tmp);
		if($a[2] - $a[0]>$max_x){
			$text[$i] .= $tmp."\n";
			++$n;
			$tmp = '';
		}else{
			$tmp .= chr(rand(65,90));
		}
	}
	++$i;
}
 
ob_start();
$i = 0;
while($i<$frames){
	$image = imagecreatetruecolor($max_x, $max_y);
	imagettftext($image,$font_size,0,0,$line_height,$color,$font_file,$text[$i]);
	imagegif($image);
	$imagedata[$i] = ob_get_contents();
	ob_clean();
	++$i;
}
 
//gifmerge
$gif = new GIFEncoder(
                            $imagedata,
                            100,
                            0,
                            2,
                            0, 0, 0,
                            "bin"
        ); 
header ( 'Content-type:image/gif' );
echo    $gif->GetAnimation (); 

Comments

Post new comment

  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <fn>
  • Lines and paragraphs break automatically.
  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Mathematical equations and graphs can be added between [tex] and [/tex], [graph] and [/graph] tags.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
  __  __   _             _   _           _   _ 
| \/ | | |__ ___ | \ | | _ _ | | | |
| |\/| | | '_ \ / __| | \| | | | | | | |_| |
| | | | | |_) | \__ \ | |\ | | |_| | | _ |
|_| |_| |_.__/ |___/ |_| \_| \__, | |_| |_|
|___/
Enter the code depicted in ASCII art style.
Honey Pot that kill bots