PHP | ImagickDraw pathLineToAbsolute() Function
Last Updated :
20 Dec, 2019
The ImagickDraw::pathLineToAbsolute() function is an inbuilt function in PHP which is used to draw a line path from the current point to the given coordinate using absolute coordinates. The coordinate then becomes the new current point. The initial point can be set using pathMoveToAbsolute() function.
Syntax:
bool ImagickDraw::pathLineToAbsolute( float $x, float $y )
Parameters: This function accepts two parameters as mentioned above and described below:
- $x: It specifies the starting x-coordinate.
- $y: It specifies the starting y-coordinate.
Return Value: This function returns TRUE on success.
Below programs illustrate the ImagickDraw::pathLineToAbsolute() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'white' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'black' );
$draw ->pathStart();
$draw ->pathMoveToAbsolute(50, 50);
$draw ->pathLineToAbsolute(100, 150);
$draw ->pathFinish();
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'white' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'black' );
$draw ->pathStart();
$draw ->pathMoveToAbsolute(350, 50);
$draw ->pathLineToAbsolute(250, 150);
$draw ->pathLineToAbsolute(350, 150);
$draw ->pathFinish();
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.pathlinetoabsolute.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...