我想画一条线和一个半圆,我想让它们有相同的底部,但它们的底线不能相同。
\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\tikz {
\draw[line width=2cm,red] (0,0) arc [radius=5,start angle=0, end angle=180];
\draw[line width=2cm,green] (0,0) arc [radius=5,start angle=0, end angle=-180];
\draw [line width=2cm, red] (-10,1) -- (0,1);
}
\end{document}
答案1
为了避免观看者产生的伪影和过粗的线宽,您可以像这样分层适当的形状:
\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[green] (0,0) circle[radius=6];
\fill[white] (0,0) circle[radius=4];
\fill[red] (6,0) arc [radius=6, start angle=0, end angle=180] -- cycle;
\fill[white] ({asin(2/4)}:4) arc [radius=4, start angle=asin(2/4), end angle=180-asin(2/4)] -- cycle;
\end{tikzpicture}
\end{document}
如果您需要透明背景,使用方法如下even odd rule
:
\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[green, even odd rule] (0,0) circle[radius=6] (0,0) circle[radius=4];
\fill[red, even odd rule] (6,0) arc [radius=6, start angle=0, end angle=180] -- cycle ({asin(2/4)}:4) arc [radius=4, start angle=asin(2/4), end angle=180-asin(2/4)] -- cycle;
\end{tikzpicture}
\end{document}