Veronica's code for Draw a Polygon (lines and square)
SLAVE CODE FOLLOWS
<?php
// create image
// create a blank image that is 400 by 300 pixels in size
$image = imagecreate(400, 300);
// set the background color to purple
// var $background is not used
$background = imagecolorallocate($image, 152, 13, 186);
// set the current foreground color to RGB (0, 25, 255) which is BLUE-ISH
$blue = imagecolorallocate ($image, 0, 25, 255);
// populate the polygon (a triangle) with paired x-y coordinates
$triangle = array(50,60, 160,240, 300,220 );
// number of coordinates (pairs) in the $triangle
$pts = count($triangle)/2;
// draw the polygon on the image using current color
imagepolygon($image, $triangle, $pts, $blue);
// draw a filled polygon on the image using current color
imagefilledpolygon($image, $triangle, $pts, $blue);
// populate the polygon (an inset frame) with paired x-y coordinates
$frame = array(5,5 , 394,5 , 394,294 , 5,294, 5,5);
// number of coordinates (pairs) in the frame
$pts = count($frame)/2;
// set the current foreground color to RGB (186, 13, 152) which is PURPLE
$red = imagecolorallocate ($image, 255, 0, 0);
// draw the frame on the image using current color
imagepolygon($image, $frame, $pts, $red);
// tell the server that a PNG image follows
header("Content-type: image/png");
// display the image in png format
imagepng($image);
// destroy the image (i.e., release memory)
imagedestroy ($image);
?>