Is it possible to define a decoration/postaction, for drawing a double line so that a self intersecting line will draw on top of itself? To show what I mean see these spirals:
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[red, double=yellow, thick, domain=0:pi, smooth, samples=200] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\begin{scope}[yshift=-3cm]
\foreach \i in {1,...,10}
\draw[red, double=yellow, thick, domain=pi*(\i-1)/10:pi*\i/10, smooth, samples=200] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\end{scope}
\end{tikzpicture}
\end{document}
The top spiral shows the effect of a normal double line and the bottom spiral shows the desired result. I wish the result done with just one \draw
command to avoid rendering artefacts and make the smooth
option work across the whole spiral.
Ultimately, I want to be able to use white as the outer color and thereby creating a crossing effect. To be able to better answer questions on this site e.g. Conical and cylindircal spirals
I was thinking that it should be possible by making the double on small segments of the path as it is being drawn. A naive approach like this:
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary {decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\draw[yellow,
decorate, decoration={zigzag, segment length=1mm, amplitude=0mm},
preaction={draw, ultra thick, red},
domain=0:pi, samples=200] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\end{tikzpicture}
\end{document}
does not work as the preaction is applied to the whole path and not the segments.
A even better solution would be if the path could clip
itself, so that the crossing would look nice on a non-white background. - Probably quite complicated.