\section{Animations}

% \begin{animation}[options] with one \animpanel{label}{path} per panel; \N in
% the path is the frame number (figures/anim/case1_0.png, _2, ... _22). The
% panels play in sync. Options:
%   fps=3  frames=first:last:step  width=  columns=N (rows of N panels)
%   controls=all | none | hover | play,step,stop,speed   autoplay  loop
%   subcaptions ((a), (b) before the labels)
%   dt=0.05 (time = frame x dt below the panels)  timelabel={$t = $}
%   timedigits=2  timeunit=s  timebar (progress bar, clickable in HTML)
%   time=false (hide the time value; the timebar keeps its end times)
% \animpanel[frames=a:b:s, dt=...]{label}{path}: a panel with its own range;
% the panels step together (a shorter one holds its last frame) and each
% shows its own time below it.
% In the PDF the animation plays in Acrobat/Okular; the HTML deck plays it
% everywhere. Needs \usepackage{animate}.
\begin{frame}{Animations}{panels in one row}
  \begin{figure}
    \begin{animation}[fps=4, frames=0:22:2, dt=0.1, timebar, controls=hover]
      \animpanel{Case 1}{figures/anim/case1_\N}
      \animpanel{Case 2}{figures/anim/case2_\N}
      \animpanel{Case 3}{figures/anim/case3_\N}
    \end{animation}
    \caption{Three cases in sync; buttons appear on hover in the HTML deck.}
  \end{figure}
\end{frame}

\begin{frame}{Animations}{panels in a grid: \texttt{columns=2}}
  \begin{columns}[c]
    \begin{column}{0.4\textwidth}
      \begin{itemize}
        \item \texttt{columns=2}: rows of two panels
        \item Each label sits on its panel
        \item \texttt{width=} makes the panels smaller
        \item \texttt{subcaptions}: (a), (b), \ldots
      \end{itemize}
    \end{column}
    \begin{column}{0.56\textwidth}
      \begin{figure}
        \begin{animation}[fps=4, frames=0:22:2, columns=2, width=0.35\linewidth,
                          subcaptions, dt=0.1, timelabel={$\tau = $}]
          \animpanel{Case 1}{figures/anim/case1_\N}
          \animpanel{Case 2}{figures/anim/case2_\N}
          \animpanel{Case 3}{figures/anim/case3_\N}
          \animpanel{Case 4}{figures/anim/case4_\N}
        \end{animation}
        \caption{Four cases, two per row.}
      \end{figure}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}{Animations}{panels with their own frames}
  \begin{figure}
    \begin{animation}[fps=4, frames=0:22:2, dt=0.1, timebar, controls=hover]
      \animpanel{Frames 0--22}{figures/anim/case1_\N}
      \animpanel[frames=4:22:2]{Frames 4--22}{figures/anim/case2_\N}
      \animpanel[frames=0:10:2, dt=0.5]{Frames 0--10, own dt}{figures/anim/case3_\N}
    \end{animation}
    \caption{\texttt{\textbackslash animpanel[frames=4:22:2]}: each panel shows its own time.}
  \end{figure}
\end{frame}

% \slidevideo[options]{file}: a video (MP4 or WebM). Options: width, height,
% poster (image shown until it plays, and in the PDF), autoplay (when the
% slide or step comes up), loop, muted, controls (true), start, end (seconds).
% It pauses when you leave the slide. In the PDF: the poster linking to the
% file -- or, with \usepackage{multimedia}, a \movie (plays in Okular, ...).
\begin{frame}{Videos}{\texttt{\textbackslash slidevideo}}
  \begin{columns}[c]
    \begin{column}{0.4\textwidth}
      \begin{itemize}
        \item MP4 or WebM, with the browser's controls
        \item \texttt{autoplay}, \texttt{loop}, \texttt{muted}
        \item \texttt{start=}, \texttt{end=}: play part of it
        \item Pauses when you leave the slide
      \end{itemize}
    \end{column}
    \begin{column}{0.56\textwidth}
      \begin{figure}
        \slidevideo[width=\linewidth, poster=figures/sample-video.png,
                    autoplay, loop, muted]{figures/sample-video.mp4}
        \caption{A video that plays with its slide.}
      \end{figure}
    \end{column}
  \end{columns}
\end{frame}
