ImagickDraw::pathLineToVerticalAbsolute()函數是PHP中的內置函數,用於使用絕對坐標繪製從當前點到目標點的垂直線路徑。然後,目標點將成為新的當前點。
用法:
bool ImagickDraw::pathLineToVerticalAbsolute( float $y )
參數:該函數接受一個包含y坐標的單個參數$y。
返回值:成功時此函數返回TRUE。
異常:該函數在錯誤時引發ImagickException。
下麵給出的程序說明了PHP中的ImagickDraw::pathLineToVerticalAbsolute()函數:
程序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(5);
// Draw a verticle line
$draw->pathStart();
$draw->pathMoveToRelative(400, 0);
$draw->pathLineToVerticalAbsolute(800);
$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 stroke color
$draw->setStrokeColor('black');
// Set the stroke width
$draw->setStrokeWidth(5);
// Draw lines
$draw->pathStart();
for($x = 0; $x < 15; $x++) {
$draw->pathMoveToRelative(50, 0);
if($x % 2) {
$draw->pathLineToVerticalAbsolute(0);
} else {
$draw->pathLineToVerticalAbsolute(1000);
}
}
$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.pathlinetoverticalabsolute.php
注:本文由純淨天空篩選整理自 PHP | ImagickDraw pathLineToVerticalAbsolute() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。