我正在尝试使用非常酷的倒置剪辑这个问题结合use path
我偷来的密钥,重新使用命名路径这个问题但是,似乎我从 stackexchange 窃取 TikZ 代码的货运技巧在这里不够用,因为在我构建的 MWE 中,剪辑的反转没有按预期工作:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\tikzset{invclip/.style={clip,insert path={{[reset cm]
(-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)
}}}}
\makeatletter
\tikzset{
use path for main/.code={%
\tikz@addmode{%
\expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname
}%
},
use path for actions/.code={%
\expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}%
},
use path/.style={%
use path for main=#1,
use path for actions=#1,
}
}
\makeatother
\begin{tikzpicture}[outer sep=0mm]
\coordinate (A) at (-1,-1);
\coordinate (B) at (1,-1);
\coordinate (C) at (1,1);
\coordinate (D) at (-1,1);
\path[draw=black,name path=P] (A) -- (B) -- (C) -- (D) --cycle;
\begin{scope}
\begin{pgfinterruptboundingbox} % useful to avoid the rectangle in the bounding box
\path[invclip] (A) -- (B) -- (C) -- (D); % works just fine
%\path[invclip,use path=P]; % doesn't work at all
\end{pgfinterruptboundingbox}
\fill[orange!50] (-2,-2) rectangle (2,2);
\end{scope}
\end{tikzpicture}
\end{document}
这很好用:
但这不起作用:
如何使用反向剪辑use path
?