In the scanline algorithm, the core is to compute the intersection of the scanning line and each side, and fill two intersections with specific rules to draw a scanning line, and we can abstract the understanding in 2D vector graphics engine, all object/shape, or even a simple straight line (straight line because of the endpoint ----- different strokes) can be understood as polygon filling, so why is it called the fill rule );
The traditional 2D vector graphics engine (openvg/gingkovg) supports two filling rules: the parity filling rule and the non-Zero Filling rule:
L parity filling rule (even/odd fill rule): The Core Algorithm of the parity filling rule is to confirm the number of times the Scan Line and each side intersect-whether it is an odd or even number to determine whether to fill; in general, when the number of intersections between the scanning line and the side is an odd number, the filling starts and the even number ends. In the parity filling rule, each side has no direction;
L non-zero fill rule (non-zero fill rule): The Core Algorithm of the non-zero fill rule is to determine whether to fill the rule based on the number of scanned lines and directed edges, and assume that the upward side is a positive side, the downward side is a negative side, the scanning line and the positive side intersection and Add 1, and the negative side intersection and minus 1, based on this value, we determine whether to fill: if this value is a non-zero value and starts to fill, it ends to fill;
L edge-edge fil rule: we can simply understand the parity filling rule with two different coloring algorithms;
Therefore, the following two different filling rules should be well understood:
In Flash Player, different colors are allowed on different sides of a shape-a place that is often confusing;