|This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.|
Set the polygon fill rule
#include <gf/gf.h> void gf_context_set_polyfill( gf_context_t context, int polyfill );
- The draw context to set the polygon fill rule for.
- The winding rule for the polygon fill. Can be one of:
- GF_CONTEXT_POLYFILL_EVENODD — the default rule
This function replaces the polygon fill rule for the specified draw context. The polygon fill rule determines how the fill for polygons is rendered. If you're only drawing simple, convex polygons, you can optimize rendering speed by setting the fill rule to GF_CONTEXT_POLYFILL_CONVEX.
By default, polygons that overlap themselves are filled using the so-called even-odd rule (GF_CONTEXT_POLYFILL_EVENODD): if an area overlaps an odd number of times, it isn't filled. Another way of looking at this is to draw a horizontal line across the polygon. As you travel along this line and cross the first line, you're inside the polygon; as you cross the second line, you're outside. As an example, consider a simple polygon:
This rule can be extended for more complicated polygons:
- When you cross an odd number of lines, you're inside the polygon, so the area is filled.
- When you cross an even number of lines, you're outside the polygon, so the area isn't filled.
If you want a polygon that overlaps itself to be completely filled in all regions within its boundary, you can set the fill rule to GF_CONTEXT_POLYFILL_NONZERO.
QNX Graphics Framework
“Drawing lines and polygons” in the Basic Drawing chapter