Computer >> Computer tutorials >  >> Programming >> PHP

imagefill() function in PHP


The imagefill() function is used to fill the image.

Syntax

imagefill(img, x, y, color)

Parameters

  • img
    Create a blank image with imagecreatetruecolor().

  • x 
    x-coordinate of start point


  • y-coordinate of start point

  • color 
    The fill color.

Return

The imagefill() function returns TRUE on success or FALSE on failure.

Example

The following is an example:

<?php
   $img = imagecreatetruecolor(400, 400);
   $color = imagecolorallocate($img, 190, 255, 120);
   imagefill($img, 0, 0, $color);
   header('Content-type: image/png');
   imagepng($img);
   imagedestroy($img);
?>

Output

The following is the output:

imagefill() function in PHP