PHP | ImagickDraw bezier() Function

The ImagickDraw::bezier() function is an inbuilt function in Imagick library of PHP which is used to draw bezier curve.

Syntax:

bool ImagickDraw::bezier( $coordinates )

Parameters: This function accepts a single parameter as the multidimensional array which takes the points through which curve is to be made.

Return Value: This function does not return any value.

Below program illustrates the ImagickDraw::bezier() function in PHP:



Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// require_once('vendor/autoload.php');
  
$draw = new \ImagickDraw();
  
$strokeColor = new \ImagickPixel('Green');
$fillColor = new \ImagickPixel('Red');
  
$draw->setStrokeOpacity(1);
$draw->setStrokeColor('Green');
$draw->setFillColor('Red');
  
$draw->setStrokeWidth(2);
  
$pointsSet = [
        [
            ['x' => 10.0 * 5, 'y' => 10.0 * 5],
            ['x' => 30.0 * 5, 'y' => 90.0 * 5],
            ['x' => 25.0 * 5, 'y' => 10.0 * 5],
            ['x' => 50.0 * 5, 'y' => 50.0 * 5],
        ]
    ];
  
foreach ($pointsSet as $points) {
   $draw->bezier($points);
}
  
// Create an image object which draw commands 
// can be rendered into
$imagick = new \Imagick();
$imagick->newImage(300, 300, 'White');
$imagick->setImageFormat("png");
  
// Render the draw commands in the 
// ImagickDraw object into the image.
$imagick->drawImage($draw);
  
// Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

chevron_right


Output:
Image

Reference: http://php.net/manual/en/imagickdraw.bezier.php




My Personal Notes arrow_drop_up

Image
Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.