I want to create a small animation using tikz
and animate
. In order to crop the draw, I use preview
package. Without it I obtain an animation that works fine but when I activate preview I am not able to play the animation.
In the following MNWE, you can obtain the right animation by commenting the lines
\usepackage[active,tightpage]{preview}
\setlength\PreviewBorder{10pt}
\begin{preview}
\end{preview}
For opening the file, I use Acrobat Reader 11 on OSX 10.10.5.
MNWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc,backgrounds}
\usepackage{animate}
\usepackage[active,tightpage]{preview}
\setlength\PreviewBorder{10pt}
%data
\def\itMax{100}
\def\pas{1}
\def\vMax{5}
\def\vMin{-5}
%
\newcommand{\plotPerso}[1]{
\begin{tikzpicture}
%
\draw (-5,\vMin) rectangle (5,\vMax);
\draw[black,very thick] (-5,0) -- (0,#1);
\draw[black,very thick] (5,0) -- (0,#1);
\begin{pgfonlayer}{background}
\path[fill=brown!20] (-5,\vMin) rectangle (5,\vMax);
\end{pgfonlayer}
\end{tikzpicture}
}
\begin{document}
\begin{preview}
\begin{animateinline}[loop, poster = first, controls,autoplay]{60}
\multiframe{\itMax}{icount=1+\pas}
{
\pgfmathsetmacro\incrP{\vMin+((\vMax-\vMin)/\itMax)*\icount}
\plotPerso{\incrP}
%\newframe
}
\end{animateinline}
\end{preview}
\end{document}
standalone
class as an alternative?