rush4hire
10-02-2005, 08:03 AM
I found this cool script.
From here.
http://www.php.net/manual/en/ref.image.php
It will produce a gif of stick men drawn by this code. The gif will appear in the folderwhere you have the script you executed.
<?php
// 0
$img = imagecreatetruecolor(300,300);
$bgcol = imagecolorallocate($img,255,255,255);
$hatcol = imagecolorallocate($img,rand(128,255),rand(128,255),rand(128,255));
$headcol = imagecolorallocate($img,255,225,205);
$bodycol = imagecolorallocate($img,0,0,0);
$eyecol = imagecolorallocate($img,rand(100,200),rand(0,128),rand(128,255));
$mouthcol = imagecolorallocate($img,rand(128,255),0,0);
imagefill($img,0,0,$bgcol);
// 1
imagefilledellipse($img,60,71,50,50,$headcol);
imagefilledpolygon($img,array(30,53,60,23,90,53),3,$hatcol);
imagesetthickness($img,5);
imageline($img,60,97,60,201,$bodycol);
imagesetthickness($img,1);
imagefilledellipse($img,50,65,7,5,$eyecol);
imagefilledellipse($img,70,65,7,5,$eyecol);
imagesetthickness($img,8);
imageline($img,60,201,10,251,$bodycol);
imageline($img,60,201,110,251,$bodycol);
imageline($img,60,136,10,186,$bodycol);
imageline($img,60,136,110,186,$bodycol);
imagesetthickness($img,3);
imageline($img,50,80,60,90,$mouthcol);
imageline($img,60,90,70,80,$mouthcol);
// 2
$hatcol = imagecolorallocate($img,rand(128,255),rand(128,255),rand(128,255));
$headcol = imagecolorallocate($img,255,225,205);
$bodycol = imagecolorallocate($img,0,0,0);
$eyecol = imagecolorallocate($img,rand(100,200),rand(0,128),rand(128,255));
$mouthcol = imagecolorallocate($img,rand(128,255),0,0);
imagefilledellipse($img,200,71,50,50,$headcol);
imagefilledpolygon($img,array(170,53,200,23,230,53),3,$hatcol);
imagesetthickness($img,5);
imageline($img,200,97,200,201,$bodycol);
imagesetthickness($img,1);
imagefilledellipse($img,190,65,7,5,$eyecol);
imagefilledellipse($img,210,65,7,5,$eyecol);
imagesetthickness($img,8);
imageline($img,200,201,150,251,$bodycol);
imageline($img,200,201,250,251,$bodycol);
imageline($img,200,136,150,186,$bodycol);
imageline($img,200,136,250,186,$bodycol);
imagesetthickness($img,3);
imageline($img,190,80,200,90,$mouthcol);
imageline($img,200,90,210,80,$mouthcol);
// 3
imagestring($img,2,223,283,"(C) Shadikka",$bodycol);
imagesetthickness($img,1);
imagerectangle($img,0,0,299,299,$bodycol);
header("Content-type: image/png");
imagegif($img,'something.gif');
imagedestroy($img);
?>
I want to create an animaged gif.
I can parse a warcraft replay and get the coordinants every action in the game. Now I want to draw a gif with code that will simulate the play in the game.
Don't wanna explain all that now. But if anyone knows how to use php image functions to create an animated gif I would really appriciate it.
Here's a random example of the output my current php replay parser produces.
http://e.domaindlx.com/rush4hire/w3g/brrj_kalotxPINK2_522171.htm
Thanks. :)
From here.
http://www.php.net/manual/en/ref.image.php
It will produce a gif of stick men drawn by this code. The gif will appear in the folderwhere you have the script you executed.
<?php
// 0
$img = imagecreatetruecolor(300,300);
$bgcol = imagecolorallocate($img,255,255,255);
$hatcol = imagecolorallocate($img,rand(128,255),rand(128,255),rand(128,255));
$headcol = imagecolorallocate($img,255,225,205);
$bodycol = imagecolorallocate($img,0,0,0);
$eyecol = imagecolorallocate($img,rand(100,200),rand(0,128),rand(128,255));
$mouthcol = imagecolorallocate($img,rand(128,255),0,0);
imagefill($img,0,0,$bgcol);
// 1
imagefilledellipse($img,60,71,50,50,$headcol);
imagefilledpolygon($img,array(30,53,60,23,90,53),3,$hatcol);
imagesetthickness($img,5);
imageline($img,60,97,60,201,$bodycol);
imagesetthickness($img,1);
imagefilledellipse($img,50,65,7,5,$eyecol);
imagefilledellipse($img,70,65,7,5,$eyecol);
imagesetthickness($img,8);
imageline($img,60,201,10,251,$bodycol);
imageline($img,60,201,110,251,$bodycol);
imageline($img,60,136,10,186,$bodycol);
imageline($img,60,136,110,186,$bodycol);
imagesetthickness($img,3);
imageline($img,50,80,60,90,$mouthcol);
imageline($img,60,90,70,80,$mouthcol);
// 2
$hatcol = imagecolorallocate($img,rand(128,255),rand(128,255),rand(128,255));
$headcol = imagecolorallocate($img,255,225,205);
$bodycol = imagecolorallocate($img,0,0,0);
$eyecol = imagecolorallocate($img,rand(100,200),rand(0,128),rand(128,255));
$mouthcol = imagecolorallocate($img,rand(128,255),0,0);
imagefilledellipse($img,200,71,50,50,$headcol);
imagefilledpolygon($img,array(170,53,200,23,230,53),3,$hatcol);
imagesetthickness($img,5);
imageline($img,200,97,200,201,$bodycol);
imagesetthickness($img,1);
imagefilledellipse($img,190,65,7,5,$eyecol);
imagefilledellipse($img,210,65,7,5,$eyecol);
imagesetthickness($img,8);
imageline($img,200,201,150,251,$bodycol);
imageline($img,200,201,250,251,$bodycol);
imageline($img,200,136,150,186,$bodycol);
imageline($img,200,136,250,186,$bodycol);
imagesetthickness($img,3);
imageline($img,190,80,200,90,$mouthcol);
imageline($img,200,90,210,80,$mouthcol);
// 3
imagestring($img,2,223,283,"(C) Shadikka",$bodycol);
imagesetthickness($img,1);
imagerectangle($img,0,0,299,299,$bodycol);
header("Content-type: image/png");
imagegif($img,'something.gif');
imagedestroy($img);
?>
I want to create an animaged gif.
I can parse a warcraft replay and get the coordinants every action in the game. Now I want to draw a gif with code that will simulate the play in the game.
Don't wanna explain all that now. But if anyone knows how to use php image functions to create an animated gif I would really appriciate it.
Here's a random example of the output my current php replay parser produces.
http://e.domaindlx.com/rush4hire/w3g/brrj_kalotxPINK2_522171.htm
Thanks. :)