TikZ-PGF – How to Paint the Regions in TikZ-PGF?

tikz-pgf

I wanto to paint the figure

enter image description here

But, I can only do the drawing without the painting.

My codes:

\documentclass[12pt]{article}

\usepackage{fontspec}

\usepackage[T1]{fontenc}

\usepackage[utf8]{inputenc}

\usepackage[portuguese]{babel}

\usepackage{color}

\usepackage{tikz}

\begin{document}

\begin{center}

    \begin{tikzpicture}[scale=1.5]

        \draw (-.5,-.5) rectangle (.5,.5);

        \draw (-1,-1) rectangle (1,1);

        \clip  (-1,-1) rectangle (1,1);

            \draw (1,1) circle (1);

            \draw (1,-1) circle (1);

            \draw (-1,-1) circle (1);

            \draw (-1,1) circle (1);

\end{tikzpicture}

\end{center}

\end{document}

enter image description here

Best Answer

This could be a way to do it, if you don't mind the center area filled with white color. Draw each arcs individually, and clipped with the small square then filled inside with white color:

\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage[T1]{fontenc}
\usepackage[portuguese]{babel}
\usepackage{tikz}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=1.5]
        \draw (-1,-1) rectangle (1,1);
        \draw [fill=red] (0,1) arc (180:270:1) arc (90:180:1) arc (0:90:1) arc (-90:0:1);
        \draw [fill=blue] (-.5,-.5) rectangle (.5,.5);
        {\clip (-.5,-.5) rectangle (.5,.5);
        \draw [fill=white] (0,1) arc (180:270:1) arc (90:180:1) arc (0:90:1) arc (-90:0:1);}
\end{tikzpicture}
\end{center}
\end{document}

enter image description here