0

I can use spath3 with paths (not nodes) in this way:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{spath3, intersections}
\begin{document}
\begin{tikzpicture}

\draw[spath/save = rect, rounded corners=12pt] (0,0) rectangle (2,1); \draw[spath/save global = line3] (-1,-1) -- (0.4,0.75); \draw[spath/save global = line4] (-1,-1) -- (1,0.5);

\tikzset{spath/.cd, split at intersections with={rect}{line3}, split at intersections with={rect}{line4}, get components of={rect}\cpts } \draw[ultra thick, color=red, spath/restore=\getComponentOf\cpts{3}] node {}; \end{tikzpicture} \end{document}

Result:

enter image description here


So far so good.

But what I really need is highlight a part of rectangle node in the intersection with a double line, and it does not work:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{spath3, intersections}
\begin{document}
\begin{tikzpicture}
\node[spath/save global = rect, rectangle, rounded corners=12pt, draw=black!50, thick, fill=white, minimum height=27pt] {asdfasdfasdfasdf};
\draw[spath/save global = line, line width=1pt, double=white, draw=black!20, double distance=3pt] (-2, -1) -- (-0.5,0.0);
\tikzset{spath/.cd,
         split at intersections with={rect}{line},
         split at intersections with={rect}{line},
         get components of={rect}\cpts
}
\draw[ultra thick, color=red, spath/restore=\getComponentOf\cpts{2}] node {};
\end{tikzpicture}
\end{document}

enter image description here

Any ideas?

DimanNe
  • 152
  • 1
    I don't think there is any way to access the background path of a node directly at the moment. It'll also be a problem if the background path has multiple disconnected segments. – Henri Menke Nov 26 '21 at 09:41
  • @HenriMenke I am sure I am missing some crucial differences, but it seems that something similar used to be possible: https://tex.stackexchange.com/a/428275/170134 – DimanNe Nov 26 '21 at 10:05
  • Thanks for the link, this is very interesting, but it seems that these approaches rely on the background path being the last one that is drawn. Most shapes only have a background path, but in principle there is also \behindbackgroundpath, \beforebackgroundpath, \foregroundpath, and \behind and \before versions of that. I doubt that these approaches are robust in the presence of any of these. – Henri Menke Nov 26 '21 at 10:24
  • @HenriMenke I am interested only in double line and rectangle - I am trying to create a proper solution for this question https://tex.stackexchange.com/questions/623787/tikz-make-double-line-arrow-remove-border-of-shapes-it-connects . (a problem with the current answer there is that I need to adjust shorten distances, and it does not work if rectangles are filled with different colours) – DimanNe Nov 26 '21 at 10:31
  • I feel like I'm missing something in these comments. You clearly have access to the background path of the node. The problem here is that the doubled line line is just a line on the path level. It has no width, there is only one intersection point. You will need to have to parallel paths here (trivial for straight lines, difficult for curves). – Qrrbrbirlbel Mar 15 '23 at 19:24

0 Answers0