PHP 8.4.0 RC3 available for testing

ImagickDraw::circle

(PECL imagick 2, PECL imagick 3)

ImagickDraw::circleDesenha um círculo

Descrição

public ImagickDraw::circle(
    float $ox,
    float $oy,
    float $px,
    float $py
): bool
Aviso

Esta função não está documentada; apenas a lista de argumentos está disponível.

Desenha um círculo na imagem.

Parâmetros

ox

coordernada x da origem

oy

coordenada y da origem

px

coordenada x do perímetro

py

coordenada y do perímetro

Valor Retornado

Nenhum valor é retornado.

Exemplos

Exemplo #1 Exemplo de ImagickDraw::circle()

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

//Cria um objeto ImagickDraw onde será desenhado.
$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();
}

?>

adicione uma nota

Notas Enviadas por Usuários (em inglês) 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