imagepolygon() creates a polygon in the given image.
PHP imagepolygon() function has the following syntax.
bool imagepolygon ( resource $image , array $points , int $num_points , int $color )
PHP imagepolygon() function has the following parameters.
Take a look at the following code:
$myPoints = array( 20, 20,
185, 55,
70, 80 );
imagepolygon( $myImage, $myPoints, 3, $myBlack );
This example creates an array of the polygon's points, called $myPoints. There are six elements in the array, or three x/y coordinate pairs.
This means that there are three corners to this polygon: at (20,20), (185,55), and (70,80).
Returns TRUE on success or FALSE on failure.
<?php//from ww w .j a v a 2 s. c o m
// Create a blank image
$image = imagecreatetruecolor(400, 300);
// Allocate a color for the polygon
$col_poly = imagecolorallocate($image, 255, 255, 255);
// Draw the polygon
imagepolygon($image, array(
0, 0,
100, 200,
300, 200
),
3,
$col_poly);
// Output the picture to the browser
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>