我有一个简单的问题,但我找不到解决方案:如何才能获得一条带有彩虹色的简单蛇箭?
答案1
欢迎!本回答的所有重要内容均来自这里。
\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}
顺便说一句,如果您能发布您所尝试过的方法,那就太好了。