Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

imagefilltoborder

Description

The imagefilltoborder of Image for PHP flood fill to specific color.

Syntax

imagefilltoborder(
    GdImage $image,
    int $x,
    int $y,
    int $border_color,
    int $color
): bool

Parameters

image

A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().

x

x-coordinate of start.

y

y-coordinate of start.

border_color

The border color. A color identifier created with imagecolorallocate().

color

The fill color. A color identifier created with imagecolorallocate().

Return

Returns true on success or false on failure.

Examples

1 · return

<?

$width = 100;
$height = 100;
$image = imagecreate($width, $height);

$red = 0;
$green = 0;
$blue = 0;
$border_color = imagecolorallocate($image, $red, $green, $blue);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$x = 0;
$y = 0;

$return = imagefilltoborder($image, $x, $y, $border_color, $color);
    
var_export($return);

?>
true

2 · base64

<?

$width = 100;
$height = 100;
$image = imagecreatetruecolor($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$border_color = imagecolorallocate($image, $red, $green, $blue);

$center_x = 50;
$center_y = 50;
$width = 100;
$height = 100;
imageellipse($image, $center_x, $center_y, $width, $height, $border_color);

$red = 255;
$green = 0;
$blue = 0;
$color = imagecolorallocate($image, $red, $green, $blue);

$x = 0;
$y = 0;
imagefilltoborder($image, $x, $y, $border_color, $color);

$red = 0;
$green = 255;
$blue = 0;
$color = imagecolorallocate($image, $red, $green, $blue);

$x = 50;
$y = 50;
imagefilltoborder($image, $x, $y, $border_color, $color);

$red = 0;
$green = 0;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$x = 100;
$y = 100;
imagefilltoborder($image, $x, $y, $border_color, $color);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACfElEQVR4nO3dSVbFMBBDUZn977kYmASnL7lJY+vNf5N75BxgQILhBZnrW4QQWn+Riy/wDNZSJ8ClYFi+6na7G7ESIKfOxfsldvfA3YJlhkpAh58AQ3uylljTlJoyLT5w2lojtTZY7ad08flthlYb62mmtOpkVbHMXsKUZrBaXpWw3jSobbUmVgPrlYPaVj6xMqx3D2pb4cQKsD4yqG3ZE/vJ/cCvSgEICOb7bXRVFtaXpWJ5XjzW96ViGV4kVi9SMdaLwepLKkZ5ubF6lIr5vXxY/UrFnF4OrN6lYh6vK6wxpGKXXrk/lA7ZKdZIs4qdj+sYazyp2ImXjiHRAdaos4odjWsPa2yp2K6XjiHRBkuzmtqOS8siWmJpVstW49KyiIRFlGDpDO6VnkQti2jC0qyOm8elZREJi0hYRMGgG5Yrg2lZRMIiEhaRsIiC6e7uTssiEhaRsIiERSQsImERCYtIWETCIhIWkbCIhEUUAOh3aU/6SymXsIiERSQsor/7uu7x5xksBC2LSVhEwiL6v0/ptnVUvGFBy6JaTEnj2jbPCloWlbCI1odOJzEtPYPQsqh2RqRxxVazgpZFtb8gjWs7KxxhYWyvXSnoGFKdbWfMcR3NCudYGM/rRAo6hlTXqxlnXOezggcLY3hdSsGJhd69PFLwY6FfL6cUKCz06OWXAouFvrwoKWRgoRcvVgp5WPi+V4YUsrHwZa88KZRgAbCv/j/4zJfXeFjQRyaWPai5Ohf58okVDmqu5uW9c2Llg5qrfG2vmlitQc01uarHyaozxVo+7OzJZ4U1ef87LuOGoTWa0qr7Toq1fb5h+ftd98xtxeo8ObPmV/L0C1xcKHlmep3wAAAAAElFTkSuQmCC">
</body>
</html>
HomeMenu