Draw rectangles.
#include <graph.h>
short __far _rectangle( short control, short x1, short y1, short x2, short y2 );
short __far _rectangle_w( short control, double wx1, double wy1, double wx2,
double wy2 );
short __far _rectangle_wxy( short control, struct _wxycoord __far *pwxy1,
struct _wxycoord __far *pwxy2 );
control | Fill flag | |
x1, y1 | Upper-left corner | |
x2, y2 | Lower-right corner | |
wx1, wy1 | Upper-left corner | |
wx2, wy2 | Lower-right corner | |
pwxy1 | Upper-left corner | |
pwxy2 | Lower-right corner |
The _rectangle functions draw a rectangle with the current line style. The _rectangle function uses the view coordinate system. The view coordinate points (x1, y1) and (x2, y2) are the diagonally opposed corners of the rectangle.
The _rectangle_w function uses the window coordinate system. The window coordinate points (wx1, wy1) and (wx2, wy2) are the diagonally opposed corners of the rectangle.
The _rectangle_wxy function uses the window coordinate system. The window coordinate points (pwxy1) and (pwxy2) are the diagonally opposed corners of the rectangle. The coordinates for the _rectangle_wxy routine are given in terms of an _wxycoord structure (defined in GRAPH.H), which contains the following elements:
Element | Description |
double wx | window x coordinate |
double wy | window y coordinate |
The control parameter can be one of the following manifest constants:
Constant | Action |
_GFILLINTERIOR | Fills the figure, using a scanfill algorithm, with the current color using the current fill mask |
_GBORDER | Does not fill the rectangle |
If the current fill mask is NULL, no mask is used. Instead, the rectangle is filled with the current color.
If you try to fill the rectangle with the _floodfill function, the rectangle must be bordered by a solid line-style pattern.
The function returns a nonzero value if the rectangle is drawn successfully, or 0 if not.
Standards:None
16-Bit:DOS
32-Bit:None
_arc functions, _ellipse functions, _floodfill, _getcolor, _lineto functions, _pie functions, _polygon, _setcolor, _setfillmask
/* RECT.C: This program draws a rectangle. */
#include <conio.h>
#include <stdlib.h>
#include <graph.h>
void main( void )
{
/* Find a valid graphics mode. */
if( !_setvideomode( _MAXRESMODE ) )
exit( 1 );
_rectangle( _GBORDER, 80, 50, 240, 150 );
_getch();
_setvideomode( _DEFAULTMODE );
}