imagedashedline 


gd apg

DRAW a dashed line in an image.





This function is currently deprecated and can be replaced by the combination of functions: imageline and imagesetstyle.





This function returns TRUE on success or FALSE on failure.



<?php

bool imagedashedline 
GdImage $image
                                               
int $x1int $y1
                                               
int $x2int $y2int $color )


where,

$image The image identifier 

$x1 
The x-coordinate of the start point 

$y1 
The y-coordinate of the start point 

$x2 
The x-coordinate of the end point 

$y2 
The y-coordinate of the end point 

$color 
The fill color as returned by imagecolorallocate

?>
 

  $image   


The image identifier.



  $x1   


x-coordinate of start point.



  $y1   


y-coordinate of start point.



  $x2   


x-coordinate of end point.



  $y2   


y-coordinate of end point.



  $color   


The fill color, a color identifier created by imagecolorallocate.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$lang 'en';

$sup_img "png/baseXx.png";

$res1_img 'png/PNG 056 01 baseXx-imagedashedline.png';

$sup_w 384;
$sup_h 288;

$bg_red 48;
$bg_green 48;
$bg_blue 48;

$id_09 imagecreatefrompng($sup_img);
$bgk_color imagecolorallocate($id_09
                                                    
$bg_red
                                                    
$bg_green
                                                    
$bg_blue);

 echo 
$sup_img?>
<br><br><img src="<?php echo 
$sup_img?>" alt="<?php echo $sup_img?>"><br><br><br>

<?php

$x10 
30;
$y10 40;
$x1N 200;
$y1N 250;

$ln1_red 0;
$ln1_green 0;
$ln1_blue 0;

$ln1_color imagecolorallocate($id_09
                                                   
$ln1_red
                                                   
$ln1_green
                                                   
$ln1_blue);
                                        
imagedashedline($id_09
                            
$x10$y10
                            
$x1N$y1N
                            
$ln1_color);

$x20 100;
$y20 80;
$x2N 120;
$y2N 250;

$ln2_red 255;
$ln2_green 0;
$ln2_blue 0;

$ln2_color imagecolorallocate($id_09
                                                   
$ln2_red
                                                   
$ln2_green
                                                   
$ln2_blue);
                                              
imagedashedline($id_09
                            
$x20$y20
                            
$x2N$y2N
                            
$ln2_color);

imagepng($id_09$res1_img);

echo 
$res1_img?>
<br><br><img src="<?php echo 
$res1_img?>" alt="<?php echo $res1_img?>"><br>


 RESULT   

baseXx.png

baseXx.png apr


PNG 056 01 baseXx-imagedashedline.png

PNG 056 01 baseXx-imagedashedline.png apr

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$lang 'en';

$sup_img "png/baseXx.png";

$res1_img 'png/PNG 057 02 baseXx-imagesetstyle.png';

$sup_w 384;
$sup_h 288;

$id_09 imagecreatefrompng($sup_img);

$bgk_color imagecolorallocate($id_09484848);

$black imagecolorallocate($id_09000);

$red imagecolorallocate($id_0925500);

$white imagecolorallocate($id_09255255255);

echo 
$sup_img?>

<br><br><img src="<?php echo $sup_img?>
alt="<?php echo $sup_img?>"><br><br><br>

<?php

$x10 
30;
$y10 40;
$x1N 200;
$y1N 250;

$style1 = [ $black$black$black$white
    
$white$white$black$black$black
             
$white$white$white$white ];
imagesetstyle($id_09$style1);
imageline($id_09$x10$y10$x1N$y1NIMG_COLOR_STYLED); 

$x20 100;
$y20 80;
$x2N 120;
$y2N 250;

$style2 = [ $red$red$red$white$white
         
$white$red$red$red$white
                    
$white$white$white ];
imagesetstyle($id_09$style2);
imageline($id_09$x20$y20$x2N$y2NIMG_COLOR_STYLED);

imagepng($id_09$res1_img);

echo 
$res1_img?>

<br><br><img src="<?php echo $res1_img?>
alt="<?php echo $res1_img?>"><br>


 RESULT   

baseXx.png

baseXx.png apr


PNG 057 02 baseXx-imagesetstyle.png

PNG 057 02 baseXx-imagesetstyle.png apr

The same result as the previous exercise, but obtained differently through the functions imagesetstyle and imageline.