# Tikz fade with transparency so background is visible in beamer?

I am writing a presentation in beamer. I have a background image that I have included with \setbeamertemplate{background canvas}{...}. Within a regular slide, I now would like to create a rectangle that fades from a color to fully transparent in Tikz. If I create a rectangle with fading, i.e. \tikz{\fill[left color=RED,right color=transparent] (0,0) rectangle (\linewidth,1.5em);} It creates the rectangle, but rather than being see-through at the right end, it is black.

Is there a way to define opacity in fade, such that the background image becomes visible?

M.W.E

\documentclass{beamer}
\usepackage{tikz}
\usepackage{graphicx}

\setbeamertemplate{background canvas}{\includegraphics[width=\paperwidth]{picture.jpg}}

\begin{document}
\begin{frame}
\tikz{\fill[left color=red,right color=transparent] (0,0) rectangle (\linewidth,1.5em);}
\end{frame}
\end{document}


(Use any random picture for the background)

-

You need to set up a fading via \tikzfading and then use the fade path option to the fill command:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{graphicx}

\setbeamertemplate{background canvas}{\includegraphics[width=\paperwidth]{example-image-a.jpg}}


See section 20.3.1 Creating Fadings of the pgfmanual.