I have some complex code that creates a tikz picture, called image A. The background areas of this picture are white, as are some foreground areas, which are painted with a white fill. I now want to lay this picture on top of image B, such that all white parts of image A are rendered transparent.
It would be ideal if image A could be created so that the white areas were simply not painted, but this is not possible, because many of the white areas are curve paths---so it's easy to draw them directly, but hard to draw their complement.
Can this be done? At the moment I'm having to render images A and B separately, take screenshots, and do this layering in GIMP.
An example (added by another user):
First draw a shape using white to 'erase' parts:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path[fill=cyan] (0,0) circle (1);
\path[draw=white, line width=10pt] (-0.1,-1.2) to[out=70, in=-70] (-0.1,1.2);
\end{tikzpicture}
\end{document}
Now try drawing something behind it:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path[draw=orange, line width=5pt] (-1.5,0) -- (1.5,0);
\path[fill=cyan] (0,0) circle (1);
\path[draw=white, line width=10pt] (-0.1,-1.2) to[out=70, in=-70] (-0.1,1.2);
\end{tikzpicture}
\end{document}
The goal is to have the orange line go behind the blue areas but show through the white part, so you can see a segment of the orange line in between the two blue regions.






tikzfadingfrompictureortransparency group. Cannot tell for sure. Perhaps http://tex.stackexchange.com/a/323315/51022 helps – Symbol 1 Oct 29 '16 at 05:12spath3solution (which is also not exactly the same but close enough for this example). – Qrrbrbirlbel Jul 21 '23 at 12:56