<?php
header ('Content-type:image/gif');
include('GIFEncoder.class.php');
$x = 200;
$y = 200;
$image = @imagecreate($x,$y )
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($image, 0, 0, 0);

 
$corners[0] = array('x' => 100, 'y' =>  10);
$corners[1] = array('x' =>   0, 'y' => 190);
$corners[2] = array('x' => 200, 'y' => 190);

$red = imagecolorallocate($image, 255, 0, 0); 


$ii=200;
for ($i = 0; $i < 100000; $i++) {
  imagesetpixel($image, round($x),round($y), $red);
  $a = rand(0, 2);
  $x = ($x + $corners[$a]['x']) / 2;
  $y = ($y + $corners[$a]['y']) / 2;
  if($i>$ii)
  {
  $ii=$i+200;
      ob_start();
      imagegif($image);
      $frames[]=ob_get_contents();
      $framed[]=40;

      // Delay in the animation.
      ob_end_clean();
  }
}
 



// Generate the animated gif and output to screen.
$gif = new GIFEncoder($frames,$framed,0,2,0,0,0,'bin');
echo $gif->GetAnimation();
?>