2023-08-30

在PHP中的imagefilledrectangle()函数

imagefilledrectangle() 函数绘制一个填充矩形。

语法

imagefilledrectangle( $img, $x1, $y1, $x2, $y2, $color )
登录后复制

参数

  • image

    使用imagecreatetruecolor()创建一个空白图像。

  • x1

    点1的x坐标。

  • y1

    点1的y坐标。

  • x2

    点2的x坐标。

  • y2

    点2的y坐标。

  • color

    填充颜色。

返回值

imagefilledrectangle()函数成功返回TRUE,失败返回FALSE。

示例

以下是一个示例:

<?php
   // Create an image
   $img = imagecreatetruecolor(500, 300);
   $color = imagecolorallocate($img, 0, 128, 128);
   imagefilledrectangle($img, 30, 30, 470, 270, $color);
   header("Content-type: image/png");
   imagepng($img);
   imagedestroy($img);
?>
登录后复制

输出

以下是输出结果:

在PHP中的imagefilledrectangle()函数

以上就是在PHP中的imagefilledrectangle()函数的详细内容,更多请关注php中文网其它相关文章!

https://www.php.cn/faq/599798.html

发表回复

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