imagefilledpolygon 


gd apg

DRAW a filled polygon with specified image file points.





The number of elements in $points must be equal to twice the number in $num_points.

This function returns TRUE on success or FALSE on failure.



<?php

bool imagefilledpolygon 
GdImage $image
                                              array 
$points
                                                  
int $num_points
                                                  
int $color )

where,

$image The image identifier 

$points 
An ARRAY containing the 
                              coordinates of the polygon vertices

$num_points 
The number of vertices of the polygon

$color 
The color fill as returned by imagecolorallocate

?>
 

  $image   


The image identifier.



  $points   


An ARRAY containing the coordinates of the polygon vertices.



  $num_points   


The number of vertices of the polygon.



  $color   


The color fill identifier created by imagecolorallocate.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$base_img "jpeg/JPEG 029 01 Mary.jpg";

$dest_img "jpeg/JPEG 029 01 Mary imagefilledpolygon.jpg";

echo 
'Existing Image<br><br>' 
basename($base_img) . '<br><br>'?>

<img src="<?php echo $base_img?>
alt="<?php echo $base_img?>" width="400"><br><br><br>

<?php

$id_polig 
imagecreatefromjpeg$base_img);

$colorln imagecolorallocate($id_polig2550255);

$star = [191,90209,142264,143220,177
                         
236,230191,199146,231
                         
161,177119,143172,143]; 
                         
$starv = (count($star)/2); ;

imageantialias($id_polig1);

$polystar 
imagefilledpolygon($id_polig$star$starv$colorln);

$quality 90;

imagejpeg($id_polig,  $dest_img$quality);

echo 
basename($dest_img); ?><br><br><img src="<?php echo  
$dest_img?>" alt="<?php echo $dest_img?>" width="400"> 


 RESULT   

JPEG 029 01 Mary.jpg

Existing image

JPEG 029 01 Mary.jpg apr

JPEG 029 01 Mary imagefilledpolygon.jpg

Resulting Image

JPEG 029 01 Mary imagefilledpolygon.jpg apr