Even-odd rule

From Wikipedia, the free encyclopedia

The even-odd-rule is an algorithm implemented in vector-based graphic software, like the PostScript language, which determines how a graphical shape with more than one closed outline will be filled. Opposite: nonzero-rule.

The SVG specification says: "This rule determines the "insideness" of a point on the canvas by drawing a ray from that point to infinity in any direction and counting the number of path segments from the given shape that the ray crosses. If this number is odd, the point is inside; if even, the point is outside."

The rule can be seen in effect in many vector graphic programs (like Freehand or Illustrator), where a crossing of an outline with itself causes shapes to fill in strange ways.

On a simple curve, the even-odd rule reduces to a decision algorithm for the point in polygon problem.

[edit] External links