Name

fill( ) — floodfill an area with a color

Synopsis

GD::Image::fill(x, y, colorindex)

The fill( ) method will fill an area with a given color. The area to fill is defined by all those pixels neighboring the pixel at x, y that are of the same color as the pixel and are connected by pixels of the same color. The operation is exactly the same as the paint bucket tool in paint programs. The color can be either a color index or the gdTiled special color if you want to fill the area with a tiled pattern. The fill( ) method can be used to draw filled shapes with different colored borders, as in:

# Draw a green-filled circle with a red border
$image->arc(100, 100, 50, 50, 0, 360, $red);
$image->fill(100, 100, $green);

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.