I am trying to generate a path from a list of directions (as seen on the numpad). The coordinates are generated correctly, but because I use multiple call to \path the arrowheads are drawn on each segment. How do I change this code to only draw the starting arrowhead on the first segment and the ending arrowhead on the last segment? I have unsuccessfully tried to have one \path outside the \foreach and only coordinates inside.
edit: It should work for any arrow shape passed in the optional argument.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\directedPath}[5][]
{
\edef\start{#2}
\edef\stop{#3}
\edef\step{#4}
\edef\directions{#5}
\coordinate (c0) at (\start);
\foreach [var=\dir, count=\cur] in \directions
{
% current coordinate dx
\pgfmathparse{(1-(1-1/sqrt(2))*mod(\dir, 2))*\step*(mod(\dir-1, 3)-1)}
\edef\dx{\pgfmathresult}
% current coordinate dy
\pgfmathparse{(1-(1-1/sqrt(2))*mod(\dir, 2))*\step*(div(\dir-1, 3)-1)}
\edef\dy{\pgfmathresult}
% previous coordinate index
\pgfmathparse{int(\cur - 1)}
\xdef\prev{\pgfmathresult}
% current coordinate
\coordinate (c\cur) at ($(c\prev) + (\dx, \dy)$);
% draw partial path
\ifnum \cur>1
\path [#1] (c\prev) -- (c\cur);
\fi
}
\path [#1] (\start) -- (c1);
\path [#1] (c\cur) -- (\stop);
}
\begin{document}
\begin{tikzpicture}
\node [draw=green] (Start) at (0, 0) {Start};
\node [draw=red] (End) at (5, 2) {End};
\directedPath[draw=black, >->]{Start}{End}{1.0}{3,6,9,8,7,8,9,6,3}
\end{tikzpicture}
\end{document}
>->
and using\path [#1,>-] (\start) -- (c1); \path [#1,->] (c\cur) -- (\stop);
\path
command? Would that be an acceptable solution?