In tikz
I want to draw a narrow long rectangle which is faded at the top and at the bottom. This is supposed to represent a laser beam.
I define a tikz
fading and it works fine as long as the beam is horizontal. When I rotate the rectangle the fading does not produce the beam as before. I tried to use the fading transform option to also rotate the fading beam but it did not work. Since I want to draw several beam with different rotations in one picture I thought I should avoid a canvas transform.
Here is my example code:
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{fadings}
\tikzfading[name=middle,
top color=transparent!100,
bottom color=transparent!100,
middle color=transparent!20]
\begin{tikzpicture}
\fill[path fading=middle, red] (0,0) rectangle (4,0.2);
\fill[rotate=-20, path fading=middle, red] (0,0) rectangle (4,0.2);
\fill[rotate=20, path fading=middle, fading transform={rotate=20}, red] (0,0) rectangle (4,0.2);
\end{tikzpicture}
\end{document}
How can I get the correct fading for the rotated beams?