# Filling a non-convex path in tikz

I am trying to fill a path consisting of two semicircles, and I only want the area between them to be filled. The following code doesn't work correctly.

\documentclass{article}
\usepackage{tikz}
\usepackage[active,pdftex,tightpage]{preview}
\PreviewEnvironment[]{tikzpicture}
\begin{document}
\begin{tikzpicture}
\filldraw[yellow,draw=black] (0em,0em) arc[radius=1em, start angle=180, end angle=0]
(2em,0em) --  (2em,-1em) arc[radius=1em, start angle=0, end angle=180]
(0em,-1em) -- (0em,0em);
\end{tikzpicture}
\end{document}


What I get is this:

Also, if I use the path for clipping, the same incorrect filled area is used. Can someone figure out how to fill the area inside the drawn semicircles (non-convex area) only?

• (+1) for completing your code even though you already had answers. That makes your question more useful to future readers. – cfr Jan 30 '15 at 23:19

## 2 Answers

You need to specify a continuous path for the fill for this to work neatly. So don't specify coordinates which you've already drawn to as that introduces a discontinuity:

\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}
\filldraw[yellow,draw=black]
(0em,0em)
arc[radius=1em, start angle=180, end angle=0]
--  (2em,-1em)
arc[radius=1em, start angle=0, end angle=180]
-- (0em,0em);
\end{tikzpicture}
\end{document}


\documentclass[tikz,border=4]{standalone}
\begin{document}
\begin{tikzpicture}
\filldraw[yellow,draw=black] (0,0) arc[radius=1em, start angle=0, end angle=180]
--  ++(0em,-1em) arc[radius=1em, start angle=180, end angle=0]
-- ++(0em,1em) -- cycle;
\end{tikzpicture}
\end{document}


• Thanks for the correct answer, but I selected cfr's solution since it came with an explanation. – Sameer Jan 30 '15 at 22:25