Shapes which have been constructed using self-intersecting lines can be filled in two different ways: Alternate or Winding.
Fill mode is a property of any polycurve that has intersecting lines. Because a polycurve is a complex shape, what is considered inside and outside the shape can becomes unclear. The fill mode is an algorithm that decides the shape's inside and outside so that filling can be understood when exporting complex shapes to SVG document fragments for use in web applications.
- The Alternative mode determines whether a segment of the shape will be filled by drawing a ray from that point to infinity in any direction, and counting the number of segments within the given shape that the ray crosses through. If this number is odd, the segment exists in the fill region; if even, the segment is outside the fill region.
- The Winding mode determines whether a segment of the shape will be filled by drawing a ray from that point to infinity in any direction, and counting the number of instances in which a segment of the shape crosses the ray. Starting from zero, one count is added each time a segment crosses the ray from left to right and one count is subtracted each time a path segment crosses the ray from right to left, from the perspective of the ray. After the number of crossings has been counted, if the result is zero, then the point is considered to be outside the fill path. Otherwise, it is inside the path.