Animation

PHP class for gif animations

The gif class is made by SuperRembo back in 2006, very short and compact. View the source here. The old time favorite, GIFEncoder is still at hand, so I did a test and the result shows SuperRembo's gif class is faster after a little modification(my test could be inaccurate because the structure of 2 gif system is different). Take out the ob_start and other part, let the user input the output image instead of the resource provide better result improves speed a thousandfold.
SuperRembo's gif class could be faster because it uses the PHP built in function pack instead of a massive amount of bitwise operators.
Anyone who thinks they can do a better job, read the gif89a specification. Strange, I don't see anything about animated gif in there.

Pong

Never ending Pong animation... Just a entry for the PHP GD contest in June.
PONG

ob_start();
include('GIFEncoder.class.php');
$board_width = 60;
$board_height = 60;
$pad_width = 5;
$pad_height = 15;
$ball_size = 5;
$game_width = $board_width - $pad_width*2 - $ball_size;
$game_height = $board_height-$ball_size;
 
 
//FIND ALL Points
//Initial point
 
$x = 0;
$y = rand(0,$game_height);
$xv = rand(1,10);
$yv = rand(1,10);
$pt[] = array($x,$y);
do{
	$x += $xv;
	$y += $yv;

(Simple version)Matrix like animated dropping character effect in PHP

This code is only for monospaced typefaces, else it will look strange. This is a simplified version of the dropping down characters(or Matrix Digital Rain), I will create more complex ones later.
The end result is something like this
Matrix like animated dropping character effect
Like most animated effects I will ever make, it needs GIFEncoder class.

The basic idea:
On a screen, when one pixel is activated, it lights up. Here, instead of a pixel, it is a character, so I just have to construct a character grid and light them when it is activated.

Although I did not use any code from Nazmul Hassan's PHP Matrix, he is the one who inspired me to make a animated version, and he is especially kindly to give the source code to me.

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 ();

Please download your own true type fonts.

If you want to find a property through the banks, be ready for a detailed scrutiny of your insurance deals as well as credit report.

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);
Syndicate content
Honey Pot that kill bots