ImagickDraw::line


wizard apg

DRAWS a line.



<?php

bool 
public ImagickDraw::line(
                                             
float $sx,
                                             
float $sy,
                                             
float $ex,
                                             
float $ey
                                                         
);

?>

$sx


The starting X coordinate.



$sy


The starting Y coordinate.



$ex


The ending X coordinate.



$ey


The ending Y coordinate.





This function returns a TRUE on success.



  1 EXERCISE   

<?php

// Run multiple times

$str1img 'img/results/11new ln.png';

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

$strokeColor1 '#ff25f2';
$strokeColor2 '#fff225';
$strokeColor3 'cyan';
$fillColor "rgb($red,$green,$blue)";
$backgroundColor "cmyk($red,$green,$blue,$k)";

$draw = new ImagickDraw();

    
$draw->setStrokeColor($strokeColor1);
    
$draw->setFillColor($fillColor);

    
$draw->setStrokeWidth(2);

    
$draw->line(1257010050);
    
$draw->line(250170100150);
    
$draw->line(161618016);
    
    
$draw->setStrokeColor($strokeColor2);
    
$draw->setStrokeWidth(6);
    
$draw->line(18260260260);
    
    
$draw->setStrokeColor($strokeColor3);
    
$draw->setStrokeWidth(50);
    
$draw->line(192216250);
    
    
$imagick = new Imagick();
    
$imagick->newImage(300300$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   

11new ln.png

img/results/11new ln.png apr