imagesetbrush 


gd apg

SET the brush image for line drawing.





This function sets the brush image to be used by all line drawing functions, such as imageline and imagepolygon when filling with the special colors IMG_COLOR_BRUSHED or IMG_COLOR_STYLEDBRUSHED.

Special attention should be taken when we are finished with a brush, but if we destroy the brush image, (or let PHP destroy it), we must not use the IMG_COLOR_BRUSHED or IMG_COLOR_STYLEDBRUSHED colors until we have set a new brush image.

This function returns TRUE on success or FALSE on failure.



<?php

bool imagesetbrush 
GdImage $imageGdImage $brush )

where,

$image The image identifier

$brush 
The image identifier to be used as a brush

?>
 

  $image   


The image identifier.



  $brush   


The image identifier to be used as a brush.



IMAGE COLOR STYLE OPTIONS


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>';

$obase_img "png/baseXx.png";

$brush_img "png/PNG 073 01.png";

$dbase_img "png/PNG 073 01 imagesetbrush.png";

$id_obase imagecreatefrompng($obase_img);

$white imagecolorallocate($id_obase255255255);
$yellow imagecolorallocate($id_obase2552550);

$arr_st_white = array($white$white);

echo 
basename($brush_img); ?><br><br>
<img src="<?php echo $brush_img?>
alt="<?php echo $brush_img?>
title="<?php echo $brush_img?>">
<br><br>

<?php echo basename($obase_img); ?><br><br>
<img src="<?php echo $obase_img?>"
alt="<?php echo $obase_img?>
title="<?php echo $obase_img?>">
<br><br><br>

<?php

$id_brush 
imagecreatefrompng($brush_img);
imagefill($id_brush00$yellow);
imagesetbrush($id_obase$id_brush);
imagesetstyle($id_obase$arr_st_white);

$x0 50;
$y0 50;

$xN 250;
$yN 250;

imageline($id_obase$x0$y0
                                  
$xN$yN
                                  
IMG_COLOR_STYLEDBRUSHED);

imagepng($id_obase$dbase_img);

echo 
basename($dbase_img); ?><br><br>
<img src="<?php echo $dbase_img?>
alt="<?php echo $dbase_img?>
title="<?php echo $dbase_img?>">



 RESULT   

PNG 073 01.png

Existing Image to be used as a brush.

PNG 073 01.png apr

baseXx.png

Existing image to which the yellow star brush will be applied.

baseXx.png apr


PNG 073 01 imagesetbrush.png

Resulting Image.

PNG 073 01 imagesetbrush.png apr