我想知道是否有一种方便的方法来跳过路径/形状。例如,我可以使用\draw (0, 0) -- [clip path={...}] (2, 3);
或\draw (0, 0) -- [clip path name=<path name>] (2, 3);
或\draw (0, 0) -- [clip node=<nodename>] (2, 3);
跳过给定的路径/节点。
我知道一些可以做到这一点的代码,但它们需要几行:
反向剪辑
\documentclass[tikz, border=1cm]{standalone}
\tikzset{
revclip/.style={
insert path={
(current page.north east) --
(current page.south east) --
(current page.south west) --
(current page.north west) --
(current page.north east)
},
},
}
\begin{document}
\begin{tikzpicture}
\draw (1, 1) circle (1cm);
\draw (0.6, 1) circle (0.5cm);
\path [clip, overlay] (1, 1) circle (1cm) [revclip];
\draw (0, 0) -- (2, 3);
\end{tikzpicture}
\end{document}
背景层
\documentclass[tikz, border=1cm]{standalone}
\pgfdeclarelayer{back}
\pgfsetlayers{back, main}
\begin{document}
\begin{tikzpicture}
\draw (1, 1) circle (1cm);
\draw (0.6, 1) circle (0.5cm);
\begin{pgfonlayer}{back}
\draw (0, 0) -- (2, 3);
\fill[white, behind path] (1, 1) circle (1cm);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}