[Tex/LaTex] Zooming images out to specific locations in beamer

animationsbeamergraphicspositioningtransition

I want to:

  • Show an image full width
  • On click, make a small sized image placed at a particular location starting from top left and show another image full width
  • Repeat the process till all four images are shown
  • End with a grid of four images vertically and horizontally centered

The problems I am facing is:

  • The location of the grid images changes as the third image (bottom-left) in the
    grid is displayed

Possible improvements I am looking at are:

  • When I go from full width image to the 'overview' slide, the transition should be like zooming the image to that location
  • Better code than the one I have used?

Below is the MWE.

\documentclass[xcolor=dvipsnames,english,professionalfonts,smaller]{beamer}

\usetheme{Madrid}

\usepackage{graphicx}
\usepackage{parskip}
\usepackage{mwe}
\graphicspath{{.}{./image}}

\begin{document}

\setlength{\parskip}{\bigskipamount}

\begin{frame}{Title Text}

    \only <+ | handout:0> {\hfil \fbox{\includegraphics[width={\textwidth}]{example-image-16x9}}}
    \only <+ | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \hfill}
    \only <. | handout:0> {\phantom{\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}}} \\ \vspace{.09in}}
    \only <. | handout:0> {\phantom{\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}}} \hfill}
    \only <. | handout:0> {\phantom{\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}}}}
    \transduration<.>{.01}
    \only <+ | handout:0> {\fbox{\includegraphics[width={\textwidth}]{example-image-16x9}}}
    \only <+ | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \hfill}
    \only <. | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \\ \vspace{.09in}}
    \only <. | handout:0> {\phantom{\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}}} \hfill}
    \only <. | handout:0> {\phantom{\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}}}}
    \transduration<.>{.01}
    \only <+ | handout:0> {\fbox{\includegraphics[width={\textwidth}]{example-image-16x9}}}
    \only <+ | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \hfill}
    \only <. | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \\ \vspace{.09in}}
    \only <. | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \hfill}
    \only <. | handout:0> {\phantom{\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}}}}
    \transduration<.>{.01}
    \only <+ | handout:0> {\fbox{\includegraphics[width={\textwidth}]{example-image-16x9}}}
    \only <+ | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \hfill}
    \only <. | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \\ \vspace{.09in}}
    \only <. | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}} \hfill}
    \only <. | handout:0> {\fbox{\includegraphics[width={.470\textwidth}]{example-image-16x9}}}

\end{frame}

\end{document}

Best Answer

Sounds like a tween animation (interpolating the in-between frames of the animated zoom) you wish to achieve. The animate package could be used for this kind of task (Adobe Reader required).

Edit: improved animation timeline; delete tween.txt before recompiling the document.

\documentclass{beamer}

%animation timeline
\begin{filecontents*}{tween.txt}
*::0
 ::1
 ::2
 ::3x0 %keep small image
 ::7
 ::6
 ::5
*::4   %click to continue, 
 ::5
 ::6
 ::7x0
 ::11
 ::10
 ::9
*::8
 ::9
 ::10
 ::11x0
 ::15
 ::14
 ::13
*::12
 ::13
 ::14
*::15x0
 ::2
 ::1
\end{filecontents*}

\usepackage{mwe}
\usepackage{animate}

\newsavebox\imgx
\newsavebox\imga
\newsavebox\imgb
\newsavebox\imgc

\newlength\fullwidth
\setlength\fullwidth{0.9\textwidth}%

\savebox\imgx{\includegraphics[width=\fullwidth]{example-image}}%
\savebox\imga{\includegraphics[width=\fullwidth]{example-image-a}}%
\savebox\imgb{\includegraphics[width=\fullwidth]{example-image-b}}%
\savebox\imgc{\includegraphics[width=\fullwidth]{example-image-c}}%

\begin{document}

\begin{frame}{Animated zoom-out}\centering

    \begin{animateinline}[timeline=tween.txt,loop]{12} %animation frame rate
        %tween x
        \multiframe{4}{rScale=1+-0.17}{%
            \vbox to 0.75\fullwidth {%
              \hbox to \fullwidth {%
                \scalebox{\rScale}{\usebox\imgx}%
                \hss%
              }%
              \vss% 
            }%
        }%
        \newframe
        %tween a
        \multiframe{4}{rScale=1+-0.17}{%
            \vbox to 0.75\fullwidth {%
              \hbox to \fullwidth {%
                \hss%
                \scalebox{\rScale}{\usebox\imga}%
              }%
              \vss% 
            }%
        }%
        \newframe
        %tween b
        \multiframe{4}{rScale=1+-0.17}{%
            \vbox to 0.75\fullwidth {%
              \vss% 
              \hbox to \fullwidth {%
                \scalebox{\rScale}{\usebox\imgb}%
                \hss%
              }%
            }%
        }%
        \newframe
        %tween c
        \multiframe{4}{rScale=1+-0.17}{%
            \vbox to 0.75\fullwidth {%
              \vss% 
              \hbox to \fullwidth {%
                \hss%
                \scalebox{\rScale}{\usebox\imgc}%
              }%
            }%
        }%
    \end{animateinline}

\end{frame}

\end{document}

enter image description here