I'd like to highlight different parts of a tikz diagram in beamer slides using something like the \only command. I was able to do this at the level of nodes, which is probably fine, but as I have some long node definitions, I was wondering if I could put \only inside of the \node
e.g.
\node [block \only<1>{,fill=blue!50}] (start) {start};
won't work (unsurprisingly).
The MWE posted below is an OK solution for my problem, but I'm curious if there is a solution that is more atomic (i.e. works within the \node command rather than outside of it. I guess that this is not possible if we are confined to just latex.
\documentclass[compress,red,notes]{beamer}
\usepackage{tikz}
\tikzstyle{line} = [draw, very thick, color=black!50]
\tikzstyle{block} = [rectangle, draw,
text centered, node distance=4em]
\begin{document}
\begin{frame}
\frametitle{An tikz diagram.}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.5, every node/.style={scale=0.5}]
\only<1>\node [block, fill=blue!50] (start) {start};
\only<2>\node [block] (start) {start};
\node [block, below of=start] (end) {end};
\path [line] (start) -- (end);
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
Based on @Kevin C's suggestion to look at @Daniel's answer, I have the following non-working solution:
\documentclass[compress,red,notes]{beamer}
\usepackage{tikz}
\tikzstyle{line} = [draw, very thick, color=black!50]
\tikzstyle{block} = [rectangle, draw,
text centered, node distance=4em]
\tikzset{
invisible/.style={#1{}},
visible on/.style={alt={{color=blue!50}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\begin{document}
\begin{frame}
\frametitle{An tikz diagram.}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.5, every node/.style={scale=0.5}]
\node [block, visible on=<2>] (start) {start};
\node [block, below of=start] (end) {end};
\path [line] (start) -- (end);
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
