![]() |
![]() |
![]() |
![]() |
Draw a rounded rectangle
int PgDrawRoundRect( PhRect_t const *rect,
PhPoint_t const *radii,
unsigned flags );
int PgDrawRoundRectCx( void *dc,
PhRect_t const *rect,
PhPoint_t const *radii,
unsigned flags );
ph
These functions build a command in the draw buffer to draw a rounded rectangle. The rect argument is a pointer to a PhRect_t structure that defines the extent of the rectangle. The radii is a pointer to a PhPoint_t structure that defines the roundness of the corners, in pixels.
The flags argument must be one of the following:
Since the value of radii is truncated to the size of the rectangle, you should find this function useful for drawing ellipses within a rectangular area (see example below).
PgDrawRoundRect() works on the current draw context, while you can specify the draw context dc for PgDrawRoundRectCx().
The following example:
DrawStrokeRRect() {
PhRect_t rect = { 8, 8, 152, 112 };
PhPoint_t radii = { 32, 32 };
PgSetStrokeColor( Pg_WHITE );
PgDrawRoundRect( &rect, &radii, Pg_DRAW_STROKE );
}
will draw:
The following example:
DrawFillRRect() {
PhRect_t rect = { 8, 8, 152, 112 };
PhPoint_t radii = { 32, 32 };
PgSetFillColor( Pg_PURPLE );
PgDrawRoundRect( &rect, &radii, Pg_DRAW_FILL );
}
will draw:
The following example:
DrawFillStrokeRRect() {
PhRect_t rect = { 8, 8, 152, 112 };
PhPoint_t radii = { 1000, 1000 };
PgSetFillColor( Pg_PURPLE );
PgSetStrokeColor( Pg_WHITE );
PgDrawRoundRect( &rect, &radii, Pg_DRAW_FILL_STROKE );
}
will draw:
Photon
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
PgDrawBeveled*(), PgDrawIRect*(), PgDrawRect*(), PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*(), PhPoint_t, PhRect_t
“Arcs, ellipses, polygons, and rectangles” in the Raw Drawing and Animation chapter of the Photon Programmer's Guide
![]() |
![]() |
![]() |
![]() |