contents   index   previous   next

GD rectangle()


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

gd.rectangle(point1, point2, color)


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






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.



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



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()