![范围是否通过 foreach 循环传播?](https://linux22.com/image/351003/%E8%8C%83%E5%9B%B4%E6%98%AF%E5%90%A6%E9%80%9A%E8%BF%87%20foreach%20%E5%BE%AA%E7%8E%AF%E4%BC%A0%E6%92%AD%EF%BC%9F.png)
\foreach
我想使用规则绘制一堆圆圈even odd fill
。
如果我做:
\documentclass{standalone}\input tikz\begin{document}\tikz{
\begin{scope}[red,even odd rule]
\fill(1,1)circle(1);
\fill(2,2)circle(2);
\end{scope}
}\end{document}
我得到了预期的效果,但如果我这样做
\documentclass{standalone}\input tikz\begin{document}\tikz{
\begin{scope}[fill=red,even odd rule]
\foreach\i in {1,2}{
\fill(\i,\i)circle(\i);
}
\end{scope}
}\end{document}
范围的属性不再影响我的\draw
。是否有某种方法可以让范围在\foreach
循环中传播?
答案1
答案2
我得到了相同的结果:
代码:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}[draw=blue, ultra thick, fill=red!20,even odd rule]
\filldraw (1,1) circle(1);
\filldraw (2,2) circle(2);
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[draw=blue, ultra thick, fill=red!20,even odd rule]
\foreach \i in {1,2} {
\filldraw (\i,\i) circle(\i);
}
\end{scope}
\end{tikzpicture}
\end{document}