This example shows how to make polygon Shapes in php gd Library.
This example shows how to make polygon Shapes in php gd Library.<?php
$points = shape(8,100); $points = translatePolygon($points,100,100);$image = imagecreatetruecolor(200,200); $white = imagecolorallocate($image,255,255,255);
imagefill(
$image,0,0,$white); $red = imagecolorallocate($image,150,0,0);imagefilledpolygon(
$image,$points,(count($points)/2),$red);
header(
"Content-type: image/jpeg");imagejpeg(
$image);imagedestroy(
$image);function shape($number_of_edges,$radius=100) {
}
return $p;}
function translatePolygon($points,$x=0,$y=0) { for($i=0;$i<count($points);$i+=2) {
$points[
$i+1] = $points[$i+1] + $y;}
}
?>
After running the program you will get the following output