PHP | ImagickDraw pathCurveToRelative() Function
Last Updated :
23 Dec, 2019
The ImagickDraw::pathCurveToRelative() function is an inbuilt function in PHP which is used to draw a cubic Bezier curve from the current point to (x, y) using (x1, y1) as the control point at the beginning of the curve and (x2, y2) as the control point at the end of the curve using relative coordinates.
Syntax:
bool ImagickDraw::pathCurveToRelative(
float $x1, float $y1, float
$x2, float $y2, float $x, float $y )
Parameters: This function accepts six parameters as mentioned above and described below:
- $x1: It specifies the x-coordinate of starting control point.
- $y1: It specifies the y-coordinate of starting control point.
- $x2: It specifies the x-coordinate of ending control point.
- $y2: It specifies the y-coordinate of ending control point.
- $x: It specifies the ending x-coordinate.
- $y: It specifies the ending y-coordinate.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickDraw::pathCurveToRelative() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'black' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'black' );
$draw ->setStrokeColor( 'white' );
$draw ->pathStart();
$draw ->pathCurveToRelative(50, 250, 900, 20, 100, 300);
$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, 'black' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'black' );
$draw ->setStrokeColor( 'white' );
$draw ->pathStart();
$draw ->pathCurveToRelative(50, 250, 1900, 20, 100, 300);
$draw ->pathClose();
$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.pathcurvetorelative.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...