Delphi type TFillRule = (EvenOdd, NonZero, Positive, Negative);
C++ enum FillRule {EvenOdd, NonZero, Positive, Negative};
C# public enum FillRule {EvenOdd, NonZero, Positive, Negative};
Complex polygons are defined by one or more closed paths that set both outer and inner polygon boundaries. But only portions of these paths (or 'contours') may be setting polygon boundaries, so crossing a path may or may not mean entering or exiting a 'filled' polygon region. For this reason complex polygons require filling rules that define which polygon sub-regions will be considered inside a given polygon, and which sub-regions will not.
The Clipper Library supports 4 filling rules: Even-Odd, Non-Zero, Positive and Negative. These rules are base on the winding numbers (see below) of each polygon sub-region, which in turn are based on the orientation of each path. Orientation is determined by the order in which vertices are declared during path construction, and whether these vertices progress roughly clockwise or counter-clockwise.
Winding numbers for polygon sub-regions can be derived using the following algorithm:
Filling Rules:
By far the most widely used fill rules are Even-Odd and Non-Zero. Most graphics rendering libraries (AGG, Android Graphics, Cairo, GDI+, OpenGL, Quartz 2D etc) and vector graphics storage formats (SVG, Postscript, Photoshop etc) support both these rules. However some libraries (eg Java's Graphics2D) only support EvenOdd filling. Android Graphics and OpenGL are the only libraries that I'm aware of that support filling rules other than EvenOdd and NonZero.
Additional notes:
Difference, Intersect, Union, XOR
Copyright © 2010-2024 Angus Johnson - Clipper2 1.3.0 - Help file built on 14 Jan 2024