imagefilledrectangle

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

imagefilledrectangle绘制矩形并填充

说明

imagefilledrectangle(
    GdImage $image,
    int $x1,
    int $y1,
    int $x2,
    int $y2,
    int $color
): bool

在指定 image 中创建一个从点 1 开始到点 2 结束的的矩形并填充 color。0, 0 是图像的左上角。

参数

image

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

x1

点 1 的 x 坐标。

y1

点 1 的 y 坐标。

x2

点 2 的 x 坐标。

y2

点 2 的 y 坐标。

color

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

返回值

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

更新日志

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

范例

示例 #1 imagefilledrectangle() 用法

<?php
// Create a 55x30 image
$im = imagecreatetruecolor(55, 30);
$white = imagecolorallocate($im, 255, 255, 255);

// Draw a white rectangle
imagefilledrectangle($im, 4, 4, 50, 25, $white);

// Save the image
imagepng($im, './imagefilledrectangle.png');
imagedestroy($im);
?>

以上例程的输出类似于:

示例输出:imagefilledrectangle()

add a note

User Contributed Notes

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