I am trying to draw a path with a double color gradient, first magenta to cyan then cyan to magenta.
I have tried to use the code from this thread, but the best I could do is this:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{multicolor/.style={
postaction={
decorate,
decoration={
markings,
mark=between positions 0 and 0.5\pgfdecoratedpathlength step 0.5pt with {
\pgfmathsetmacro\myval{multiply(divide(
\pgfkeysvalueof{/pgf/decoration/mark info/distance from start}, 1\pgfdecoratedpathlength),200)};
\pgfsetfillcolor{cyan!\myval!magenta};
\pgfpathcircle{\pgfpointorigin}{#1};
\pgfusepath{fill};},
mark=between positions 0.5\pgfdecoratedpathlength and \pgfdecoratedpathlength step 0.5pt with {
\pgfmathsetmacro\myval{300+multiply(divide(
\pgfkeysvalueof{/pgf/decoration/mark info/distance from start}, 1\pgfdecoratedpathlength),200)};
\pgfsetfillcolor{magenta!\myval!cyan};
\pgfpathcircle{\pgfpointorigin}{#1};
\pgfusepath{fill};},
}}}}
\begin{document}
\begin{tikzpicture}
\path [multicolor=0.3mm,draw] (0,0) .. controls (1,3) and (5,-7) .. (4,1) {};
\end{tikzpicture}
\end{document}
I would like the second part of the path to gradually change from cyan to magenta.
Thanks in advance

