ImageSetStyle

(PHP 4 >= 4.0.6)

ImageSetStyle -- Set the style for line drawing

Description

int imagesetstyle ( resource im, 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.

The style parameter is an array of pixels. Following example script draws a dashed line from upper left to lower right corner of the canvas:

P°φklad 1. ImageSetStyle

<?php
Header ("Content-type: image/png");
$im  = imagecreate (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");
ImageColorTransparent($brush, $w);
ImageSetBrush($im, $brush);
ImageLine($im, 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);

ImagePng($im);
ImageDestroy ($im);
?>

See also ImageSetBrush(), ImageLine().

Poznßmka: This function was added in PHP 4.0.6