The imagefilltoborder() function is an inbuilt function in PHP which is used to performs a flood fill with a specific color and add a border with a border color.
Syntax:
php
Output:
Program 2 (Adding fill color to a drawing):
php
Output:
Reference: https://www.php.net/manual/en/function.imagefilltoborder.php
bool imagefilltoborder( resource $image, int $x, int $y, int $border, int $color )Parameters: This function accept five parameters as mentioned above and described below:
- $image: It specifies the image to be worked upon.
- $x: It specifies the x-coordinate of start.
- $y: It specifies the y-coordinate of start.
- $border: It specifies the border color.
- $color: It specifies the fill color.
<?php
// Load the png image
$im = imagecreatefrompng(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Create colors
$borderColor = imagecolorallocate($im, 0, 200, 0);
$fillColor = imagecolorallocate($im, 0, 0, 200);
// Add fill to border
imagefilltoborder($im, 0, 0, $borderColor, $fillColor);
// Show the output
header('Content-type: image/png');
imagepng($im);
?>
Program 2 (Adding fill color to a drawing):
<?php
// Create the image handle, set the background to white
$im = imagecreatetruecolor(800, 250);
imagefilledrectangle($im, 0, 0, 800,
250, imagecolorallocate($im, 0, 255, 0));
// Draw an ellipse to fill with a black border
imageellipse($im, 250, 150, 250, 150,
imagecolorallocate($im, 0, 0, 0));
// Fill the selection
imagefilltoborder($im, 50, 50, imagecolorallocate($im,
0, 0, 0), imagecolorallocate($im, 255, 0, 0));
// Output the image
header('Content-type: image/png');
imagepng($im);
?>
Reference: https://www.php.net/manual/en/function.imagefilltoborder.php