[Tex/LaTex] How to color a region

colortikz-pgf

The following code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,positioning}

\begin{document}

\begin{tikzpicture}[radius=5]
\draw (0,0) rectangle (5,5);
\draw[name path=c1] (0,0) arc[start angle=-90,end angle=0] -- (5,5);
\draw[name path=c2] (5,0) arc[start angle=0,end angle=90] -- (0,5);
\draw[name path=c3] (5,5) arc[start angle=90,end angle=180] -- (0,5);
\draw[name path=c4] (0,5) arc[start angle=180,end angle=270] -- (5,0);
\begin{scope}
\fill [name intersections={of=c1 and c2}]
  (intersection-1) circle (2pt) node[label=right:$A$] {};
\fill [name intersections={of=c2 and c3}]
  (intersection-1) circle (2pt) node[label=above:$B$] {};
\fill [name intersections={of=c3 and c4}]
  (intersection-1) circle (2pt) node[label=left:$C$] {};
\fill [name intersections={of=c4 and c1}]
  (intersection-1) circle (2pt) node[label=below:$D$] {};
\end{scope}
\end{tikzpicture}

\end{document}

produces

How can I apply color only to the central region limited by the arcs crossing at A, B, C and D?

Best Answer

If you don't mind to have the paths twice in your picture you can use clipping to only draw the inner area. Clipping is local to the scope and accumulates. So you can take the figure as two overlapping "leaves" and clip to both, then fill the whole rectangle.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,positioning}

\begin{document}

\begin{tikzpicture}[radius=5]
\begin{scope}
\clip (0,0) arc[start angle=-90,end angle=0]   -- (5,5)
            arc[start angle=90,end angle=180]  -- (0,0);
\clip (0,5) arc[start angle=180,end angle=270] -- (5,0)
            arc[start angle=0,end angle=90]    -- (0,5);
\fill [red] (0,0) rectangle (5,5);
\end{scope}
\draw (0,0) rectangle (5,5);
\draw[name path=c1] (0,0) arc[start angle=-90,end angle=0] -- (5,5);
\draw[name path=c2] (5,0) arc[start angle=0,end angle=90] -- (0,5);
\draw[name path=c3] (5,5) arc[start angle=90,end angle=180] -- (0,5);
\draw[name path=c4] (0,5) arc[start angle=180,end angle=270] -- (5,0);
\begin{scope}
\fill [name intersections={of=c1 and c2}]
  (intersection-1) circle (2pt) node[label=right:$A$] {};
\fill [name intersections={of=c2 and c3}]
  (intersection-1) circle (2pt) node[label=above:$B$] {};
\fill [name intersections={of=c3 and c4}]
  (intersection-1) circle (2pt) node[label=left:$C$] {};
\fill [name intersections={of=c4 and c1}]
  (intersection-1) circle (2pt) node[label=below:$D$] {};
\end{scope}
\end{tikzpicture}

\end{document}

Image