I've searched, but I can't find a previous question sufficiently close to this one to find an answer. At the same time, this problem seems like it must have been solved by someone before now, so apologies if it's a duplicate.
I want to clip a path (particularly a circle, but a general solution would be useful too) using a node with a shape. Here's an example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{through}
\begin{document}
\begin{tikzpicture}
\node [draw,circle,fill=white,minimum size=1mm] (u) at (0,0) {};
\node [draw,circle through=(u)] at (1,0) {};
\end{tikzpicture}
\end{document}
I'd like to have the red circle clipped by the black, but still have at least the black circle remain a node. I also want to specify the black node first if at all possible.
I'm guessing that something like a postaction might be what I need, but I haven't been able to make enough sense of those yet to work it out.
Edit: clarification and something a bit strange
What I want is something looking like this:
Which can obviously be got with code like:
\begin{tikzpicture}
\node [circle,minimum size=5mm] (u) at (0,0) {};
\node [draw, circle through=(u),red] at (1,0) {};
\node [draw,circle,fill=white,minimum size=5mm] at (0,0) {};
\end{tikzpicture}
But that necessitates the first node being specified twice.
The use case for this is a load of graphs I've already done, using a vertex
style for all the vertex nodes and ideally I want to just edit this style to do the reverse clipping.
Finally, there's something very strange about the technique used at this answer
This code works as expected
\begin{tikzpicture}[remember picture,overlay]
% A path that follows the edges of the current page
\tikzstyle{reverseclip}=[insert path={(current page.north east) --
(current page.south east) --
(current page.south west) --
(current page.north west) --
(current page.north east)}
]
\node [circle,minimum size=8mm] (u) at (0,0) {};
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\coordinate (C) at (1,1);
\begin{pgfinterruptboundingbox} % To make sure our clipping path does not mess up the placement of the picture
\path [clip,draw] (A) -- (B) -- (C) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}
\draw [fill=red] (1,0) circle (1cm);
\end{tikzpicture}
but this doesn't
\begin{tikzpicture}[remember picture,overlay]
% A path that follows the edges of the current page
\tikzstyle{reverseclip}=[insert path={(current page.north east) --
(current page.south east) --
(current page.south west) --
(current page.north west) --
(current page.north east)}
]
\node [circle,minimum size=8mm] (u) at (0,0) {};
\coordinate (A) at (u.east);
\coordinate (B) at (u.south west);
\coordinate (C) at (u.north west);
\begin{pgfinterruptboundingbox} % To make sure our clipping path does not mess up the placement of the picture
\path [clip,draw] (A) -- (B) -- (C) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}
\draw [fill=red] (1,0) circle (1cm);
\end{tikzpicture}
which makes absolutely no sense to me. The first reverse-clips as expected, the second just draws the filled circle on top as if no clipping is happening at all.
\clip (u.west) -- (u.north) -- (u.east) -- (u.south)--cycle;