1. First, you need to confirm the GD library is normal. 2. If you are composing a picture, be sure to place the exploded image in the frames folder. 3. GIFEncoder.class.php class
- Include "GIFEncoder.class.php";
- Ob_start ();
- $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;
- $x = 0;
- $y = rand (0, $game _height);
- $XV = rand (1,10);
- $YV = rand (1,10);
- $pt [] = Array ($x, $y);
- do{
- $x + = $XV;
- $y + = $yv;
- if ($x > $game _width) {
- $XV = -1* $XV;
- $x = $game _width-($x-$game _width);
- }elseif ($x < 0) {
- $XV = -1* $XV;
- $x = ABS ($x);
- }
- if ($y > $game _height) {
- $yv = -1* $yv;
- $y = $game _height-($y-$game _height);
- }elseif ($y <0) {
- $yv = -1* $yv;
- $y = ABS ($y);
- }
- $pt [] = Array ($x, $y);
- }while ($x! = $pt [0][0]| | $y! = $pt [0][1]);
- $i = 0;
- while (Isset ($pt [$i])) {
- $image = Imagecreate ($board _width, $board _height);
- Imagecolorallocate ($image, 0,0,0);
- $color = Imagecolorallocate ($image, 255,255,255);
- $color 2 = imagecolorallocate ($image, 255,0,0);
- if ($pt [$i][1] + $pad _height < $board _width) {
- Imagefilledrectangle ($image, 0, $pt [$i][1], $pad _width, $pt [$i][1]+ $pad _height, $color);
- }else{
- Imagefilledrectangle ($image, 0, $board _width-$pad _height, $pad _width, $board _width, $color);
- }
- Imagefilledrectangle ($image, $board _width-$pad _width,0, $board _width, $board _height, $color 2);
- Imagefilledrectangle ($image, $pad _width+ $pt [$i][0], $ball _size+ $pt [$i][1]-$ball _size, $pad _width+ $pt [$i][0]+ $ball _size, $ball _size+ $pt [$i][1], $color);
- Imagesetpixel ($image, $pt [$i][0], $pt [$i][1], $color);
- Imagegif ($image);
- Imagedestroy ($image);
- $imagedata [] = Ob_get_contents ();
- Ob_clean ();
- + + $i;
- }
- $gif = new Gifencoder (
- $imagedata,
- 100,
- 0,
- 2,
- 0, 0, 1,
- "Bin"
- );
- Header (' content-type:image/gif ');
- echo $gif->getanimation ();
- ?>
Copy Code |