區域填充

imagefill

(PHP 4, PHP 5, PHP 7, PHP 8)

imagefill — 區域填充

說明

imagefill(
    resource $image,
    int $x,
    int $y,
    int $color
): bool

imagefill() 在 image 影象的座標 x,y(影象左上角為 0, 0)處用 color 顏色執行區域填充(即與 x, y 點顏色相同且相鄰的點都會被填充)。

示例 #1 imagefill() 例子

<?php

$im 
= imagecreatetruecolor(100, 100);

// 將背景設為紅色
$red = imagecolorallocate($im, 255, 0, 0);
imagefill($im, 0, 0, $red);

header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

參見 imagecolorallocate()。

Leave a Reply

Your email address will not be published. Required fields are marked *