\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}