ImagickDraw::pathMoveToAbsolute()函數是PHP中的內置函數,用於使用絕對坐標在給定坐標處啟動新的sub-path。然後,當前點成為指定的坐標。此函數用於在開始繪製任何東西之前設置初始坐標。
用法:
bool ImagickDraw::pathMoveToAbsolute( float $x, float $y )
參數:該函數接受上述和以下描述的兩個參數:
- $x:它指定x坐標。
- $y:它指定y坐標。
返回值:成功時此函數返回TRUE。
異常:該函數在錯誤時引發ImagickException。
下麵給出的程序說明了PHP中的ImagickDraw::pathMoveToAbsolute()函數:程序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 stroke width
$draw->setStrokeWidth(30);
$draw->pathStart();
// Setting the stating point to (400, 40)
$draw->pathMoveToAbsolute(400, 40);
// Setting the end point to (500, 40)
$draw->pathLineToHorizontalAbsolute(500);
$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();
$color = ['blue', 'red', 'green'];
// Set the stroke width
$draw->setStrokeWidth(5);
// Draw lines
for ($x = 0; $x < 20; $x++) {
$draw->setStrokeColor($color[$x % 3]);
$draw->pathStart();
// Moving to next vertical line
$draw->pathMoveToAbsolute($x * 40, 0);
$draw->pathLineToVerticalRelative(800);
$draw->pathFinish();
}
for ($x = 0; $x < 20; $x++) {
$draw->setStrokeColor($color[$x % 3]);
$draw->pathStart();
// Moving to next horizontal line
$draw->pathMoveToAbsolute(0, $x * 40);
$draw->pathLineToHorizontalRelative(800);
$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.pathmovetoabsolute.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothAbsolute()用法及代碼示例
- PHP ImagickDraw pathStart()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw setFontSize()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setTextAntialias()用法及代碼示例
- PHP ImagickDraw setTextDecoration()用法及代碼示例
- PHP ImagickDraw setTextUnderColor()用法及代碼示例
- PHP ImagickDraw polygon()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw pathMoveToAbsolute() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。