我现在手动完成了这个操作,但我感兴趣的是如何使用循环来完成这个操作:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzstyle{Punkt} = [coordinate]
\node[Punkt] (Center) at (0, 0) {};
\draw[-, thick, fill=black!30!white]{[rounded corners=1.5pt] ([shift={(30:1.2)}]Center) arc (30:34:1.2) --
([shift={(36:1.5)}]Center) arc (36:84:1.5) --
([shift={(86:1.2)}]Center) arc (86:94:1.2) --
([shift={(96:1.5)}]Center) arc (96:144:1.5) --
([shift={(146:1.2)}]Center) arc (146:154:1.2) --
([shift={(156:1.5)}]Center) arc (156:204:1.5) --
([shift={(206:1.2)}]Center) arc (206:214:1.2) --
([shift={(216:1.5)}]Center) arc (216:264:1.5) --
([shift={(266:1.2)}]Center) arc (266:274:1.2) --
([shift={(276:1.5)}]Center) arc (276:324:1.5) --
([shift={(326:1.2)}]Center) arc (326:334:1.2) --
([shift={(336:1.5)}]Center) arc (336:384:1.5) --
([shift={(386:1.2)}]Center) arc (386:390:1.2)
};
\draw [fill=white, opacity=1, thick] (Center) circle [radius=1];
\end{tikzpicture}
\end{document}
如果我尝试这样的事情:
\foreach \i in {1,2,...,6}{
\draw[-, fill=green][rotate=(\i-1)*360/6]
{[rounded corners=1.5pt] ([shift={(29:1.2)}]Center) arc (29:34:1.2) --
([shift={(36:1.5)}]Center) arc (36:84:1.5) --
([shift={(86:1.2)}]Center) arc (86:91:1.2);
}
它仅填充在每个段的起点和终点之间:
谢谢你的帮助。Konne
答案1
将 放在\foreach
里面\draw
。这会使其成为一条路径,因此可完全填充。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzstyle{Punkt} = [coordinate]
\node[Punkt] (Center) at (0, 0) {};
\draw[-, fill=green] ([shift={(29:1.2)}]Center)
\foreach \i in {1,2,...,6}{
[rotate=(\i-1)*360/6]
{[rounded corners=1.5pt] arc (29:34:1.2) --
([shift={(36:1.5)}]Center) arc (36:84:1.5) --
([shift={(86:1.2)}]Center) arc (86:91:1.2) -- ([shift={(89:1.2)}]Center)
}
};
\draw [fill=white, opacity=1, thick] (Center) circle [radius=1];
\end{tikzpicture}
\end{document}