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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。