(PHP 4 >= 4.0.6, PHP 5, PHP 7)
Set the style for line drawing
bool imagesetstyle ( resource $image, array $style )
imagesetstyle() sets the style to be used by all line drawing functions (such as imageline() and imagepolygon()) when drawing with the special color IMG_COLOR_STYLED
or lines of images with color IMG_COLOR_STYLEDBRUSHED
.
Parameters:
image
An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
style
An array of pixel colors. You can use the IMG_COLOR_TRANSPARENT
constant to add a transparent pixel.
Returns:
Returns TRUE
on success or FALSE
on failure.
Examples:
imagesetstyle() example
Following example script draws a dashed line from upper left to lower right corner of the canvas:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php header( "Content-type: image/jpeg" ); $im = imagecreatetruecolor(100, 100); $w = imagecolorallocate( $im , 255, 255, 255); $red = imagecolorallocate( $im , 255, 0, 0); /* Draw a dashed line, 5 red pixels, 5 white pixels */ $style = array ( $red , $red , $red , $red , $red , $w , $w , $w , $w , $w ); imagesetstyle( $im , $style ); imageline( $im , 0, 0, 100, 100, IMG_COLOR_STYLED); /* Draw a line of happy faces using imagesetbrush() with imagesetstyle */ $style = array ( $w , $w , $w , $w , $w , $w , $w , $w , $w , $w , $w , $w , $red ); imagesetstyle( $im , $style ); $w2 = imagecolorallocate( $brush , 255, 255, 255); imagecolortransparent( $brush , $w2 ); imagesetbrush( $im , $brush ); imageline( $im , 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED); imagejpeg( $im ); imagedestroy( $im ); ?> |
The above example will output something similar to:

See also:
Please login to continue.