2

I have achieved the following:

enter image description here

with the below code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
  \coordinate (A) at (0,0);
  \coordinate (B) at (8,0);
  \coordinate (C) at ($(A)!.5!(B)$);
  \coordinate (D) at ($(A)!.5!(C)$);
  \coordinate (E) at ($(B)!.5!(C)$);

  \draw[dashed] (A) -- (B);
  \begin{scope}
  \clip (A) rectangle (8,-8);
  \draw (D) let \p1 = ($(C) - (D)$) in circle ({veclen(\x1,\y1)});
  \end{scope}

  \begin{scope}
  \clip (A) rectangle (8,8);
  \draw (C) let \p1 = ($(B) - (C)$) in circle ({veclen(\x1,\y1)});
  \end{scope}  

  \begin{scope}
  \clip (A) rectangle (8,8);
  \draw (E) let \p1 = ($(B) - (E)$) in circle ({veclen(\x1,\y1)});
  \end{scope}   
\end{tikzpicture}
\end{document} 

Now do I fill the area like this:

enter image description here

4

Like this?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns}
\begin{document}
\begin{tikzpicture}
  \coordinate (A) at (0,0);
  \coordinate (B) at (8,0);
  \draw[pattern=north east lines] let \p1 = ($(B) - (A)$) in (A) arc(180:360:{veclen(\x1,\y1)/4})
  arc(180:0:{veclen(\x1,\y1)/4}) arc(0:180:{veclen(\x1,\y1)/2});
  \draw[dashed] (A) -- (B);
\end{tikzpicture}
\end{document} 

enter image description here

Or

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
  \coordinate (A) at (0,0);
  \coordinate (B) at (8,0);
  \draw[pattern=north east lines] (A) 
  arc(180:360:2)  arc(180:0:2) arc(0:180:4);
  \draw[dashed] (A) -- (B);
\end{tikzpicture}
\end{document} 
  • Thank you for the optimized code. But can you also provide a solution with my code. – subham soni Apr 18 at 13:51
  • @subhamsoni You can add \path[pattern=north east lines] let \p1 = ($(B) - (A)$) in (A) arc(180:360:{veclen(\x1,\y1)/4}) arc(180:0:{veclen(\x1,\y1)/4}) arc(0:180:{veclen(\x1,\y1)/2}); to your code (after adding \usetikzlibrary{patterns}). – marmot Apr 18 at 13:53
  • @subhamsoni Any attempt to fill the fragments rather than just one path will lead to an output which is not very compelling at least on some viewers because you will see little gaps. – marmot Apr 18 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.