The goal I want to obtain is to have a parallel curve to a generic curve defined in a \draw command trough TikZ. To achieve it, I used the TikZ decorations library and the command \pgfdeclaredecoration to create it. The solution adopted by me is not very efficient but it works conceptually. Here it is a minimal example of my listing:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,decorations}
\makeatletter
\newlength\@l
\newcount\@c
\tikzset{
raise line/.initial = 25pt,
raise points/.initial = 100
}
\pgfdeclaredecoration{Parallel Line}{initial}{
\state{initial}[persistent precomputation={%
\pgfmathsetlength{\@l}%
{\pgfdecoratedpathlength/(\pgfkeysvalueof{/tikz/raise points})}%
\@c=1%
},
next state = middle,
width =\@l]{\coordinate (DecoratedPointRaised-\the\@c) at
($(0,0)+(0,\pgfkeysvalueof{/tikz/raise line})$);}
\state{middle}[persistent precomputation = {\@c=\numexpr\the\@c+1\relax},
width = \@l]{\coordinate (DecoratedPointRaised-\the\@c) at
($(0,0)+(0,\pgfkeysvalueof{/tikz/raise line})$);}
\state{final}[persistent precomputation = {\@c=\numexpr\the\@c+1\relax},
persistent postcomputation = {\foreach[count=\t from 1]\n in{2,...,100}{ %
\draw (DecoratedPointRaised-\t)-- % Here it does not work!!
(DecoratedPointRaised-\n);}}]{ %
\pgfcoordinate{DecoratedPointRaised-\the\@c}{\pgfpointdecoratedpathlast}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw (0,0) .. controls++(1,1) and (6,-3).. (7,0);
\draw[decorate,decoration=Parallel Line] (0,0) .. controls++(1,1) and (6,-3).. (7,0);
%\foreach[count=\t from 1]\n in{2,...,100}{ %
% \draw (DecoratedPointRaised-\t)--(DecoratedPointRaised-\n); % Here it works!!!!
%} %
\end{tikzpicture}
\end{document}
This is what I draw:

The line below is the original one while the above one is the decoration.
The step to create the parallel curve are the following:
- I create a new length
\@lwhich is the step of thedecoration. I create a new counter\@cto have a sequential name of thecoordinate I will create. - The first state is
initialwhere it is computed the pitch\@land where at the beginning\@cis set equal to one. Then the first coordinate of theDecoratedPointRaised-\the\@cseries is created. Finished the initial state, the decoration passes to the middle state. - In the middle state precomputation it is computed the new
\@cas\@c=\@c+1. After the\@ccoordinate is created. - When necessary, the decoration passes to the final state, where the last
\@ccoordinate is computed. Here I use post computation to draw all the segments that connect all created coordinates.
The problem is that the post computation in the final state doesn't work, while, if I write the code inside it after the \draw command, I have no problem. Why? How can I avoid it?
In the final state, is the coordinate system I use into the \state command the global one and not the transformed one?



\draw[double distance = 1cm] (0,0) .. controls++(1,1) and (6,-3).. (7,0);– percusse Oct 16 '11 at 10:51\drawcommand as you stated in the question. I can see that you want to finish what you have started but I was trying to give an alternative way. Apparently it is not what you desire. – percusse Oct 16 '11 at 14:56