Graphics, Figures & Tablesanimate, tikZ | Unexpected Result

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

animate, tikZ | Unexpected Result

Post by mas »

I was able to get the animation for a series of bitmap files using the animate package. I thought of using it for a figure drawn in TikZ.

Here is the MWE:

Code: Select all

\documentclass{beamer}
\usepackage{tikz}
\usepackage{animate}

\begin{document}
  \begin{frame}
    \begin{center}
      \begin{animateinline}[
        loop,
        controls,
        begin={\begin{tikzpicture}},
        end={\end{tikzpicture}}
      ]{1}
        \newframe
        \draw[fill=red] (0,0) circle (3cm);
        \newframe
        \draw[fill=blue] (0,0) circle (6cm);
      \end{animateinline}
    \end{center}
  \end{frame}
\end{document}
When I try to compile this, I get the following error:

Code: Select all

! Package animate Error: Contents of first frame must not have zero width.

See the animate package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.19 \end{frame}

?
Assuming that there was a problem in getting the dimensions, I added something like
\draw (-4,-4) rectangle (4,4); just before the first \newframe command. It was successful. But, I was surprised to see both the circles being drawn with the same radius.

Any pointers would be helpful.

Regards.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

alex
Posts: 32
Joined: Mon May 19, 2008 10:53 am

animate, tikZ | Unexpected Result

Post by alex »

In your example, there is no material in the first frame between \begin{animateinline}... and \newframe. The size of the first frame is measured to set the animation box dimensions in the document.

All subsequent frames will be scaled anamorphically to fit into the animation box. Therefore both circles are displayed at the same size. You need to set-up a bounding box of fixed size that is used with each of the animation frames.

Instead of \draw, put \useasboundingbox in front of the rectangle and move this command from the first frame into the code of the begin option. See animate doc on page 8.
Last edited by alex on Thu Jan 24, 2013 2:41 pm, edited 1 time in total.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Re: animate, tikZ | Unexpected Result

Post by mas »

Thanks. That solved the problem.

Regards.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
Post Reply