[Previous] [Contents] [Index] [Next]

PgDrawRect(), PgDrawIRect()

Draw a rectangle

Synopsis:

int PgDrawRect( PhRect_t const *rect,
                unsigned int flags );

int PgDrawIRect( int ulx, int uly,
                 int lrx, int lry,
                 unsigned int flags );

Description:

These functions build a command in the draw buffer to draw a rectangle. Note that PgDrawRect() requires a pointer to a PhRect_t structure whereas PgDrawIRect() takes individual arguments.

The flags argument must be one of the following:

Pg_DRAW_STROKE
Draw as a line.
Pg_DRAW_FILL
Fill the rectangle.
Pg_DRAW_FILL_STROKE
Fill the rectangle, then stroke it.

For PgDrawIRect(), ulx and uly are the coordinates of the upper-left corner, and lrx and lry are those for the lower-right.

Returns:

0
Success.
-1
The draw buffer is too small to hold the current draw state and the draw command.

Examples:

The following example:

DrawFillRect() {
    PgSetFillColor( Pg_PURPLE );
    PgDrawIRect( 8, 8, 152, 112, Pg_DRAW_FILL );
}

will draw:

PgDrawRect

The following example:

DrawStrokeRect() {
    PgSetStrokeColor( Pg_WHITE );
    PgDrawIRect( 8, 8, 152, 112, Pg_DRAW_STROKE );
}

will draw:

PgDrawRect

The following example:

DrawFillStrokeRect() {
     PgSetFillColor( Pg_PURPLE );
     PgSetStrokeColor( Pg_WHITE );
     PgDrawIRect( 8, 8, 152, 112, Pg_DRAW_FILL_STROKE );
}

will draw:

PgDrawRect

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PgDrawBeveled(), PgDrawRoundRect(), PgSetFillColor(), PgSetFillDither(), PgSetFillTransPat()


[Previous] [Contents] [Index] [Next]