
我需要有關 TikZ 的幫助nonzero rule
作品。它說它從某些點開始計算射線的交叉次數。這官方範例在fill
帶有三角形和圓形的我迷失了,因為三角形和圓形之間的交點沒有被填滿。
為了理解這一點,我改編了該範例並添加了第二個兩個圓圈的範例。
\begin{document}
\begin{tikzpicture}
\filldraw[fill=yellow]
% Clockwise isoceles right-angled triangle
(0,0) -- (1,1) -- (2,0) --cycle
% Small circle centered on the leftmost vertex
(0,0) circle (.5);
\draw[->] (0,0) -- (.3,.3);
\draw[->] (1,1) -- (1.5,.5);
\draw[->] (2,0) -- (1,0);
\draw[->] (120:.5) arc (120:90:.5);
\draw[->] (300:.5) arc (300:270:.5);
\draw[->] (.2,.1) -- +(0,1) node[above] {crossings: $1+1 = 2$};
\begin{scope}[yshift=-3cm]
\filldraw[fill=yellow]
% Two circles
(0,0) circle (.5)
(.5,0) circle (.5);
\draw[->] (120:.5) arc (120:90:.5);
\draw[->] (300:.5) arc (300:270:.5);
\draw[->] (120:.5)+(.5,0) arc (120:90:.5);
\draw[->] (300:.5)+(.5,0) arc (300:270:.5);
\draw[->] (.2,.1) -- +(0,1) node[above] {crossings: $1+1 = 2$};
\end{scope}
\end{tikzpicture}
\end{document}
我很難理解以下內容:
- 在第一個範例中,交叉部分未填入。
- 在第二個範例中,交叉部分被填滿。
因為交叉口的數量是相同的。您能解釋為什麼會發生這種情況嗎?
答案1
透過反轉來更正圓的繪製方向[x radius=-\r, y radius=\r]
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=yellow]
(0,0) -- (1,1) -- (2,0) --cycle
(0,0) circle[x radius=-0.5, y radius=0.5];
\draw[->] (0,0) -- (.3,.3);
\draw[->] (1,1) -- (1.5,.5);
\draw[->] (2,0) -- (1,0);
\draw[->] (120:.5) arc (120:90:.5);
\draw[->] (300:.5) arc (300:270:.5);
\draw[->] (.2,.1) -- +(0,1) node[above] {crossings: $1+1 = 2$};
\begin{scope}[yshift=-3cm]
\filldraw[fill=yellow]
(0,0) circle[x radius=-0.5, y radius=0.5]
(.5,0) circle[x radius=-0.5, y radius=0.5];
\draw[->] (120:.5) arc (120:90:.5);
\draw[->] (300:.5) arc (300:270:.5);
\draw[->] (120:.5)+(.5,0) arc (120:90:.5);
\draw[->] (300:.5)+(.5,0) arc (300:270:.5);
\draw[->] (.2,.1) -- +(0,1) node[above] {crossings: $1+1 = 2$};
\end{scope}
\end{tikzpicture}
\end{document}