Skip to content
Related Articles

Related Articles

PHP | ImagickDraw pathLineToVerticalAbsolute() Function
  • Last Updated : 30 Dec, 2019

The ImagickDraw::pathLineToVerticalAbsolute() function is an inbuilt function in PHP which 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
  
// 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();
?>

Output:

Program 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();
?>

Output:

Reference: https://www.php.net/manual/en/imagickdraw.pathlinetoverticalabsolute.php

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :