LaTeX forum ⇒ Graphics, Figures & Tablesanimate, tikZ | Unexpected Result Topic is solved

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

animate, tikZ | Unexpected Result

Postby mas » Wed Jan 23, 2013 3:17 pm

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:
  1. \documentclass{beamer}
  2. \usepackage{tikz}
  3. \usepackage{animate}
  4.  
  5. \begin{document}
  6. \begin{frame}
  7. \begin{center}
  8. \begin{animateinline}[
  9. loop,
  10. controls,
  11. begin={\begin{tikzpicture}},
  12. end={\end{tikzpicture}}
  13. ]{1}
  14. \newframe
  15. \draw[fill=red] (0,0) circle (3cm);
  16. \newframe
  17. \draw[fill=blue] (0,0) circle (6cm);
  18. \end{animateinline}
  19. \end{center}
  20. \end{frame}
  21. \end{document}

When I try to compile this, I get the following error:
  1. ! Package animate Error: Contents of first frame must not have zero width.
  2.  
  3. See the animate package documentation for explanation.
  4. Type H <return> for immediate help.
  5. ...
  6.  
  7. l.19 \end{frame}
  8.  
  9. ?

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

Tags:

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

Postby alex » Thu Jan 24, 2013 10:46 am

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: 223
Joined: Thu Dec 04, 2008 4:39 am

Postby mas » Thu Jan 24, 2013 1:54 pm

Thanks. That solved the problem.

Regards.

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


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: Google [Bot] and 7 guests