Once again, I'm preparing a new logic puzzle; Resuko to be precise.
For the race track, I would like to have a symbolized bridge/underbridge -|-
. I searched this site, but only found this question: Intersection of 2 lines not really connected in TikZ
The answers there seem to indicate that there is no automatic solution for full paths. I'm quite sure, i have seen this, but maybe with PSTricks. Any ideas?
Edit:
Unfortunately, Frédéric's solution does not work after integration into logicpuzzle.sty
. Some path construction must be supported, like trackpath
in the following MWE:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\makeatletter
\tikzstyle{bridge path}=[rounded corners=10pt,decorate,decoration={show path construction,
lineto code={
\draw [white,line width = 4pt,double=red,double distance=4pt]
(\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);},
curveto code={
\draw [red,line width = 4pt] (\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
..(\tikzinputsegmentlast);
}}]
\newcommand*\trackpath[3]%
{%
(#1.5,#2.5)%
\foreach \LP@direction in {#3}%
{%
\ifnum\LP@direction=1%
--++(-1,-1)%
\fi%
\ifnum\LP@direction=2%
--++(0,-1)%
\fi%
\ifnum\LP@direction=3%
--++(1,-1)%
\fi%
\ifnum\LP@direction=4%
--++(-1,0)%
\fi%
\ifnum\LP@direction=6%
--++(1,0)%
\fi%
\ifnum\LP@direction=7%
--++(-1,1)%
\fi%
\ifnum\LP@direction=8%
--++(0,1)%
\fi%
\ifnum\LP@direction=9%
--++(1,1)%
\fi%
};%
}%
%
\newcommand*\track[1]{
\draw[bridge path] #1;
}
\makeatother
\begin{document}
\begin{tikzpicture}
\track{\trackpath{0}{2}{6,2,2,4,8,6,6}}
\draw (0,0) grid[step=1] (3,3);
\end{tikzpicture}
\end{document}
Then, the decoration doesn't work any longer. :-( It works with a TikZ path
, \trackpath
seems to trigger the problem.
Any idea what's going wrong?
Edit2:
With Frédéric's idea to change the way how the path is constructed, we have a final solution:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\makeatletter
\tikzstyle{bridge path}=[rounded corners=10pt,decorate,decoration={show path construction,
lineto code={
\draw [white,line width = 4pt,double=red,double distance=4pt]
(\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);},
curveto code={
\draw [red,line width = 4pt] (\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
..(\tikzinputsegmentlast);
}}]
\newcommand*\trackpath[3]%
{%
(#1.5,#2.5)%
\foreach \LP@dir/\LP@length in {#3}%
{%
\ifnum\LP@dir=2%
--++(0,-\LP@length)%
\fi%
\ifnum\LP@dir=4%
--++(-\LP@length,0)%
\fi%
\ifnum\LP@dir=6%
--++(\LP@length,0)%
\fi%
\ifnum\LP@dir=8%
--++(0,\LP@length)%
\fi%
};%
}%
%
\newcommand*\track[1]{
\draw[bridge path] #1;
}
\makeatother
\begin{document}
\begin{tikzpicture}
\track{\trackpath{0}{2}{6/1,2/2,4/1,8/1,6/2}}
\draw (0,0) grid[step=1] (3,3);
\end{tikzpicture}
\end{document}
\curveNW
,\curveSE
,\straightWE
,\straightNS
, and so on, and then aligning these tiles in a grid. This would make your intersection problem go away, since you can just draw the bridge as three separate rectangles.