ImagickDraw::ellipse


wizard apg

DRAWS an ellipse on one image.



<?php

bool 
public ImagickDraw::ellipse(
                                             
float $ox,
                                             
float $oy,
                                             
float $rx,
                                             
float $ry,
                                             
float $start,
                                             
float $end
                                                         
);

?>

$ox


The origin X coordinate.



$oy


The origin Y coordinate.



$rx


The rotate X coordinate.



$ry


The rotate Y coordinate.



$start


The start coordinate.



$end


The end coordinate.





This function returns a TRUE on success.



  1 EXERCISE   

<?php

// Run multiple time

$str1img 'img/results/13new el.png';

    
$red mt_rand(0100);
    
$green mt_rand(0100);
    
$blue mt_rand(0100);
    
$k mt_rand(0100) /100;
    
    
$strokeColor "rgb($red,$green,$blue)";
    
    
$c = [ 'cyan''red''green''blue'];
    
$n mt_rand(0,3);
    
$fillColor $c[$n];
    
$backgroundColor "cmyk($red,$green,$blue,$k)";

    
$draw = new ImagickDraw();
    
$draw->setStrokeColor($strokeColor);
    
$draw->setFillColor($fillColor);

    
$draw->setStrokeWidth(2);

    
$draw->ellipse(125100100700360);

    
$imagick = new Imagick();
    
$imagick->newImage(500200$backgroundColor);
    
$imagick->setImageFormat("png");

    
$str $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?>">

13new el.png

ellipse(125, 100, 100, 70, 0, 360))

img/results/13new el.png apr

  2 EXERCISE   

<?php

// Run multiple time

$str2img 'img/results/13new el2.png';

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

    
$strokeColor "rgb($red,$green,$blue)";
    
    
$c = [ 'cyan''red''green''blue'];
    
$n mt_rand(0,3);
    
$fillColor $c[$n];
    
$backgroundColor "cmyk($red,$green,$blue,$k)";
    
    
$ox mt_rand(1300);
    
$oy mt_rand(1100);
    
    
$rx mt_rand(1300);
    
$ry mt_rand(1100);
    
    
$start mt_rand(0360);
    
$end mt_rand(0360);

    
$draw = new ImagickDraw();
    
    
$draw->setStrokeColor($strokeColor);
    
$draw->setFillColor($fillColor);

    
$draw->setStrokeWidth(5);

    
$draw->ellipse($ox$ox$rx$ry$start$end);

    
$imagick = new Imagick();
    
$imagick->newImage(500200$backgroundColor);
    
$imagick->setImageFormat("png");

    
$str $imagick->drawImage($draw);
    
    
$str $imagick->getImageBlob();
    
    
$img imagecreatefromstring($str);
    
    
imagepng($img$str2img);
    
    echo 
basename($str2img); ?>
<br><br>
<?php echo "ellipse($ox$ox$rx$ry$start$end)<br><br>"?>
<img src="<?php echo $str2img?>"
 alt="<?php echo $str2img?>
 title="<?php echo $str2img?>">

13new el2.png

ellipse(230, 230, 4, 31, 201, 287)

img/results/13new el2.png apr

  3 EXERCISE   

<?php

// Run multiple time

$str3img 'img/results/13new el3.png';

    
$red mt_rand(0100);
    
$green mt_rand(0100);
    
$blue mt_rand(0100);
    
$k mt_rand(0100) /100;
    
    
$strokeColor "rgb($red,$green,$blue)";
    
    
$c = [ 'cyan''red''green''blue'];
    
$n mt_rand(0,3);
    
$fillColor $c[$n];
    
$backgroundColor "cmyk($red,$green,$blue,$k)";

    
$draw = new ImagickDraw();
    
$draw->setStrokeColor($strokeColor);
    
$draw->setFillColor($fillColor);

    
$draw->setStrokeWidth(2);

    
$draw->ellipse(12570100500360);
    
$draw->ellipse(35070100500315);

    
$draw->push();
    
$draw->translate(125250);
    
$draw->rotate(30);
    
$draw->ellipse(00100500360);
    
$draw->pop();

    
$draw->push();
    
$draw->translate(350250);
    
$draw->rotate(30);
    
$draw->ellipse(00100500315);
    
$draw->pop();

    
$imagick = new Imagick();
    
$imagick->newImage(500400$backgroundColor);
    
$imagick->setImageFormat("png");

    
$str $imagick->drawImage($draw);
    
    
$str $imagick->getImageBlob();
    
    
$img imagecreatefromstring($str);
    
    
imagepng($img$str3img);
    
    echo 
basename($str3img); ?>
<br><br>
<img src="<?php echo $str3img?>"
 alt="<?php echo $str3img?>
 title="<?php echo $str3img?>">

 RESULT   

13new el3.png

img/results/13new el3.png apr