The evenâÂÂodd rule is an algorithm implemented in vector-based graphic software, like the PostScript language and Scalable Vector Graphics (SVG), which determines how a graphical shape with more than one closed outline will be filled. Unlike the nonzero-rule algorithm, this algorithm will alternatively color and leave uncolored shapes defined by nested closed paths irrespective of their winding.
The SVG defines the evenâÂÂodd rule by saying:
The rule can be seen in effect in many vector graphic programs (such as 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.
The SVG computer vector graphics standard may be configured to use the evenâÂÂodd rule when drawing polygons, though it uses the non-zero rule by default.
Below is a partial example implementation in Python, by using a ray to the right of the point being checked: