array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagefilledrectangle.php', 1 => 'imagefilledrectangle', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imagefilledpolygon.php', 1 => 'imagefilledpolygon', ), 'next' => array ( 0 => 'function.imagefilltoborder.php', 1 => 'imagefilltoborder', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagefilledrectangle.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
imagefilledrectangle — 绘制矩形并填充
在指定 image
中创建一个从点 1 开始到点 2 结束的的矩形并填充
color
。0, 0 是图像的左上角。
image
由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。
x1
点 1 的 x 坐标。
y1
点 1 的 y 坐标。
x2
点 2 的 x 坐标。
y2
点 2 的 y 坐标。
color
填充颜色。颜色标识符使用 imagecolorallocate() 创建。
示例 #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);
?>
以上示例的输出类似于: