GmagickDraw::roundrectangle()

在图像上绘制一个带有圆角的矩形形状

首字母:G

函数名:GmagickDraw::roundrectangle()

适用版本:Gmagick 1.1.0 及以上版本

用法:GmagickDraw::roundrectangle() 方法用于在图像上绘制一个带有圆角的矩形形状。

语法:bool GmagickDraw::roundrectangle(float $x1, float $y1, float $x2, float $y2, float $rx, float $ry)

参数:

  • $x1: 矩形左上角的 x 坐标
  • $y1: 矩形左上角的 y 坐标
  • $x2: 矩形右下角的 x 坐标
  • $y2: 矩形右下角的 y 坐标
  • $rx: 圆角的 x 半径
  • $ry: 圆角的 y 半径

返回值:成功时返回 true,失败时返回 false。

示例:

newImage(400, 300, 'white');
// 创建一个绘图对象
$draw = new GmagickDraw();
// 设置矩形的位置和大小,并指定圆角半径
$x1 = 50;
$y1 = 50;
$x2 = 350;
$y2 = 250;
$rx = 20;
$ry = 20;
// 在图像上绘制圆角矩形
$draw->roundrectangle($x1, $y1, $x2, $y2, $rx, $ry);
// 将绘图对象应用到图像上
$image->drawImage($draw);
// 显示图像
header('Content-Type: image/png');
echo $image;
?>

以上示例代码会创建一个大小为 400x300 像素的白色图像,并在图像上绘制一个左上角坐标为 (50, 50),右下角坐标为 (350, 250) 的圆角矩形,圆角半径为 20。最后将图像显示在浏览器中。

同首字母函数