我想将水平线和圆圈底部所界定的区域填充为蓝色。我遵循了这篇文章中给出的答案给圆的某部分涂上阴影但不知何故我的代码正好填充了圆的补数。这是我的 MWE
\documentclass[hidelinks,12pt,twoside,a4paper,reqno]{amsbook}
\usepackage{tikz}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\coordinate (C) at (0,0);
\coordinate (A) at (200:pi);
\coordinate (B) at (-20:pi);
\fill[blue!40] (A) arc[start angle=200, end angle=-20, radius=pi] -- cycle;
\draw (C) -- (A);
\draw (C) -- (B);
\draw (A) -- (B);
\draw (0,0) node[circle,draw,inner sep=1pt](C) {} circle (pi);
\end{tikzpicture}
\end{figure}
\end{document}
有人能告诉我我遗漏了什么吗?如果我理解正确的话,改变弧线命令的起始和结束角度应该会给出结果,但这只会把事情完全搞乱。
答案1
像这样?
\documentclass[hidelinks,12pt,twoside,a4paper,reqno]{amsbook}
\usepackage{tikz}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\coordinate (C) at (0,0);
\coordinate (A) at (200:pi);
\coordinate (B) at (-20:pi);
\fill[blue!40] (A) arc[start angle=200, end angle=340, radius=pi];
\draw (A) -- (B) -- (C) -- cycle;
\draw (0,0) node[circle,draw,inner sep=1pt]{} (C) circle (pi);
\end{tikzpicture}
\end{figure}
\end{document}
答案2
使用 ,path picture
您可以在 内绘制任何您想要的内容path
,结果将被路径裁剪。在本例中,足够大的矩形将被圆的下半部分裁剪。
\documentclass[hidelinks,12pt,twoside,a4paper,reqno]{amsbook}
\usepackage{tikz}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\coordinate (C) at (0,0);
\coordinate (A) at (200:pi);
\coordinate (B) at (-20:pi);
\draw (C) -- (A);
\draw (C) -- (B);
\draw (A) -- (B);
\draw[path picture={ \draw[fill=blue!30] (200:pi) rectangle ++(7,-3);}] (0,0)
node[circle,draw,inner sep=1pt](C) {} circle (pi);
\end{tikzpicture}
\end{figure}
\end{document}