Monday, December 22, 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
32456 POSTS0 COMMENTS
Milvus
111 POSTS0 COMMENTS
Nango Kala
6823 POSTS0 COMMENTS
Nicole Veronica
11958 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12038 POSTS0 COMMENTS
Shaida Kate Naidoo
6958 POSTS0 COMMENTS
Ted Musemwa
7203 POSTS0 COMMENTS
Thapelo Manthata
6911 POSTS0 COMMENTS
Umr Jansen
6890 POSTS0 COMMENTS