ImagickDraw::circle

(PECL imagick 2.0.0)

ImagickDraw::circleDraws a circle

Описание

bool ImagickDraw::circle ( float $ox , float $oy , float $px , float $py )
Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.

Draws a circle on the image.

Список параметров

ox

origin x coordinate

oy

origin y coordinate

px

perimeter x coordinate

py

perimeter y coordinate

Возвращаемые значения

Эта функция не возвращает значения после выполнения.

Коментарии

This example creates a circle, one part green, one part red using kind of masks for transparency, which you might know from Photoshop. drawImage() is a quick helper for debug output (see code comments) to help you reproduce the process.

<?php
function drawImage(Imagick $im) {
   
$im->setCompressionQuality(100);
   
$im->setImageFormat("jpg");
   
header("Content-Type: image/" $im->getImageFormat());
    echo 
$im;
    exit;
}

// define red/green layer
$layer1 = new Imagick();
$layer1->newImage(100100"none");

$red = new ImagickDraw();
$red->setFillColor("#FF0000");
$red->rectangle(0050100);

$green = new ImagickDraw();
$green->setFillColor("#00FF00");
$green->rectangle(500100100);

$layer1->drawImage($red);
$layer1->drawImage($green);

# debug output: two rectangles
# drawImage($layer1);

// define circle mask
$layer2 = new Imagick();
$layer2->newImage(100100"none");

$circle = new ImagickDraw();
$circle->setFillColor("#FFFFFF");
$circle->circle(50504898);

$layer2->drawImage($circle);

# debug output: the mask
# drawImage($layer2);

// use mask
$layer1->compositeImage($layer2Imagick::COMPOSITE_DSTIN00);

# debug output: the result of our mask usage
# drawImage($layer1);

// define background
$layer3 = new Imagick();
$layer3->newImage(100100"none");

$layer3->compositeImage($layer1Imagick::COMPOSITE_DEFAULT00);

// define ring as background
$layer4 = new Imagick();
$layer4->newImage(100100"white"); // this is our background

$ring1 = new ImagickDraw();
$ring1->setFillColor("black");
$ring1->circle(50505099);

$layer4->drawImage($ring1);

# debug output: this is a black circle (not our mask, which is similar, but a little bit smaller)
# drawImage($layer4);

// use black circle as background (this creates our circle border)
$layer4->compositeImage($layer3Imagick::COMPOSITE_DEFAULT00);

# debug output: here we go with our circle border
# drawImage($layer4);

// draw separator between red and green rectangle (now semi circles)
$line = new ImagickDraw();
$line->setStrokeWidth(1);
$line->setStrokeColor("black");
$line->line(5015099);

// add our separator line
$layer4->drawImage($line);

drawImage($layer4);
?>

To understand how the COMPOSITE_* constants effect the image merging process, see here:
http://www.imagemagick.org/Usage/compose/#duff-porter
2009-06-23 16:31:47
http://php5.kiev.ua/manual/ru/function.imagickdraw-circle.html
<?php
// OR we could just draw a simple circle for the benefit of the newbies.
// I'm not great at OOP programming and I hope my comments are accurate.
// commets or criticism are welcome.

$image = new Imagick();    // Create a new instance an $image class

$width 600;        // Some necessary dimensions
$height 400

// $image class now inherits some attributes. i.e. Dimensions, bkgcolor...
$image->newImage$width$height, new ImagickPixel'lightgray' ) );

$draw = new ImagickDraw();    //Create a new drawing class (?)

$draw->setFillColor('wheat');    // Set up some colors to use for fill and outline
$draw->setStrokeColor( new ImagickPixel'green' ) );

$draw->circle$width/2$height/2$width/2$width/);    // Draw the circle already 

$image->drawImage$draw );    // Apply the stuff from the draw class to the image canvas

$image->setImageFormat('jpg');    // Give the image a format

header('Content-type: image/jpeg');     // Prepare the web browser to display an image
echo $image;                // Publish it to the world!

//$image->writeImage('someimage.jpg");    // ...Or just write it to a file...

?>
2010-02-24 21:34:02
http://php5.kiev.ua/manual/ru/function.imagickdraw-circle.html

    Поддержать сайт на родительском проекте КГБ