10

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

Display Name
  • 46,933
Benedito Freire
  • 795
  • 6
  • 11

2 Answers2

10

If you want to keep center's color (or transparency), you can draw the figure using even odd rule. You have to repeat the command, first to fill everything outside central rectangle and a second one to fill with another color inner rectangle corners, with a clip path help.

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

\begin{document} \begin{center} \begin{tikzpicture}[scale=1.5] \draw[fill=green!10] (-1,-1) rectangle (1,1); \end{tikzpicture}

\begin{tikzpicture}[scale=1.5] \draw[fill=green!10] (-1,-1) rectangle (1,1);

\filldraw [fill=red, even odd rule] (-.5,-.5) rectangle (.5,.5) 
(0,1) arc (180:270:1) arc (90:180:1) arc (0:90:1) arc (-90:0:1);

\end{tikzpicture}

\begin{tikzpicture}[scale=1.5] \draw[fill=green!10] (-1,-1) rectangle (1,1);

\filldraw [fill=red, even odd rule] (-.5,-.5) rectangle (.5,.5) 
(0,1) arc (180:270:1) arc (90:180:1) arc (0:90:1) arc (-90:0:1);

\begin{scope}
    \clip (-.5,-.5) rectangle (.5,.5);
    \filldraw [fill=blue, even odd rule] (-.5,-.5) rectangle (.5,.5) 
    (0,1) arc (180:270:1) arc (90:180:1) arc (0:90:1) arc (-90:0:1);
\end{scope}

\end{tikzpicture} \end{center} \end{document}

enter image description here

Ignasi
  • 136,588
9

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

Tom
  • 7,318
  • 4
  • 21