contents   index   previous   next



GD rectangle()

syntax:

gd.rectangle(x1, y1, x2, y2, color)

gd.rectangle(point1, point2, color)

where:

x1 - horizontal pixel location of first corner

 

y1 - vertical pixel location of first corner

 

x2 - horizontal pixel location of second corner

 

y2 - horizontal pixel location of second corner

 

point1 - First point specification.

 

point2 - Second point specification.

 

color - color index or style to use for drawing line

 

return:

void.

 

description:

This method draws a rectangle with one corner located at position (x1, y1) and the other at position (x2, y2). The color used is specified by the color parameter. Alternatively, the coordinates can be specified with the point format. If either corner is out of bounds, then no drawing is done. Note that this is a shorthand function, as this can be accomplished in several other ways.

 

see:

#link <gd>, GD filledRectangle(), GD polygon()

 

example:

var gd = new GD(10,10);

gd.rectangle( 4, 5, 8, 9, 0 );

 

// is equivalent to:

var gd = new GD(10,10);

gd.line( [4,5], [8,5],  0 );

gd.line( [4,9], [8,9],  0 );

gd.line( [4,5], [4,9],  0 );

gd.line( [8,5], [8,9],  0 );

 

// which is also equivalent to:

var gd = new GD(10,10);

gd.polygon( [ [4,5], [8,5], [4,9], [8,9] ], 0 );

 


GD red()