3

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:

enter image description here

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?

1
  • even odd rule is already implemented in TikZ. See the manual page 34 and 163.
    – percusse
    Jan 30, 2012 at 18:33

1 Answer 1

4

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}

enter image description here

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}

enter image description here

1
  • Wow! Many thanks! That's what I've looked for!
    – Michael Z
    Jan 30, 2012 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.