imagesetstyle 


gd apg

DRAW a styled line in an image.





This function returns TRUE on success or FALSE on failure.



<?php

bool imagesetstyle 
GdImage $image, array $style )


where,

$image The image identifier

$style 
An ARRAY of pixel colors
            
SEE the below TABLE )

?> 

  $image   


The image identifier.



  $style   


An ARRAY of pixel colors.

IMAGE COLOR STYLE OPTIONS
CONSTANT VALUE MEANING
IMG_COLOR_STYLED -2 The stroke will have style
IMG_COLOR_BRUSHED -3 The stroke will be brushed
IMG_COLOR_STYLEDBRUSHED -4 The stroke will have brushed style
IMG_COLOR_TILED -5 The stroke will be decorated, (tiled)
IMG_COLOR_TRANSPARENT -6 The stroke will have transparent regions
ed48


  1 EXERCISE   

<?php

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

$sup_img "png/baseXx.png";
$dst_img "png/PNG 055 01 baseXx-imagesetstyle.png";

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

<?php
$id_12 
imagecreatefrompng$sup_img);

$white imagecolorallocate($id_12255255255);

$red1 imagecolorallocate($id_1225500);
$green1 imagecolorallocate($id_1202550);
$blue1 imagecolorallocate($id_1200255);

$red2 imagecolorallocate($id_126000);
$green2 imagecolorallocate($id_120600);
$blue2 imagecolorallocate($id_120060);

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   6px red+1px white+6px green+1px white+6px blue
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

$style1 = array ($red1$red1$red1$red1$red1
$red1$white$green1$green1$green1$green1
$green1$green1$white$blue1$blue1$blue1
$blue1$blue1$blue1);

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   3px red+2px transp+3px green+2px transp+3px blue
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

$style2 = array ($red2$red2$red2, -6
-
6$green2$green2$green2, -6
-
6$blue2$blue2$blue2);

imagesetstyle($id_12$style1);
$line1 imageline($id_123030340250, -2);

imagesetstyle($id_12$style2);
$line2 imageline($id_1234050100250, -2);

imagepng($id_12,  $dst_img );

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

<?php
imagedestroy
($id_12);

?> 

 RESULT   

baseXx.png

baseXx.png apr


PNG 055 01 baseXx-imagesetstyle.png

PNG 055 01 baseXx-imagesetstyle.png apr