# Tikz and beamer overlay using opacity

I am using the following code to create overlays with beamer

\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}

It works great except when one needs to use opacity in the path that is to be overlayed i.e.

\scoped[visible on=<2->]{\filldraw[shade, opacity=.5, color=red] (0,1) rectangle (0,0);}

does not work because of the opacity argument in the path itself. So this rectangle is always seen in all the overlays.

Anyway of a workaround?

Thanks

• Why you cannot use \onslide with \transfade transitions between overlays? – vi pa Jun 25 at 10:29
• never used \transfade, I know \onslide does not work by itself. Can you give an example please – Jean Eid Jul 3 at 14:00

This is a MWE with \transfade and \onslide. This work only in fullscreen mode.

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}