0

I have a simple question but I can not find a solution : How can I get a simple snake arrow but with a rainbow color?

1
  • 1
    Welcome! You can either use path fading or clip.
    – user194703
    Jan 20, 2020 at 22:40

1 Answer 1

8

Welcome! All important ingredients of this answer are from here.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{shadings,fadings,arrows.meta,bending,decorations.pathmorphing}
\pgfdeclarehorizontalshading{rainbow}{100bp}{% https://tex.stackexchange.com/a/344548/194703
  rgb(0bp)=(1,0,0);
  rgb(26bp)=(1,0,0);
  rgb(33bp)=(1,.5,0);
  rgb(40bp)=(1,1,0);
  rgb(47bp)=(0,1,0);
  rgb(54bp)=(0,1,1);
  rgb(61bp)=(0,0,1);
  rgb(68bp)=(1,0,1);
  rgb(75bp)=(.5,0,.5);
  rgb(100bp)=(.5,0,.5)}
\begin{tikzfadingfrompicture}[name=my arrow]
 \draw[transparent!0,ultra thick,decorate,decoration={snake,post length=2mm},
 -{Stealth}] (0,0) -- (2,0);
\end{tikzfadingfrompicture}%
\begin{document}
\begin{tikzpicture}
 \path [ postaction={shading=rainbow, path fading=my arrow, fit fading=false}] 
 (-1,-0.2) rectangle (1,0.2);
\end{tikzpicture}
\end{document}

enter image description here

BTW, for the future it would be great if you could post what you have tried.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .