php8.5
Home/ Manual/ imagick / imagickdraw/ ImagickDraw::circle

ImagickDraw::circle

PHP function Edit on GitHub ✎

(PECL imagick 2, PECL imagick 3)

Draws a circle

Description

ImagickDraw::circle(float $origin_x, float $origin_y, float $perimeter_x, float $perimeter_y): bool

Func

Draws a circle on the image.

Parameters

origin_x

origin x coordinate

origin_y

origin y coordinate

perimeter_x

perimeter x coordinate

perimeter_y

perimeter y coordinate

Return Values

Void

Examples

ImagickDraw::circle() example

php
<?php
function circle($strokeColor, $fillColor, $backgroundColor, $originX, $originY, $endX, $endY) {

    //Create a ImagickDraw object to draw into.
    $draw = new \ImagickDraw();

    $strokeColor = new \ImagickPixel($strokeColor);
    $fillColor = new \ImagickPixel($fillColor);

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    $draw->circle($originX, $originY, $endX, $endY);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

Source: reference/imagick/imagickdraw/circle.xml · from the official PHP manual (php/doc-en)