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 // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object $imagick ->newImage(800, 250, 'black' ); // Create a new ImagickDraw object $draw = new ImagickDraw(); $draw ->setFillColor( 'black' ); // Set the stroke color $draw ->setStrokeColor( 'red' ); // Draw curves to Quadratic Bezier Relative (with pathClose()) $draw ->pathStart(); $draw ->pathCurveToQuadraticBezierRelative(150, 750, 750, 250); $draw ->pathClose(); $draw ->pathFinish(); $draw ->pathStart(); $draw ->pathCurveToQuadraticBezierRelative(350, 50, 750, 650); $draw ->pathClose(); $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, 'black' ); // Create a new ImagickDraw object $draw = new ImagickDraw(); $draw ->setFillColor( 'black' ); // Set the stroke color $draw ->setStrokeColor( 'green' ); // Draw curves (without pathClose()) $draw ->pathStart(); $draw ->pathCurveToQuadraticBezierRelative(150, 750, 350, 0); $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.pathcurvetoquadraticbezierrelative.php