imagefill

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

imagefill漫水填充

说明

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

使用 image 中的指定 color 从指定坐标(左上角为 0,0)开始执行漫水填充。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。

x

起点的 x 坐标。

y

起点的 y 坐标。

color

填充颜色。颜色标识符使用 imagecolorallocate() 创建。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 image 现在需要 GdImage 实例;之前需要有效的 gd resource

范例

示例 #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);
?>

以上例程的输出类似于:

示例输出:imagefill()

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top