PHP ImagickDraw pathLineToVerticalAbsolute() Function

PHP ImagickDraw::pathLineToVerticalAbsolute() function is an inbuilt function in PHP that is used to draw a vertical line path from the current point to the target point using absolute coordinates. The target point then becomes the new current point.Â
Syntax:
bool ImagickDraw::pathLineToVerticalAbsolute( float $y )
Parameters: This function accepts a single parameter $y which holds the y-coordinate.
Return Value: This function returns TRUE on success.Â
Exceptions: This function throws ImagickException on error.Â
Below given programs illustrate the ImagickDraw::pathLineToVerticalAbsolute() function in PHP:Â
Program 1:Â
php
<?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 vertical 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();?> |
Output:
 
Program 2:Â
php
<?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();?> |
Output:
 
Reference: https://www.php.net/manual/en/imagickdraw.pathlinetoverticalabsolute.php
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!



