2

I am trying to fill the region inside the circle centered on C but outside the circle centered on B using TikZ or Tkz-Euclide but I am unable to do so. I just got help on a similar question and I tried to use it to my advantage, but to no avail.

\documentclass[10pt]{scrartcl}

\usepackage{tkz-euclide}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/0/A, 1/0/B, 2/0/C, 3/0/D, 4/0/E, 5/0/F, 6/0/G}
\tkzDrawCircle[R](B,1cm)
\tkzDrawCircle[R](C,2cm)
\tkzDrawCircle[R](D,3cm)
\tkzDrawPoints(A,B,C,D,E,F,G)
\tkzDrawSegment(A,G)
\tkzLabelPoints[below](B,D,F)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](G)
\tkzLabelPoints[below right](C,E)
\filldraw[color=gray, opacity=0.5]
(E) arc (0:180:2cm);
\end{tikzpicture}

\end{document}

enter image description here

4 Answers 4

5

I could write another comment, but maybe it is clearer when I use an answer for this because this way I can add a screen shot. As I said in the comments, you can omit most of the coordinates. The reason for writing an answer is that I'd like to encourage you using the backgrounds library for that. I assume you added opacity because you did not want to get rid of the nodes. If that's the case, you may put the fills on the background. That way you can use also full colors. This also applied to the nice solution proposed by J. Leon V. As you see, the labels do not get blurred out.

\documentclass[10pt]{scrartcl}

\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc,backgrounds}

\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/0/A, 1/0/B, 2/0/C, 3/0/D, 4/0/E, 5/0/F, 6/0/G}
\tkzDrawCircle[R](B,1cm)
\tkzDrawCircle[R](C,2cm)
\tkzDrawCircle[R](D,3cm)
\tkzDrawPoints(A,B,C,D,E,F,G)
\tkzDrawSegment(A,G)
\tkzLabelPoints[below](B,D,F)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](G)
\tkzLabelPoints[below right](C,E)
\begin{scope}[on background layer]
\fill[gray!50] (A) arc(-180:180:2cm) arc(180:-180:1cm) --cycle;
\fill[blue](A) arc(-180:180:3cm) arc(180:-180:2cm) --cycle;
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Here are examples of just upper and lower halfs.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{calc,backgrounds}

\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A, 1/0/B, 2/0/C, 3/0/D, 4/0/E, 5/0/F, 6/0/G}
\tkzDrawCircle[R](B,1cm)
\tkzDrawCircle[R](C,2cm)
\tkzDrawCircle[R](D,3cm)
\tkzDrawPoints(A,B,C,D,E,F,G)
\tkzDrawSegment(A,G)
\tkzLabelPoints[below](B,D,F)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](G)
\tkzLabelPoints[below right](C,E)
\begin{scope}[on background layer]
\fill[gray!50] (A) arc(180:00:2cm) -- (C) arc(00:180:1cm) --cycle;
\fill[blue] (A) arc(180:360:3cm) --(E) arc(00:-180:2cm)  --cycle;
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

2

I managed to do it. Here's the result:

\documentclass[10pt]{scrartcl}

\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/0/A, 1/0/B, 2/0/C, 3/0/D, 4/0/E, 5/0/F, 6/0/G}
\tkzDrawCircle[R](B,1cm)
\tkzDrawCircle[R](C,2cm)
\tkzDrawCircle[R](D,3cm)
\tkzDrawSegment(A,G)
\tkzLabelPoints[below](B,D,F)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](G)
\tkzLabelPoints[below right](C,E)
\filldraw[color=gray, opacity=0.5]
(E) arc (0:180:2cm) --
(A) arc (180:-180:1cm) --
(A) arc (-180:0:2cm) -- cycle;
\tkzDrawPoints(A,B,C,D,E,F,G)
\end{tikzpicture}

\end{document}

enter image description here

8
  • 2
    Was just about to post almost the same, and I could make here the same comment as before, namely that the coordinates are not necessary: \filldraw[color=gray, opacity=0.5] (E) arc (0:180:2cm) arc (180:-180:1cm) arc (-180:0:2cm) -- cycle;
    – user121799
    Sep 24, 2018 at 2:46
  • @marmot Could you help me with something similar: I want to fill the semicircle inside the larger one but outside the second larger, and I'm having trouble again. I tried using both methods, the one using the answer I posted (and you showed me in the other question) and the one you mentioned again in this comment. Sep 24, 2018 at 3:04
  • 1
    Sure, that's almost the same, just one number is changed from 1 to 3: \filldraw[color=gray, opacity=0.5] (E) arc (0:180:2cm) arc (180:-180:3cm) arc (-180:0:2cm) -- cycle;
    – user121799
    Sep 24, 2018 at 3:11
  • 2
    You also achieve this using the option even odd rule, that allows to define a shape with a shape inside as a hole: \filldraw[color=gray, opacity=0.5,even odd rule] (C) circle (2cm) (B) circle (1cm); \filldraw[color=blue, opacity=0.5,even odd rule] (D) circle (3cm) (C) circle (2cm);
    – J Leon V.
    Sep 24, 2018 at 3:27
  • @marmot Thank you again, and thank you J. Leon V. I now want to fill only half region. I'm trying to use the code \filldraw[color=gray,opacity=0.5] (E) arc (0:180:2cm) arc (-180:0:3cm) -- (E) -- cycle; but it doesn't give half the region. What am I doing wrong? Sep 24, 2018 at 14:40
2

It is possible to fill this area with the even odd rule. I have already explained this rule in this answer. Here, the path is composed of the succession of 3 circles:

\draw[fill=green, even odd rule] (D) circle(3cm)(B) circle (1cm) (C) circle (2cm);

Here, the area to color is an even area that with the even odd rule is not colored. In order for it to be colored with the even odd rule, this area would have to be odd. To do this, simply add the largest circle (center D) one more time to the path composed of the other three.

\draw[fill=green, even odd rule] (D) circle(3cm)(B) circle (1cm) (C) circle (2cm) (D) circle(3cm);

Full code:

\documentclass[10pt]{scrartcl}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc,backgrounds}

\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A, 1/0/B, 2/0/C, 3/0/D, 4/0/E, 5/0/F, 6/0/G}
\draw[fill=green, even odd rule] (D) circle(3cm)(B) circle (1cm) (C) circle (2cm) (D) circle(3cm);
\tkzDrawPoints(A,B,C,D,E,F,G)
\tkzDrawSegment(A,G)
\tkzLabelPoints[below](B,D,F)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](G)
\tkzLabelPoints[below right](C,E)
\end{tikzpicture}
\end{document}

Result by drawing the center circle D twice:

output-4-circles

Output by default (3 circles):

output-3-circles Translated with www.DeepL.com/Translator

1
\documentclass[10pt]{scrartcl} 
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}
\tkzDefPoints{0/0/A, 1/0/B, 2/0/C, 3/0/D, 4/0/E, 5/0/F, 6/0/G}
\tkzFillCircle[blue!20](C,E)
\tkzFillCircle[white](B,C)
\tkzDrawCircle[R](B,1)
\tkzDrawCircle[R](C,2)
\tkzDrawCircle[R](D,3)
\tkzDrawPoints(A,B,C,D,E,F,G)
\tkzDrawSegment(A,G)
\tkzLabelPoints[below](B,D,F)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](G)
\tkzLabelPoints[below right](C,E)
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .