ImagickDraw::pathLineToRelative()函數是PHP中的內置函數,用於使用相對坐標繪製從當前點到給定坐標的線路徑。然後,坐標成為新的當前點。可以使用pathMoveToRelative()函數設置初始點。
用法:
bool ImagickDraw::pathLineToRelative( float $x, float $y )
參數:該函數接受上述和以下描述的兩個參數:
- $x:它指定起始的x坐標。
- $y:它指定起始y坐標。
返回值:成功時此函數返回TRUE。
以下示例程序旨在說明PHP中的ImagickDraw::pathLineToRelative()函數:
示例1:
<?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();
// Set the fill color
$draw->setFillColor('black');
// Create a path
$draw->pathStart();
// Draw a line
// Start coordinates of line
$draw->pathMoveToRelative(350, 50);
// End coordinates of line
$draw->pathLineToRelative(50, 150);
// End the path
$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();
// Set the fill color
$draw->setFillColor('yellow');
// Set the stroke color
$draw->setStrokeColor('black');
// Set the stroke width
$draw->setStrokeWidth(1);
// Create a path
$draw->pathStart();
// Draw a star
$draw->pathMoveToRelative(350, 20);
$draw->pathLineToRelative(40, 60);
$draw->pathLineToRelative(80, 20);
$draw->pathLineToRelative(-80, 30);
$draw->pathLineToRelative(30, 60);
$draw->pathLineToRelative(-50, -20);
$draw->pathLineToRelative(-50, 40);
$draw->pathLineToRelative(10, -70);
$draw->pathLineToRelative(-50, -10);
$draw->pathLineToRelative(50, -30);
$draw->pathLineToRelative(20, -80);
// End the path
$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.pathlinetorelative.php
相關用法
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw destroy()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP ImagickDraw getFillRule()用法及代碼示例
- PHP ImagickDraw getTextEncoding()用法及代碼示例
- PHP ImagickDraw setTextEncoding()用法及代碼示例
- PHP ImagickDraw polyline()用法及代碼示例
- PHP ImagickDraw getClipPath()用法及代碼示例
- PHP ImagickDraw color()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw comment()用法及代碼示例
- PHP ImagickDraw setClipPath()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw pathLineToRelative() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。