//DEFINE CONTENT TYPE
Header("Content-type: image/png");
//DEFINE BACKGROUND SIZE
$height = 300;
$width = 300;
//TELLS IT TO CREATE BACK (IMAGE) AT DEFINED SIZE
$im = ImageCreate($width, $height);
//TELLS IT WHAT COLOR TO MAKE YOUR BACK (IMAGE)
$bck = ImageColorAllocate($im, 255,255,255);
// SET BACK TO TRANSPARENT.
ImageColorTransparent($im, $bck);
// MAKE YOUR BACKGROUND SHAPE.
imagefilledrectangle($im, 0, 0, 300, 300, $bck);
//COLOR VARIABLES
$maroon = ImageColorAllocate($im, 128, 0, 0);
$pink = ImageColorAllocate($im, 255, 192, 203);
$dodger = ImageColorAllocate($im, 30, 144, 255);
$burly = ImageColorAllocate($im, 222, 184, 135);
$brown = ImageColorAllocate($im, 102, 51, 0);
$seagreen = ImageColorAllocate($im, 46, 139, 87);
$mseagreen = ImageColorAllocate($im, 60, 179, 113);
$grey = imagecolorallocate($im, 128, 128, 128);
$black =imagecolorallocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
$lace = ImageColorAllocate($im, 253, 245, 230);
$goldenrod = ImageColorAllocate($im, 218, 165, 32);
//FUNCTIONS
//THIS SETS THICKNESS OF LINE, DEFAULT IS 1
imagesetthickness($im, 4);
//DRAW RECTANGLES FOR BOXCAR
imagefilledrectangle ($im, 20, 150, 215, 210, $brown);
imagefilledrectangle ($im, 25, 155, 210, 205, $maroon);
//DRAW SMOKESTACK
imagefilledrectangle ($im, 25, 130, 45, 150, $maroon);
imageLine ($im, 25, 130, 25, 150, $brown);
imageLine ($im, 45, 130, 45, 150, $brown);
imageLine ($im, 35, 130, 35, 150, $brown);
imagefilledEllipse ($im, 35, 100, 5, 10, $white);
imagefilledEllipse ($im, 40, 80, 5, 5, $white);
//DRAW WINDOWS AND DOOR
imagefilledrectangle ($im, 42, 165, 59, 180, $brown);
imagefilledEllipse ($im, 50.5, 173.5, 8, 8, $black);
imagefilledrectangle ($im, 76, 165, 93, 180, $brown);
imagefilledEllipse ($im, 84.5, 173.5, 8, 8, $black);
imagefilledrectangle ($im, 110, 165, 127, 205, $brown);
imagefilledrectangle ($im, 144, 165, 161, 180, $brown);
imagefilledEllipse ($im, 152.5, 173.5, 8, 8, $black);
imagefilledrectangle ($im, 178, 165, 193, 180, $brown);
imagefilledEllipse ($im, 186.5, 173.5, 8, 8, $black);
//DRAW WHEELS
imagefilledEllipse ($im, 35, 210, 20, 20, $white);
imagefilledEllipse ($im, 35, 210, 16, 16, $black);
imagefilledEllipse ($im, 60, 210, 20, 20, $white);
imagefilledEllipse ($im, 60, 210, 16, 16, $black);
imageLine ($im, 20, 210, 70, 210, $white);
imagefilledEllipse ($im, 178, 210, 20, 20, $white);
imagefilledEllipse ($im, 178, 210, 16, 16, $black);
imagefilledEllipse ($im, 203, 210, 20, 20, $white);
imagefilledEllipse ($im, 203, 210, 16, 16, $black);
imageLine ($im, 168, 210, 218, 210, $white);
imageLine ($im, 20, 224, 255, 224, $grey);
imageArc ($im, 25, 250, 50, 50, 90, 270, $grey);
//SHOW IMAGE OUTPUT AS PNG
//$im = imagecreatefrompng("test.png");
ImagePNG($im);
//FREE THE IMAGE (CLEAR FROM CACHE)
imagedestroy($im);
?>