contents   index   previous   next



GD setStyle()

syntax:

gd.setStyle(style)

where:

style - style to set for current image.

 

return:

void.

 

description:

This method sets the current style for this image, which is used whenever the string "styled" is passed as a color index parameter to a drawing function. The parameters to the method is a list of pixels, which are color indexes or the special value -1, which indicates a transparent pixel. When drawing lines or a series of pixels, the drawing methods cycle through the sequence defined in the current style and applies the color to each successive pixel. If the value of -1 is used, then no color is applied and the background remains.

 

see:

#link <gd>, GD setBrush(), GD setTile()

 

example:

/* Create a Red, Green, Blue,

 * dashed line from the upper left

 * corner of the image to the lower right corner.

 * Each dash will be 3

 * pixels wide, and there will be 3 pixels

 * of space in between.

 */

 

var gd = new GD(64,64);

var red = gd.colorAllocate( 255, 0, 0 );

var green = gd.colorAllocate( 0, 255, 0 );

var blue = gd.colorAllocate( 0, 0, 255 );

gd.setStyle(red, red, red,

            -1, -1, -1, 

            green, green, green,

            -1, -1, -1,

            blue, blue, blue,

            -1, -1, -1 );

gd.line( [0,0], [63,63], "styled" );

 


GD setTile()