I would like to reproduce something similar to Animating Protocols but with a compound path and not a straight one.




\begin{tikzpicture}[every node/.style={circle,draw}]

\node(R0) at (0,0) {R0};
\node[draw,circle] (R1) at (1,3) {R1};
\node[draw,circle] (R2) at (2,1) {R2};
\node[draw,circle] (R3) at (3,2) {R3};

\path[name path=route] (R0)--(R1)--(R2)--(R3)
node[pos=\rPos,coordinate] (p) {};

%I would like to draw the already defined path from R0 to p
\draw[->] (R0) -- (p);

%\draw \route


I would like to declare the path and draw only the initial segment in each frame, but I don't know how to draw the "named path". With this solution, the path draw is a straight line between (R0) and (p) but I would like it to follow (R0)--(R1)--(R2)--(R3). Do you know how to do it?

pgf's manual only uses 'named path' to find intersections, so I don't know how to use them once defined.

Caramdir's answer to TikZ: draw only a certain central length of a given path uses a decoration to draw only some part of any path. I've already adapted it to draw the starting segment of the path, but I would like to draw a certain percentatge of path length and not a fixed length (3 cm). I couldn't find in manual how to provide a parameter to a decoration.

And in Length, surface, and coordinates of a tikz-pgf path, Andrew Stacey proposes to use a new TEX-SX package still in development. It seems to be they way but I think there should be a easier solution.

Do you know it?

1 Answer 1


Here's the decoration Caramdir came up with, adapted to draw only the first fraction of an arbitrary path:


% A simple empty decoration, that is used to ignore the last bit of the path

% Declare the actual decoration.
        next state=middle

        next state=final


% Create a key for easy access to the decoration
\tikzset{middle segment/.style={decoration={middle},decorate, segment length=#1}}

\foreach \step in {0.2,0.4,...,1} {%
    \draw[middle segment=\step,ultra thick,red,->] (0,0) to[out=30,in=150] (3,0) -- (7,1) -- (8,0);
  • Thanks. From your solution and Caramdir's answer I've understood that \the converts a dimensional value to just a value.
    – Ignasi
    Aug 11, 2011 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .