![集合论 - 应用奇偶规则](https://linux22.com/image/435568/%E9%9B%86%E5%90%88%E8%AE%BA%20-%20%E5%BA%94%E7%94%A8%E5%A5%87%E5%81%B6%E8%A7%84%E5%88%99.png)
有人能帮我为这些图像创建 tikz 图片吗?非常感谢。
我尝试过这个:
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\def\A{(0.5, 1) .. controls ++(180:-1) and ++(280: 2) .. (2.5, 3) .. controls ++(280:-1) and ++(170: -.5) .. (.5, 3) .. controls ++(170: 1) and ++(180: 1) .. (0.5, 1);}
\def\B{(1.5, 2) .. controls ++(150:-2) and ++(280: 1) .. ( 4.5, 2.5) .. controls ++(280:-1) and ++(180:-1) .. ( 3, 4) .. controls ++(180: 1) and ++(175:-1) .. (1, 4.5) .. controls ++(175: 1) and ++(150: 1) .. (1.5,2);}
\def\R{(-1,0) rectangle (5,5);}
\begin{tikzpicture}
\draw[very thick] \R;
\begin{scope} \clip \A;
\fill[gray] \B;
\end{scope}
\draw \A; \draw \B;
\end{tikzpicture}
\end{document}
答案1
以下是您可以做的四个例子(您可能会从该起点找到实现其他所有目标的方法)。您已经做得很好了。
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\def\a{(1,3.5)(2,4.5)(3,3.5)(3.5,4)(4,3.5)(3.5,2.5)(4.5,1.5)(4.5,1)(3.5,1)(3.5,2)(1.5,2.5)}
\def\b{(.5,.5)(1,2)(2.5,3)(2,1)}
\def\A{plot[smooth cycle,tension=.75] coordinates {\a}}
\def\B{plot[smooth cycle,tension=1] coordinates {\b}}
\begin{tikzpicture}
\fill[orange,even odd rule] \A \B;
\draw[orange!50!black] \A \B;
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}
\clip \A;
\fill[orange] \B;
\end{scope}
\draw[orange!50!black] \A \B;
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[even odd rule]
\clip \A;
\fill[orange,even odd rule] \A \B;
\end{scope}
\draw[orange!50!black] \A \B;
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[even odd rule]
\clip \B;
\fill[orange,even odd rule] \A \B;
\end{scope}
\draw[orange!50!black] \A \B;
\end{tikzpicture}
\end{document}