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

polygon image

SLAVE CODE FOLLOWS

<?php
// create a blank image that is 400 by 300 pixels in size
$image imagecreate(400300);

// set the background color to #EEEEEE
$na imagecolorallocate($image238238238);

// BLUE color for triangle
$color imagecolorallocate($image00255);

// Triangle coordinates
$triangle = array(1020100200300200);
$pts count($triangle) / 2;

// Outline + filled triangle
imagepolygon($image$triangle$pts$color);
imagefilledpolygon($image$triangle$pts$color);

// Frame coordinates
$frame = array(0,0399,0399,2990,2990,0);
$pts count($frame) / 2;

// RED frame
$color imagecolorallocate($image25500);
imagepolygon($image$frame$pts$color);

// Tell browser a PNG image is coming
header("Content-type: image/png");

// Output image
imagepng($image);

// Free memory
imagedestroy($image);
?>