Isaac's code for Draw a Polygon (lines and square)

polygon

SLAVE CODE FOLLOWS

<?php    // create a PNG image file

// create a blank image that is 400 by 300 pixels in size
$image = imagecreate(400, 300);

// set the background color to RGB (238, 238, 238) which is the same as #EEEEEE HEX
$na = imagecolorallocate($image, 238, 238, 238);    // var $na is not used

// set the current foreground color to RGB (0, 0, 255) which is BLUE
$color = imagecolorallocate ($image, 200, 0, 105);

// populate the polygon (a triangle) with paired x-y coordinates
$triangle = array(10,20, 10,200, 300,200 );

// number of coordinates (pairs) in the $triangle
$pts = count($triangle)/2;

// draw the polygon on the image using current color
imagepolygon($image, $triangle, $pts, $color);

// draw a filled polygon on the image using current color
imagefilledpolygon($image, $triangle, $pts, $color);

// populate the polygon (a frame)    with paired x-y coordinates
$frame = array(0,0 , 399,0 , 399,299 , 0,299, 0,0);

// number of coordinates (pairs) in the frame
$pts = count($frame)/2;

// set the current foreground color to RGB (255, 0, 0) which is RED
$color = imagecolorallocate ($image, 255, 0, 0);

// draw the frame on the image using current color
imagepolygon($image, $frame, $pts, $color);

// tell the server that a PNG image  follows
header("Content-type: image/png");

// display the image
imagepng($image);

// destroy the image (i.e., release memory)
imagedestroy ($image);

?>