ImagickDraw::pathClose()函數是PHP中的內置函數,用於將路徑元素添加到當前路徑,該路徑元素通過繪製直線來關閉當前子路徑。簡而言之,它用於將筆畫完全應用於所有邊。
用法:
bool ImagickDraw::pathClose( void )
參數:此函數不接受任何參數。
返回值:成功時此函數返回TRUE。
以下示例程序旨在說明PHP中的ImagickDraw::pathClose()函數:
示例1:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'black');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Set the stroke color
$draw->setStrokeColor('white');
// Set the stroke width
$draw->setStrokeWidth(5);
// Create a shape with four corners using
// paths with pathClose() function
$draw->pathStart();
$draw->pathMoveToAbsolute(420, 50);
$draw->pathMoveToRelative(20, 0);
$draw->pathLineToRelative(50, 90);
$draw->pathLineToVerticalRelative(30);
$draw->pathLineToHorizontalAbsolute(250);
$draw->pathClose();
$draw->pathFinish();
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>
輸出:
示例2:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Add texts to image
$draw->annotation(100, 200, 'With pathClose()');
$draw->annotation(500, 200, 'Without pathClose()');
// Set the stroke color
$draw->setStrokeColor('green');
// Set the stroke width
$draw->setStrokeWidth(5);
// Create a shape with three coreners using
// paths (with pathClose())
$draw->pathStart();
$draw->pathMoveToAbsolute(20, 50);
$draw->pathMoveToRelative(20, 0);
$draw->pathLineToRelative(50, 90);
$draw->pathLineToVerticalRelative(0);
$draw->pathLineToHorizontalAbsolute(250);
$draw->pathClose();
$draw->pathFinish();
// Create the same shape using
// paths (without pathClose())
$draw->translate(400, 0);
$draw->pathStart();
$draw->pathMoveToAbsolute(20, 50);
$draw->pathMoveToRelative(20, 0);
$draw->pathLineToRelative(50, 90);
$draw->pathLineToVerticalRelative(0);
$draw->pathLineToHorizontalAbsolute(250);
$draw->pathFinish();
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>
輸出:
參考: https://www.php.net/manual/en/imagickdraw.pathclose.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw color()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
- PHP ImagickDraw pathMoveToRelative()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw pathClose() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。