Open In App

PHP | ImagickDraw pathCurveToQuadraticBezierAbsolute() Function

Improve
Improve
Like Article
Like
Save
Share
Report

The ImagickDraw::pathCurveToQuadraticBezierAbsolute() function is an inbuilt function in PHP which is used to draw a quadratic Bezier curve which is nothing but a parametric quadratic curve.

Syntax:

bool ImagickDraw::pathCurveToQuadraticBezierAbsolute( 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 control point.
  • $y1: It specifies y-coordinate of the 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::pathCurveToQuadraticBezierAbsolute() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
$draw->setFillColor('white');
  
// Set the stroke color
$draw->setStrokeColor('red');
  
// Draw curve to Quadratic Bezier Absolute (with pathClose())
$draw->pathStart();
$draw->pathCurveToQuadraticBezierAbsolute(150, 250, 950, 250);
$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, 'white');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
$draw->setFillColor('white');
  
// Set the stroke color
$draw->setStrokeColor('blue');
  
// Draw curve to Quadratic Bezier Absolute (without pathClose())
$draw->pathStart();
$draw->pathCurveToQuadraticBezierAbsolute(350, 250, 750, 250);
$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.pathcurvetoquadraticbezierabsolute.php



Last Updated : 17 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads