4

enter image description here Could you show how to shade regions within circles using tikz?

5

Output

figure 1

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns, arrows.meta}

\begin{document}
\begin{tikzpicture}[scale=.5]

\draw[thick] (0,0) circle (5);
\draw[thick] (-5,0) -- (5,0);
\draw[thick] (0,-5) -- (0,5);

\node[draw, circle, thick, fill=white, minimum size=1mm, inner sep=0, label=225:O] at (0,0) {};


\draw[->, -{Stealth}] (6,0) -- (9,0);

\begin{scope}[xshift=15cm]
\path[clip, preaction={draw, thick}] (0,0) circle (5);
\fill[draw=black, thick, pattern=north west lines] (-5,2) -- (3,2) -- (3,-5) -- (-5,-5) -- cycle;
\fill[draw=black, thick, pattern=north west lines] (3,5) -- (3,2) -- (5,2) -- (5,5) -- cycle;

\node[draw, circle, thick, fill=black, minimum size=1mm, inner sep=0, label=225:O] at (0,0) {};
\draw[dashed] (-5,0) -- (5,0);
\draw[dashed] (0,-5) -- (0,5);

\draw[<->] (.5,2.3) -- (2.5,2.3) node[midway, above] {3cm};
\draw[<->] (3.3,1.7) -- (3.3,.2) node[midway, right] {2cm};
\end{scope}
\end{tikzpicture}
\end{document}
3

One option: Draw a colored circle and use the circle as clipping path for two white rectangles

\documentclass[border=2mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[fill=red] circle (5cm);
\begin{scope}
\clip circle (5cm);
\draw[fill=white] (3,2) rectangle ++(5,5);
\draw[fill=white] (3,2) rectangle ++(-8,-8);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

3

Without clipping (so a bit more work) using angles and arcs:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{patterns,math}
\begin{document}
\begin{tikzpicture}[x=1em,y=1em,>=stealth]
\tikzmath{%
  integer \x, \y;
  \r = 5;
  \x = 3; \y = 2;
  \a = asin(\y/\r);
  \b = acos(\x/\r);
}
\draw circle [radius=\r];
\draw [gray, pattern=north west lines, pattern color=gray]
   (\x,\y) -- (\a:\r) arc (\a:\b:\r) -- (-\b:\r) arc (-\b:-180-\a:\r) -- cycle;
\draw [dashed] (-\r,0) -- (\r,0) (0,-\r) -- (0,\r);
\fill circle [radius=0.125] node [below left] {$O$};
\fill [fill=gray] (\x, \y) circle [radius=0.125] 
  node [above left] {$(\x,\y)$};
\end{tikzpicture}
\end{document}

enter image description here

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.