ImagickDraw::circle

(PECL imagick 2, PECL imagick 3)

ImagickDraw::circle β€” РисуСт ΠΊΡ€ΡƒΠ³

ОписаниС

public function ImagickDraw::circle(
Β Β Β Β float $origin_x,
Β Β Β Β float $origin_y,
Β Β Β Β float $perimeter_x,
Β Β Β Β float $perimeter_y
): bool
Π’Π½ΠΈΠΌΠ°Π½ΠΈΠ΅

Π€ΡƒΠ½ΠΊΡ†ΠΈΡŽ ΠΏΠΎΠΊΠ° Π½Π΅ Π·Π°Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ΠΈΡ€ΠΎΠ²Π°Π»ΠΈ; для знакомства доступСн Ρ‚ΠΎΠ»ΡŒΠΊΠΎ список Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚ΠΎΠ².

РисуСт ΠΊΡ€ΡƒΠ³ Π½Π° ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΈ.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

origin_x

Π˜ΡΡ…ΠΎΠ΄Π½Π°Ρ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π° X

origin_y

Π˜ΡΡ…ΠΎΠ΄Π½Π°Ρ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π° Y

perimeter_x

ΠšΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π° X ΠΏΠ΅Ρ€ΠΈΠΌΠ΅Ρ‚Ρ€Π°

perimeter_y

ΠšΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π° Y ΠΏΠ΅Ρ€ΠΈΠΌΠ΅Ρ‚Ρ€Π°

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

Ѐункция Π½Π΅ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ значСния послС выполнСния.

ΠŸΡ€ΠΈΠΌΠ΅Ρ€Ρ‹

ΠŸΡ€ΠΈΠΌΠ΅Ρ€ #1 ΠŸΡ€ΠΈΠΌΠ΅Ρ€ использования ImagickDraw::circle()

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

//Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° ImagickDraw для рисования.
$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();
}

?>
οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 1 note

up
11
SkepticaLee ΒΆ
12 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.