Friday, October 17, 2025
HomeLanguagesPHP | ImagickDraw bezier() Function

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:




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


Output:

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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS