Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

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

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
Wow! Many thanks! That's what I've looked for! –  Michael Z Jan 30 '12 at 18:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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