在 `$draw->pathStart()` 和 `$draw->pathFinish()` 之间,您需要以 `$draw->pathMoveToAbsolute(x, y)` 开始初始化位置。所有后续对“路径函数”(包括绝对函数)的调用都将继续路径。
我期望 `pathStart` 接受起始坐标,而我花了一段时间才意识到您需要使用不同的函数进行初始化。(PECL imagick 2, PECL imagick 3)
ImagickDraw::pathStart — 声明路径绘制列表的开始
此函数目前未记录;仅提供其参数列表。
声明路径绘制列表的开始,该列表由匹配的 DrawPathFinish() 命令终止。所有其他 DrawPath 命令都必须包含在一个 DrawPathFinish() 命令之间。这是因为路径绘制命令是下属命令,它们本身不起作用。
不返回值。
示例 #1 ImagickDraw::pathStart() 示例
<?php
function pathStart($strokeColor, $fillColor, $backgroundColor) {
 $draw = new \ImagickDraw();
 $draw->setStrokeOpacity(1);
 $draw->setStrokeColor($strokeColor);
 $draw->setFillColor($fillColor);
 $draw->setStrokeWidth(2);
 $draw->setFontSize(72);
 $draw->pathStart();
 $draw->pathMoveToAbsolute(50, 50);
 $draw->pathLineToAbsolute(100, 50);
 $draw->pathLineToRelative(0, 50);
 $draw->pathLineToHorizontalRelative(-50);
 $draw->pathFinish();
 $draw->pathStart();
 $draw->pathMoveToAbsolute(50, 50);
 $draw->pathMoveToRelative(300, 0);
 $draw->pathLineToRelative(50, 0);
 $draw->pathLineToVerticalRelative(50);
 $draw->pathLineToHorizontalAbsolute(350);
 $draw->pathclose();
 $draw->pathFinish();
 $draw->pathStart();
 $draw->pathMoveToAbsolute(50, 300);
 $draw->pathCurveToAbsolute(50, 300, 100, 200, 300, 300);
 $draw->pathLineToVerticalAbsolute(350);
 $draw->pathFinish();
 $imagick = new \Imagick();
 $imagick->newImage(500, 500, $backgroundColor);
 $imagick->setImageFormat("png");
 $imagick->drawImage($draw);
 header("Content-Type: image/png");
 echo $imagick->getImageBlob();
}
?>