# Filling complex figures with color

I wonder if there is any method available in LaTeX to fill complex figures. There are few methods for filling figures: even-odd rule algorithm, winding number algorithm. According to these algorithms, the figure can be filled for particular regions.

For instance:

Please see this for a reference.

Suppose we have some complex figure, e.g. self-crossing polygon, is that possible to fill it with some of above mentioned algorithms?

-
even odd rule is already implemented in TikZ. See the manual page 34 and 163. –  percusse Jan 30 '12 at 18:33

TikZ has a key called even odd rule which I assume use the first of those. An example:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[even odd rule] (0,0) -- (2,2) -- (2,0) -- (0,2) -- (3,1.5) -- cycle;
\end{tikzpicture}
\end{document}


Another example, from the manual:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=green,even odd rule]
(0,0) rectangle (1,1) (0.5,0.5) circle (0.4cm);
\draw[->] (0.5,0.5) -- +(0,1) [above] node{crossings: $1+1 = 2$};
\end{tikzpicture}
\end{document}


-
Wow! Many thanks! That's what I've looked for! –  Michael Z Jan 30 '12 at 18:45