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(0, 100);
    
$green = mt_rand(0, 100);
    
$blue = mt_rand(0, 100);
    
$k = mt_rand(0, 100) /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(125, 100, 100, 70, 0, 360);

    
$imagick = new Imagick();
    
$imagick->newImage(500, 200, $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(0, 100);
    
$green = mt_rand(0, 100);
    
$blue = mt_rand(0, 100);
    
$k = mt_rand(0, 100) /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(1, 300);
    
$oy = mt_rand(1, 100);
    
    
$rx = mt_rand(1, 300);
    
$ry = mt_rand(1, 100);
    
    
$start = mt_rand(0, 360);
    
$end = mt_rand(0, 360);

    
$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(500, 200, $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(222, 222, 198, 34, 357, 108)

img/results/13new el2.png apr

  3 EXERCISE   

<?php

// Run multiple time

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

    
$red = mt_rand(0, 100);
    
$green = mt_rand(0, 100);
    
$blue = mt_rand(0, 100);
    
$k = mt_rand(0, 100) /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(125, 70, 100, 50, 0, 360);
    
$draw->ellipse(350, 70, 100, 50, 0, 315);

    
$draw->push();
    
$draw->translate(125, 250);
    
$draw->rotate(30);
    
$draw->ellipse(0, 0, 100, 50, 0, 360);
    
$draw->pop();

    
$draw->push();
    
$draw->translate(350, 250);
    
$draw->rotate(30);
    
$draw->ellipse(0, 0, 100, 50, 0, 315);
    
$draw->pop();

    
$imagick = new Imagick();
    
$imagick->newImage(500, 400, $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