Draw a stroked and/or filled polygon
int PgDrawPolygon( PhPoint_t const *ptr, int num, PhPoint_t const *pos, int flags ); int PgDrawPolygonmx( PhPoint_t const *ptr, int num, PhPoint_t const *pos, int flags );
These functions build a command in the draw buffer to draw a polygon from an array of points, pointed to by ptr, with num entries.
The array of points must fit in the draw buffer, even if you use PgDrawPolygonmx(). |
The flags argument must be one of the following:
You can OR flags with any combination of the following:
For absolute coordinates, pos is added to each point pointed to by ptr. For relative coordinates, the first coordinate is the sum of pos and the first point of the array; any subsequent coordinate is the sum of the previous point and the next point of the array.
If you call the "mx" form of this function, the data isn't physically copied into the draw buffer. Instead, a pointer to the array is stored until the draw buffer is flushed. Make sure you call PgFlush() before you modify the point array. |
The following example:
DrawFillStrokePoly() { PhPoint_t o = { 0, 0 }; PhPoint_t p[] = { 80, 8, 120, 120, 16, 32, 136, 32, 40, 120 }; PgSetStrokeColor( Pg_WHITE ); PgSetFillColor( Pg_PURPLE ); PgDrawPolygon( &p, 5, &o, Pg_DRAW_FILL_STROKE | Pg_CLOSED ); }
will draw:
The following example:
DrawRelPoly() { PhPoint_t o = { 0, 0 }; PhPoint_t p[] = { 80, 8, 40, 112, -104, -88, 120, 0, -96, 88 }; PgSetStrokeColor( Pg_WHITE ); PgSetFillColor( Pg_PURPLE ); PgDrawPolygon( &p, 5, &o, Pg_DRAW_FILL_STROKE | Pg_CLOSED | Pg_RELATIVE ); }
will draw:
The following example:
DrawUnclosedPoly() { PhPoint_t o = { 0, 0 }; PhPoint_t p[] = { 80, 8, 120, 120, 16, 32, 136, 32, 40, 120 }; PgSetStrokeColor( Pg_WHITE ); PgSetFillColor( Pg_PURPLE ); PgDrawPolygon( &p, 5, &o, Pg_DRAW_FILL_STROKE ); }
will draw:
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
To draw stroked polygons, see also:
PgSetStrokeColor(), PgSetStrokeCap(), PgSetStrokeDash(), PgSetStrokeDither(), PgSetStrokeJoin(), PgSetStrokeWidth()
To draw filled polygons, see also:
PgSetFillColor(), PgSetFillDither(), PgSetFillTransPat()