[Tex/LaTex] How to ‘lengthen’ a TikZ path

tikz-pgf

Instead of to shorten a TikZ path, i need to lengthen a path. But I could not find a lengthen key.

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\makeatletter
\newcommand*\xtikzpath[3]%
{%
  (#1\LP@rel@tikzpath,#2\LP@rel@tikzpath)%
  \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*\fourwindscell[4]%
{%
  \foreach \LP@fw@dir/\LP@fw@length in {#4}%
  {%
    \bgroup%
      \def\LP@rel@tikzpath{.5}%
      \draw[-|,color=blue,line width=.1cm
            %,lengthen >=3mm
           ]%
        \xtikzpath{#1}{#2}{\LP@fw@dir/\LP@fw@length};%
    \egroup%
  };%
  \node[fill=white,font=\LARGE] at (#1.5,#2.5) {#3};%
}%
\makeatother
\begin{document}
\begin{tikzpicture} 
  \fourwindscell{1}{1}{5}{8/2,6/3}
  \fourwindscell{3}{2}{2}{4/1,6/1}
  \fourwindscell{4}{3}{2}{4/2}
  \draw (1,1) grid[step=1] (5,4);
\end{tikzpicture}
\end{document}

MWE

Is there a way to lengthen the paths?

Best Answer

Although it's not documented one can use the shorten key with a negative value to lengthen a path!

Just add shorten >=-3mm to the original MWE to get the desired result!

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\makeatletter
\newcommand*\xtikzpath[3]%
{%
  (#1\LP@rel@tikzpath,#2\LP@rel@tikzpath)%
  \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*\fourwindscell[4]%
{%
  \foreach \LP@fw@dir/\LP@fw@length in {#4}%
  {%
    \bgroup%
      \def\LP@rel@tikzpath{.5}%
      \draw[-|,color=blue,line width=.1cm,shorten >=-3mm]%
        \xtikzpath{#1}{#2}{\LP@fw@dir/\LP@fw@length};%
    \egroup%
  };%
  \node[fill=white,font=\LARGE] at (#1.5,#2.5) {#3};%
}%
\makeatother
\begin{document}
\begin{tikzpicture} 
  \fourwindscell{1}{1}{5}{8/2,6/3}
  \fourwindscell{3}{2}{2}{4/1,6/1}
  \fourwindscell{4}{3}{2}{4/2}
  \draw (1,1) grid[step=1] (5,4);
\end{tikzpicture}
\end{document}

enter image description here