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?
Asked
Active
Viewed 442 times
0
-
1Welcome! You can either use path fading or clip. – Jan 20 '20 at 22:40
1 Answers
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}
BTW, for the future it would be great if you could post what you have tried.
