To avoid remember picture
and overlay
, I mix Jack's solution and Altermundus's solution using the bigger rectangle that TikZ/PGF (TeX?) can used (Edit: as suggested by Qrrbrbirlbel, I add [reset cm]
to get a solution independent from any scale transformations).
First tikzpicture shows two (inv)clipping triangles.
Second tikzpicture shows the effect of nonzero rule
(even odd rule
can't be used directly in a clipping path, see note below).
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{invclip/.style={clip,insert path={{[reset cm]
(-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)
}}}}
\begin{tikzpicture}[outer sep=0mm]
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\coordinate (C) at (.5,1);
\coordinate (Ap) at (0,1);
\coordinate (Bp) at (1,1);
\coordinate (Cp) at (.5,0);
\begin{scope}
\begin{pgfinterruptboundingbox} % useful to avoid the rectangle in the bounding box
\path[invclip]
(A) -- (B) -- (C) -- (A)
(Ap) -- (Cp) -- (Bp) -- (Ap);
\end{pgfinterruptboundingbox}
\fill[orange!50] (-1,-1) rectangle (2,2);
\draw (A) circle (2mm); % this is the little angle marker
\draw (B) circle (2mm); % this is the little angle marker
\draw (C) circle (2mm); % this is the little angle marker
\draw (Ap) circle (2mm); % this is the little angle marker
\draw (Bp) circle (2mm); % this is the little angle marker
\draw (Cp) circle (2mm); % this is the little angle marker
\end{scope}
\draw[red] (current bounding box.south west)
rectangle (current bounding box.north east);
\end{tikzpicture}
\begin{tikzpicture}[outer sep=0mm]
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\coordinate (C) at (.5,1);
\coordinate (Ap) at (0,1);
\coordinate (Bp) at (1,1);
\coordinate (Cp) at (.5,0);
\begin{scope}
\begin{pgfinterruptboundingbox} % useful to avoid the rectangle in the bounding box
\path[invclip]
(A) -- (B) -- (C) -- (A)
(Ap) -- (Bp) -- (Cp) -- (Ap);
\end{pgfinterruptboundingbox}
\fill[orange!50] (-1,-1) rectangle (2,2);
\draw (A) circle (2mm); % this is the little angle marker
\draw (B) circle (2mm); % this is the little angle marker
\draw (C) circle (2mm); % this is the little angle marker
\draw (Ap) circle (2mm); % this is the little angle marker
\draw (Bp) circle (2mm); % this is the little angle marker
\draw (Cp) circle (2mm); % this is the little angle marker
\end{scope}
\draw[red] (current bounding box.south west)
rectangle (current bounding box.north east);
\end{tikzpicture}
\end{document}

Note about rules and clip:
It's impossible to combine clip
and even odd rule
in a path (it seems to me that it's almost a bug). But, if you add the even odd rule
option to the enclosing scope, the clip
operation uses it. Applied on the previous example, the clipping paths can use any direction of rotation:
\documentclass{standalone}
\usepackage{tikz}
\tikzset{invclip/.style={clip,insert path={{[reset cm]
(-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)}}}}
\begin{document}
\begin{tikzpicture}[outer sep=0mm]
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\coordinate (C) at (.5,1);
\coordinate (Ap) at (0,1);
\coordinate (Bp) at (1,1);
\coordinate (Cp) at (.5,0);
\begin{scope}[even odd rule]
\begin{pgfinterruptboundingbox} % useful to avoid the rectangle in the bounding box
\path[invclip]
(A) -- (B) -- (C) -- (A)
(Ap) -- (Bp) -- (Cp) -- (Ap);
\end{pgfinterruptboundingbox}
\fill[orange!50] (-1,-1) rectangle (2,2);
\draw (A) circle (2mm); % this is the little angle marker
\draw (B) circle (2mm); % this is the little angle marker
\draw (C) circle (2mm); % this is the little angle marker
\draw (Ap) circle (2mm); % this is the little angle marker
\draw (Bp) circle (2mm); % this is the little angle marker
\draw (Cp) circle (2mm); % this is the little angle marker
\end{scope}
\draw[red] (current bounding box.south west)
rectangle (current bounding box.north east);
\end{tikzpicture}