PHP | ImagickDraw pathCurveToAbsolute() Function
Last Updated :
17 Dec, 2019
The ImagickDraw::pathCurveToAbsolute() function is an inbuilt function in PHP which is used to draw a cubic Bezier curve which is a parametric curve. This function draws a curve from the current point to (x, y) using beginning control point (x1, y1) to ending control point (x2, y2). In the last command, the new current point becomes the final (x, y) coordinate pair used in the polybezier.
Syntax:
bool ImagickDraw::pathCurveToAbsolute( 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 first control point.
- $y1: It specifies the y-coordinate of first control point.
- $x2: It specifies the x-coordinate of second control point.
- $y2: It specifies the y-coordinate of second control point.
- $x: It specifies the x-coordinate of curve end.
- $y: It specifies the y-coordinate of curve end.
Return Value: This function returns TRUE on success.
Below programs illustrate the ImagickDraw::pathCurveToAbsolute() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'white' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'white' );
$draw ->setStrokeColor( 'green' );
$draw ->setStrokeWidth(5);
$draw ->pathStart();
$draw ->pathCurveToAbsolute(50, 100, 180, 200, 1360, 200);
$draw ->pathFinish();
$draw ->setStrokeColor( 'red' );
$draw ->pathStart();
$draw ->pathCurveToAbsolute(500, 20, 80, 40, 60, 900);
$draw ->pathClose();
$draw ->pathFinish();
$draw ->setStrokeColor( 'blue' );
$draw ->pathStart();
$draw ->pathCurveToAbsolute(50, 50, 80, 20, 1360, 200);
$draw ->pathClose();
$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 ->setStrokeColor( 'white' );
$draw ->setStrokeWidth(5);
$draw ->pathStart();
$draw ->pathCurveToAbsolute(50, 400, 560, 700, 160, 20);
$draw ->pathCurveToAbsolute(1000, 40, 560, 70, 60, 300);
$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.pathcurvetoabsolute.php
Share your thoughts in the comments
Please Login to comment...