When calculating the intersection point(s) between a line and another double-line path, TikZ normally returns the intersection at the middle of the double-line path. The question here is how to get the intersection with the outer line of the path. I believe, we can shift the point by a value .5\pgflinewidth + .5\pgfinnerlinewidth
, but I'm using this inside a macro which should check first if the path is double or not, then, it can do the correction. The code currently is like this:
\documentclass[tikz,border=1mm]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\node (rect) [name path=rect,draw,double,ultra thick,double distance=3pt, rounded corners,minimum size=1cm]{};
\draw[name path=line] (rect.center)--(.7,.7);
\path[name intersections={of= rect and line}];
\node at (intersection-1) [circle,fill=blue,inner sep=.5pt]{};
\end{tikzpicture}
\end{document}
I appreciate your advice.
Comment on @Augustin's answer:
This should be a comment, but posting the picture needs editing here. The answer of Augustin is only valid for the case of the line slope being 45 degrees, which is rarely the case. Try, for example,
...
\draw[name path=line,draw] (rect.center)--(.7,.1);
..
you get the following result:
I appreciate the trial, but I need a general solution. More importantly, I mentioned in my question that I can shift the point. What I need to accomplish is how to check if the path is double and how to get the keys for its innerlinewidth
, total linewidth
, ... etc (all the information you have is the path itself), to be able to do the correct shifting.
\pgfinnerlinewidth>0
or not. – user11232 Apr 11 '15 at 0:11\pgfinnerlinewidth
is always>0
if you have a single double path in the wholetikzpicture
environment. So, how to check a specific path,rect
for example, and you have many other single/double paths? – AboAmmar Apr 11 '15 at 0:19rect
), so how can we extract the properties andkeysvalue
s of a path only by its name. It is actually passed to the macro (as an argument) only by its name. – AboAmmar Apr 11 '15 at 0:28name path
key only saves the path specification. Currently there is no way to save the actions and properties of a path, and they are essentially 'forgotten' once the path is used. – Mark Wibrow Apr 11 '15 at 8:20I--I
, whereI
would be the previously intersection. – Franck Pastor Apr 11 '15 at 14:38