Tikz: Shading a path without any filling

How can I shade a path witout filling? In particular, I wand to draw a curved arrow that starts colored blue and ends colored green, where in between it gradually changes its color. I can't find a way to shade a path without filling it.

The following code does not work, as it shades the filling area, although it compiles.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,automata,patterns,decorations,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}

bottom color=green!80!white,->] (0,0) .. controls +(0,-1) and +(0,1) .. (1,-2);

\end{tikzpicture}
\end{document}


Here's a quick attempt to automate percusse's solution:

Here's the main file:

\documentclass[tikz,border=5mm]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw[style=help lines] (0,-2) grid[step=1cm] (2,0);
\path[
very thick,
transparent!20,
->
}{
top color=blue!80,
bottom color=green!80,
},
] (0cm,0cm) .. controls +(0cm,-1cm) and +(0cm,1cm) .. (1cm,-2cm);

\begin{scope}[x=0.5cm,y=0.5cm]
% Circles, each with a distinct fading
\foreach \i in {1,...,5}{
\pgfmathsetmacro{\j}{18*\i}
\path[
very thick,
transparent!\j,
}{
top color=green!80,
bottom color=blue!80,
},
] (1+\i,-\i) circle (\i mm);
}

% Circles, with a global fading
\path[
very thick,
transparent!60,
}{
top color=blue!80,
bottom color=green!80,
},
] foreach \i in {1,...,5}{
(\i-1,-\i-3) circle (\i mm)
};
\end{scope}
\end{tikzpicture}

\end{document}


You will need to paste the following code into fade-no-fill.sty, which uses the spath library from the TeX.SX package. You will therefore need to download spath.dtx, run it with pdflatex spath.dtx and copy the resulting spath.sty in the same folder.

\usetikzlibrary{intersections}% for "name path".
\usetikzlibrary{math}%
\usepackage{spath}% for "use path", from the TeX.SX package
\usepgfmodule{oo}% for spath
\usetikzlibrary{arrows.meta}% needed so that bounding boxes correctly include arrows.
% Copied from https://tex.stackexchange.com/a/26386/5699
\tikzset{
use path for main/.code={%
\expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname
}%
},
use path for actions/.code={%
\expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}%
},
use path/.style={%
use path for main=#1,
use path for actions=#1,
}
}
\tikzset{
fade path but don't fill/.style 2 args={
preaction={save path=\tmppath,},
postaction={
/utils/exec={
\coordinate (oldbb-ne) at (current bounding box.north east);
\coordinate (oldbb-sw) at (current bounding box.south west);
\pgfresetboundingbox
\pgfresetboundingbox
\pgfoonew \thepathsav=new spath(\tmppath)
\thepathsav.use path with tikz(draw,#1)
\coordinate (temp-fade-bb-ne) at (current bounding box.north east);
\coordinate (temp-fade-bb-sw) at (current bounding box.south west);
\coordinate (temp-fade-bb-center) at (current bounding box.center);
%
\useasboundingbox (oldbb-ne) rectangle (oldbb-sw);
%
\tikzmath{
}
\tikzset{tempstyle/.style/.expand once={#2}}
\path[
},
tempstyle,
},
},
},
}


I don't remember why the scaling was happening but please let me know the missing detail or fix it so I can delete this. ( Stolen from How to draw multiple lines inside the circle )

Something along these lines can be a very impractical but a possible way to do it. I can't think of anything clever how to automate it other than the obvious tedious way.

\documentclass[tikz,border=5mm]{standalone}

\path(-0.2cm,0.2cm) rectangle (1.2cm,-2cm); % Arrow line is an overlay!
\pgfinterruptboundingbox
\draw[very thick,transparent!20,->] (0cm,0cm) .. controls +(0cm,-1cm) and +(0cm,1cm) .. (1cm,-2cm);
\endpgfinterruptboundingbox

\begin{document}

\begin{tikzpicture}
\draw[style=help lines] (0,-2) grid[step=1cm] (2,0);
top color=blue!80,
bottom color=green!80,
] (0,0) rectangle (1cm,-2cm);
\end{tikzpicture}

\end{document}


In Metapost, it is possible to get the "envelope" of a path using envelope. One can then fill in the path with a linear shade.

\starttext

\startMPpage[offset=1mm]
path p, q;

p := origin{dir -90} .. {dir -90} (2, -2);
p := p scaled 1cm;

q := envelope pensquare scaled 3bp of p;
draw q;

q := q xshifted 2cm;