imagefill() 函数用于区域填充。
语法:
bool imagefill( resource image, int x, int y, int color )
x,y 分别为填充的起始 x 坐标和 y 坐标,与 x, y 点颜色相同且相邻的点都会被填充。
例子:
<?php
header("Content-type: image/png");
$im = @imagecreatetruecolor(200, 200);
$red = imagecolorallocate($im, 255, 0, 0);
//用 $red 颜色填充图像
imagefill( $im, 0, 0, $red );
imagepng($im);
imagedestroy($im);
?>
提示:对于用imagecreate()建立的图像,第一次调用imagecolorallocate() 会自动给图像填充背景色。