ImagickDraw::circle


wizard apg

DRAWS a circle.



<?php

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

?>

$ox


The origin X coordinate.



$oy


The origin Y coordinate.



$px


The perimeter X coordinate.



$py


The perimeter Y coordinate.





This function returns a TRUE on success.



  1 EXERCISE   

<?php

// Run multiple time

$str1img 'img/results/12new cr.png';

    
$red mt_rand(0100);
    
$green mt_rand(0100);
    
$blue mt_rand(0100);
    
$k mt_rand(0100) /100;

$c = [ 'cyan''red''green''blue'];
$n mt_rand(0,3);

$strokeColor "rgb($red,$green,$blue)";
$fillColor $c[$n];
$backgroundColor "cmyk($red,$green,$blue,$k)";

$originX 180;
$originY 180;

$endX 250;
$endY 250;

$draw = new ImagickDraw();

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

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

    
$draw->setStrokeWidth(2);

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

    
$imagick = new Imagick();
    
$imagick->newImage(400300$backgroundColor);
    
$imagick->setImageFormat("png");
    
$imagick->drawImage($draw);
    
    
$str=$imagick->getImageBlob();
    
    
$img imagecreatefromstring($str);
    
    
imagepng($img$str1img);
    
    echo 
basename($str1img); ?>
<br><br>
<img src="<?php echo $str1img?>"
 alt="<?php echo $str1img?>
 title="<?php echo $str1img?>">

 RESULT   

12new cr.png

img/results/12new cr.png apr