Here's a coverfig
environment which is basically just a wrapper for tikzpicture
but it does position the node and install a xyz coordinate system so that the coordinate (0, 0)
specifies the picture's bottom left and (1, 1)
specifies its upper right corner.
This is actually all you need so that you can done do
\fill<…>[white, opacity=.8] (0,0) rectangle (.3333,1);
to cover the left third of the picture.
But since you probably will use this more often, there's also a \cffill
macro (which is just a wrapper for \fill
really) but here you can easily use the keys left
, right
, … so that you only have to specify
\cffill<…>[left=.3333];
to cover the left third of your graphic.
You can still use a normal \fill
and make it shorter with a to
because the rectangle to path is installed for all paths (as well as the coverfig/style
which acts as a default cover style for all paths).
The \EndCover
macro resets the defaults for every path
and to path
in case you want to add other annotations to the diagram but still use the new coordinate system.
Code
\documentclass{beamer}
\usetheme{Boadilla}
\useoutertheme[width=0pt,height=.5in]{sidebar}
\definecolor{bground}{HTML}{005EB8}
\usepackage{tikz}
\NewDocumentEnvironment{coverfig}{O{} m}{
\begin{tikzpicture}
\node[shape=rectangle, path only, anchor=south west,
inner sep=+0pt, outer sep=+0pt, minimum size=+0pt]
(cf@){\includegraphics[#1]{#2}};
\def\EndCover{\tikzset{every path/.code=, line to}}% default
\tikzset{x=([email protected] east), y=([email protected] west),
every path/.append style=coverfig/style, to path=rectangle(\tikztotarget)}
}{\end{tikzpicture}}
\NewDocumentCommand{\cffill}{D<>{.-} O{}}{%
\fill<#1>[coverfig={#2}](\pgfkeysvalueof{/tikz/coverfig/start})
rectangle (\pgfkeysvalueof{/tikz/coverfig/end})}
\newcommand*\coverfigset{\pgfqkeys{/tikz/coverfig}}
\coverfigset{
.code=\coverfigset{#1},% .search also=/tikz,
style/.style={color=white, opacity=.5},
start/.initial={0,0}, end/.initial={1,1},
left/.style ={start={0,0}, end={{#1},1}},
right/.style={start={{1-(#1)},0}, end={1,1}},
top/.style ={start={0,{1-(#1)}}, end={1,1}},
bottom/.style={start={0,0}, end={1,{#1}}},
vertical/.style args={#1 to #2}{start={{#1},0}, end={{#2},1}},
horizontal/.style args={#1 to #2}{start={0,{#1}}, end={1,{#2}}}}
\begin{document}
\begin{frame}
\begin{coverfig}[width=0.75\linewidth]{example-image}
\cffill<2>[left=.3333];
\cffill<3>[left=.6666];
\cffill<4>[vertical=.35 to .65][blue];
\fill<5>[rounded corners, green] (.25, .35) to (.75, .65);
% \EndCover
% \draw[ultra thick, red, ->]
% (.1,.15) -- node[above, sloped] {to the middle} (.5, .5);
\end{coverfig}
\end{frame}
\end{document}
Output