Tutorialspoint.dev

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 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:

<?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();
?>

/div>

Output:

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



This article is attributed to GeeksforGeeks.org

You Might Also Like

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter