PHP.nl

imagesetstyle

imagesetstyle

Set the style for line drawing

bool **imagesetstyle** GdImage $image array $style
sets the style to be used by all

line drawing functions (such as and ) when drawing with the special color or lines of images with color . imagesetstyle``imageline``imagepolygon``IMG_COLOR_STYLED``IMG_COLOR_STYLEDBRUSHED

style An array of pixel colors. You can use the constant to add a transparent pixel. Note that must not be an empty . IMG_COLOR_TRANSPARENT``style``array

return.success

Following example script draws a dashed line from upper left to lower right corner of the canvas:

Voorbeeld: example

<?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);

$brush = imagecreatefrompng("http://www.libpng.org/pub/png/images/smile.happy.png");
$w2 = imagecolorallocate($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($im, $brush);
imageline($im, 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);

imagejpeg($im);
?>

imagesetbrush``imageline