我正在尝试绘制由基本图形(圆形和矩形)组合而成的形状轮廓。我使用的是 Caramdir 的代码这里但由于某种原因,它不起作用。
我的代码:
\documentclass[12pt, border=0.5mm]{standalone}
\usepackage{graphicx}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]
\draw[line width=0.05mm, postaction={gray!10, fill}]
(-3, -0.4) rectangle (11.5, 0.4)
(-3, 0) circle (0.55mm)
(7.2, 0) circle (1.5mm)
(7.2, 0) circle (1.1mm)
(0, 0) circle (0.95mm);
\end{tikzpicture}
\end{document}
我需要的大纲是:
答案1
一方面,虽然看到了其他答案,但这可能不是你想要的:
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm, line width=.05mm]
\clip (-4.5,-2) rectangle (14.5,2) (7.2,0) circle (1.05);
\draw [double distance=.8mm, double=gray!10, postaction={fill=gray!10}]
(-3,0) circle (.55mm)
-- (0,0) circle (.95mm)
-- (7.2,0) circle (1.5mm)
-- (11.5,0);
\draw (7.2,0) circle (1.1mm) (11.5,.4) -- (11.5,-.4);
\end{tikzpicture}
\end{document}
答案2
绘制和填充的顺序可能很复杂,具体取决于您想要覆盖的内容。我使用普通灰色,这样我可以更容易地看到它。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]
\path[draw=black,line width=0.05mm]
(-3, 0) circle (0.55mm)
(0, 0) circle (0.95mm)
(7.2, 0) circle (1.5mm);
\path[draw=black,line width=0.05mm,fill=gray]
(-3, -0.4) rectangle (11.5, 0.4);
\path[fill=gray]% note reduction in radius by 1/2 line width
(7.2, 0) circle (1.475mm)
(-3, 0) circle (0.525mm)
(0, 0) circle (0.925mm);
\path[draw=black,line width=0.05mm,fill=white]
(7.2, 0) circle (1.1mm);
\end{tikzpicture}
\end{document}