I am trying to understand how it works the decoration pgf module, in order to solve the unanswered question Fiber-Optic-Style decoration.
I am having an hard time with some macros, for example \pgfdecoratedpathlength. Look the following MWE, from what I read on the pgfmanual version 2.10, the options (1), (2) and (3) should be equivalent, but only (2) works, while I get 100 errors for the others.
\documentclass[a4paper]{article}
\usepackage{pgf,pgfsys,pgffor}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{tikz}
\usepgfmodule{decorations}
\usetikzlibrary{intersections,arrows,decorations,snakes}
\pgfdeclaredecoration{fiber}{initial}
{
\state{initial}[
switch if less than=\pgfdecoratedpathlength/2 to final %% (1)
%width=\pgfdecoratedpathlength/2 %% (2)
%width=.5\pgfdecoratedpathlength %% (3)
]{
\pgflineto{\pgfpoint{5pt}{15pt}}
\pgflineto{\pgfpoint{5pt}{-15pt}}
}
\state{final}{
\pgfpathlineto{\pgfpointdecoratedpathlast}
}
}
\begin{document}
\begin{tikzpicture}[decoration={fiber, amplitude=1cm}, draw=red]
\draw[->,decorate] (3, 5mm) -- ++(4,0); %% ERROR! Undefined control sequence. <argument> \pgf@decorate@width
\draw[->,decorate] (3,0) -- ++(3,0);
\draw[->,decorate] (3,-5mm) -- ++(2,0);
\draw[->,decorate] (3,-1cm) -- ++(1,0);
\draw[->,decorate] (3,-1.5cm) -- ++(0.5,0);
\end{tikzpicture}
\end{document}
The first error is Undefined control sequence. <argument> \pgf@decorate@width , in the first draw. Any ideas?

0.5*\dimenshould work instead of.5\dimen(not tested) – percusse Dec 17 '13 at 23:39width=.5*\pgfdecoratedpathlengthworks for (3) in place ofwidth=.5\pgfdecoratedpathlength. But why (1) does not work? By the manual, (1) and (2) should be completely equivalent. – Nicola Dec 18 '13 at 07:52