Update 2021-07-13: A more recent version of this code is at https://tex.stackexchange.com/a/567029/86
Firstly, spath3 is on CTAN and is part of TeXLive so doesn't need to be separately downloaded.
Secondly, it does feel slightly overkill to be using it in this context, but I don't know enough about how fadings work to be able to extract only the needed parts. What is needed is the facility to save and restore a path (which is easy enough to do without spath3) but also to restore the bounding box of that path (which ought to be doable without spath3, but my initial experiments dismally failed).
So here's the original code modified to use spath3. It works on the code from the original answer, but I haven't tested it on anything else. I've also removed some unnecessary code from the original.
The original document is unchanged:
\documentclass[tikz,border=5mm]{standalone}
%\url{https://tex.stackexchange.com/q/134283/86}
\usepackage{tikz}
\usepackage{fade-no-fill}
\begin{document}
\begin{tikzpicture}
\draw[style=help lines] (0,-2) grid[step=1cm] (2,0);
\path[
fade path but don't fill={
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[
fade path but don't fill={
very thick,
transparent!\j,
}{
top color=green!80,
bottom color=blue!80,
shading angle=45,
},
] (1+\i,-\i) circle (\i mm);
}
% Circles, with a global fading
\path[
fade path but don't fill={
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}
and fade-no-fill.sty is now:
%\url{https://tex.stackexchange.com/a/327713/86}
\usetikzlibrary{math}%
\usetikzlibrary{fadings}%
\usepackage{spath3}
\usetikzlibrary{arrows.meta}% needed so that bounding boxes correctly include arrows.
\ExplSyntaxOn
\cs_if_exist:NF \spath_set_current_softpath:n {
\cs_new_protected_nopar:Npn \spath_set_current_softpath:n #1
{
\spath_get:nnN {#1} {min bb} \l__spath_tmpa_tl
\exp_last_unbraced:NV \pgf@protocolsizes\l__spath_tmpa_tl
\spath_get:nnN {#1} {max bb} \l__spath_tmpa_tl
\exp_last_unbraced:NV \pgf@protocolsizes\l__spath_tmpa_tl
\spath_get:nnN {#1} {path} \l__spath_tmpa_tl
\pgfsyssoftpath@setcurrentpath\l__spath_tmpa_tl
}
}
\tikzset{restore~ soft~ path/.code={%
\spath_set_current_softpath:n {#1}
}
}
\ExplSyntaxOff
\tikzset{
fade path but don't fill/.style 2 args={
preaction={save spath=fadingpath,},
postaction={
/utils/exec={
\coordinate (oldbb-ne) at (current bounding box.north east);
\coordinate (oldbb-sw) at (current bounding box.south west);
\pgfresetboundingbox
\begin{tikzfadingfrompicture}[name=tempfade]%
\pgfresetboundingbox
\draw[restore soft path=fadingpath,#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);
\end{tikzfadingfrompicture}
%
\useasboundingbox (oldbb-ne) rectangle (oldbb-sw);
%
\tikzmath{
coordinate \ctempfadebbcenter;
\ctempfadebbcenter = (temp-fade-bb-center);
}
\tikzset{tempstyle/.style/.expand once={#2}}
\path[
path fading=tempfade,
fit fading=false,
fading transform={
yshift=\ctempfadebbcentery,
xshift=\ctempfadebbcenterx,
},
tempstyle,
] (temp-fade-bb-ne) rectangle (temp-fade-bb-sw);
},
},
},
}
Interestingly, I had to add a new command \spath_set_current_softpath:n to ensure that the fading picked up the arrow heads. This will make its way into spath3 at some point which is why I've wrapped it in a \cs_if_exist:NF.
spaht3.styfrom? Appearantly you have to get thespath3.dtx, runpdflatex spath3.dtxto get thespath3.sty. Have you done that? – Guilherme Zanotelli Nov 22 '16 at 11:04spath3.dtxthen runpdflatex spath3.dtxto get thespath3.sty.Got the error mentioned in the question. When I use\usepackage{spath}It works very well.I wonder how to use\usepackage{spath3}to do the same thing as use\usepackage{spath}– Cong Yang Nov 30 '16 at 08:44