
2 つの図形があり、円形 ( などellipse
) を追加したいとします。この楕円をトリミングして、下図のように他の図形の間に収まるようにするにはどうすればよいでしょうか。ただし、空きスペースを透明にしておきたいので、図形の周囲に白い境界線を追加したくありません。
MWE:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill (-4,2) rectangle (-1,1.5);
\fill (-3.5,1.25) rectangle (-0.5,0.75);
\fill (-1.6,1.35) ellipse (0.3);
\end{tikzpicture}
\end{document}
編集:上記の例の長方形の形状は少し特殊すぎるかもしれないので、私が実現したいことのより複雑な例を示したいと思います。今回は、より複雑な形状を重ね合わせますellipse
。
答え1
\documentclass[tikz]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\pattern[pattern=checkerboard,pattern color=black!30] (-5,0) rectangle (0,3);
\newcommand{\myspace}{0.5}
\fill (-4,2) rectangle (-1,1.5);
\fill (-3.5,1.25) rectangle (-0.5,0.75);
\clip ([yshift=\myspace] -2,1.25) rectangle ([yshift=-\myspace] -1,1.5);
\fill (-1.6,1.35) ellipse (0.3);
\end{tikzpicture}
\end{document}
編集:以下は、更新された質問を実現する 1 つの方法ですtikzfadingfrompicture
。
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{fadings, patterns}
\begin{tikzfadingfrompicture}[name=myfading]
\draw[draw=transparent!100, ultra thick, fill=transparent!0] (0,0) circle[radius=1];
\draw[draw=transparent!100, ultra thick, fill=transparent!0] (-2,-1) -- (0,0) -- (-1,2.5) -- (-2,2) -- cycle;
\draw[draw=transparent!100, ultra thick, fill=transparent!0] (0,1) ellipse [x radius=0.5, y radius=0.8];
\draw[draw=transparent!100, ultra thick, fill=transparent!0] (0.2,-0.5) -- (1,1.5) -- (2,-0.5) -- cycle;
\draw (0,0) circle[radius=10]; %encompassing circle for alignment
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\pattern[pattern=checkerboard,pattern color=black!30] (-3,-3) rectangle (3,3);
\fill[path fading=myfading, fit fading=false] (-3,-3) rectangle (3,3);
\end{tikzpicture}
\end{document}