Dutch PHP Conference 2025 - Call For Papers

ImagickDraw::circle

(PECL imagick 2, PECL imagick 3)

ImagickDraw::circleDraws a circle

Опис

public ImagickDraw::circle(
    float $ox,
    float $oy,
    float $px,
    float $py
): bool
Увага

Наразі ця функція не документована. Доступний лише список її параметрів.

Draws a circle on the image.

Параметри

ox

origin x coordinate

oy

origin y coordinate

px

perimeter x coordinate

py

perimeter y coordinate

Значення, що повертаються

Не повертає значень.

Приклади

Приклад #1 ImagickDraw::circle() example

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

?>

add a note

User Contributed Notes 1 note

up
10
SkepticaLee
10 years ago
The four values required here are a bit confusing. After all, a circle is defined by three values: the x, y coordinates of the centre, and the radius, r.

The fourth value is redundant, but has to be given, otherwise the function fails. One way of coping with this redundancy is:

<?php
$draw
= new ImagickDraw ();
//given that $x and $y are the coordinates of the centre, and $r the radius:
$draw->circle ($x, $y, $x + $r, $y);
?>

There are any number of actions which are synonymous with the last, including:
<?php
$draw
->circle ($x, $y, $x, $y + $r);
$draw->circle ($x, $y, $x - $r, $y);
$draw->circle ($x, $y, $x, $y - $r);
// etc, etc.
?>

Hope this helps.
To Top