contents   index   previous   next



GD polygon()

syntax:

gd.polygon(point1[, x2, y2, ...],  color)

where:

pointN - Point specification for Nth point

 

xN - x coordinate of Nth point

 

yN - y coordinate of Nth point

 

color - color index or style to use for line

 

return:

void.

 

description:

This method draws a polygon by connecting sequential points with lines. The parameters are either a pair of parameters indicating the two coordinates of the point, or a point specification type. A point type can either be an array with two elements, element 0 being the x coordinate and element 1 being the y coordinate, or an object with members 'x' and 'y', representing the x and y coordinates.

 

see:

#link <gd>, GD filledPolygon()

 

example:

// Draw a rectangle

function myRectangle(gd,x1,y1,x2,y2,color)

{

   gd.polygon([x1,y1], x1, y2, {x:x2,y:y2}, [x2,y1],

              [x1,y1], color);

}

 


GD rectangle()