PHP | ImagickDraw pathCurveToQuadraticBezierRelative() Function
The ImagickDraw::pathCurveToQuadraticBezierRelative() function is an inbuilt function in PHP which is used to draw a quadratic Bezier curve which is nothing but a parametric quadratic curve. Only difference between pathCurveToQuadraticBezierAbsolute() and pathCurveToQuadraticBezierRelative() is that the later uses the relative control points while former uses absolute points.
Syntax:
bool ImagickDraw::pathCurveToQuadraticBezierRelative( float $x1,
float $y1, float $x, float $y )
Parameters: This function accepts four parameters as mentioned above and described below:
- $x1: It specifies x-coordinate of the relative control point.
- $y1: It specifies y-coordinate of the relative control point.
- $x: It specifies x-coordinate of the end point.
- $y: It specifies y-coordinate of the end point.
Return Value: This function returns TRUE on success.
Below programs illustrate the ImagickDraw::pathCurveToQuadraticBezierRelative() function in PHP:
Program 1:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'black' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'black' );
$draw ->setStrokeColor( 'red' );
$draw ->pathStart();
$draw ->pathCurveToQuadraticBezierRelative(150, 750, 750, 250);
$draw ->pathClose();
$draw ->pathFinish();
$draw ->pathStart();
$draw ->pathCurveToQuadraticBezierRelative(350, 50, 750, 650);
$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 ->setFillColor( 'black' );
$draw ->setStrokeColor( 'green' );
$draw ->pathStart();
$draw ->pathCurveToQuadraticBezierRelative(150, 750, 350, 0);
$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.pathcurvetoquadraticbezierrelative.php
Last Updated :
17 Dec, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...