fill-rule
property
The fill-rule property decides what counts as "inside" when a path or polygon overlaps itself or has holes.
Hover/tap/focus the figure to switch from
fill-rule:nonzero
to
fill-rule:evenodd
.
The keywords refer to a way of counting how many path segments you have to cross to reach a given point. The determination is affected by the direction of the path: clockwise paths add to the count, counter-clockwise paths subtract from it.
As a result, path segments that loop in opposite directions cancel each other out with either fill-rule. Loops in the same direction cancel each other out for
evenodd
, but not for
nonzero
. Which means
you can ignore the path direction for
evenodd
, and just focus on how many paths you cross, alternating inside/outside for each. But be aware:
the default value is
nonzero
.