PHP imagefilledpolygon Function: Drawing and Filling Polygons
This article explains the PHP imagefilledpolygon function, detailing its parameters, return values, and providing a complete example that creates an image, allocates colors, defines polygon points, draws a filled polygon, outputs the PNG, and cleans up the resources.
The PHP imagefilledpolygon function draws a filled polygon on an image resource using an array of point coordinates, the number of points, and a color.
Parameters: $image – the image resource; $points – an array containing the x and y coordinates of each vertex in order; $num_points – the total number of vertices (must be greater than 3); $color – the color identifier allocated for the polygon.
Return value: On success it returns the image resource; on failure it returns FALSE .
Example usage: The example creates a 250 × 250 true‑color image, allocates a gray background and a blue drawing color, defines six points for the polygon, draws the filled polygon, sends the appropriate header, outputs the image as PNG, and finally destroys the image resource.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.