您能告诉我如何填充形状的突出显示部分吗fill=gray!60
?
一如既往地感谢您。
\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%\draw[thick,latex-latex,yshift=-0.3cm](-138-6:2.5) arc(-138-6:-38+6:2.5) node[midway,left,fill=white]{L};
%
\draw[thick] (0,0) -- (36.87:4) --+ (-53.13:3) --cycle;
%\draw[thick] (0,0) -- (-138-5:2.5) arc(-138-5:-38+5:2.5) -- cycle;
%
\draw[thick,rotate around={-90-53.13:(3.2,2.4)}](3.2,2.4) rectangle (3.5,2.7);
%\draw[thick,black,dashed](0,+3.65) --(1.14,+3.65);
\node[above] at (3.3,2.5) {\large $A$};
\node[left] at (0.3,-0.26) {\large $B$};
\node[right] at (4.7,-0.26) {\large $C$};
%
%\draw[thick,fill=black] (0,+3.65) circle (0.2mm);
%
\draw[thick,rotate around={36.87:(0,0)}] (0,0) arc(180:0:2);
\draw[thick] (0,0) arc(180:0:2.5);
\draw[thick,rotate around={-52.73:(3.2,2.4)}] (3.2,2.4) arc(180:0:1.5);
\end{tikzpicture}
\end{document}
答案1
最简单的方法可能是先绘制三个圆弧,然后将大圆弧填充为白色(或当前背景颜色)。
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick, fill=gray!60, rotate around={36.87:(0,0)}] (0,0) arc (180:0:2);
\draw[thick, fill=gray!60, rotate around={-52.73:(3.2,2.4)}] (3.2,2.4) arc (180:0:1.5);
\draw[thick, fill=white] (0,0) arc (180:0:2.5);
\draw[thick] (0,0) -- (36.87:4) -- +(-53.13:3) -- cycle;
\draw[thick, rotate around={-90-53.13:(3.2,2.4)}](3.2,2.4) rectangle (3.5,2.7);
\node[above] at (3.3,2.5) {\large $A$};
\node[left] at (0.3,-0.26) {\large $B$};
\node[right] at (4.7,-0.26) {\large $C$};
\end{tikzpicture}
\end{document}
但更好的方法是将三条弧线绘制为一条路径,然后可以轻松填充。为此,您只需将计算直接应用于语句内的度数arc
(使用此方法,您也可以将其他语句更改为仅使用 36.87 的倍数):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) -- (36.87:4) -- ++({-90+36.87}:3) -- cycle;
\draw[thick, rotate around={{180+36.87}:(3.2,2.4)}](3.2,2.4) rectangle (3.5,2.7);
\node[above] at (3.3,2.5) {\large $A$};
\node[left] at (0.3,-0.26) {\large $B$};
\node[right] at (4.7,-0.26) {\large $C$};
\draw[thick, fill=gray!60] (0,0) arc ({180+36.87}:{0+36.87}:2) arc
({90+36.87}:{-90+36.87}:1.5) arc (0:180:2.5) -- cycle;
\end{tikzpicture}
\end{document}