3

I am working on an animation for a presentation - a grid is deformed and reformed. I cobbled together a quick animation that does what I want, but for some reason it also shrinks the drawing. Is this a known issue? Does anyone know how I can prevent this shrinkage?

For simplicity I have, in addition to the MWE, included an image which shows the first and last frames. Note how the lines at the extremes of the grid should end at the very same coordinates throughout the animation: Deformation

\documentclass{article}
\usepackage{tikz}
\usepackage{animate}

\begin{document}
\begin{animateinline}[controls,palindrome]{10}
  \multiframe{10}{i=0+1}{%
\begin{tikzpicture}
\clip (0,0.3)..controls + (.075*\i,-2.5) and +(-.075*\i,2.5) .. (0,-6.3)--
    (-0.3,-6)..controls + (2.5,-.075*\i) and +(-2.5,.075*\i) .. (6.3,-6)--
    (6,-6.3)..controls + (-.075*\i,2.5) and +(.075*\i,-2.5) .. (6,.3)--
    (6.3,0)..controls + (-2.5,.075*\i) and + (2.5,-.075*\i) .. (-.3,0);
  \foreach \x in {0,...,6}{
    \draw (\x,0.3)..controls + (.075*\i,-2.5) and +(-.075*\i,2.5) .. (\x,-6.3);
    \draw (-0.3,-\x)..controls + (2.5,-.075*\i) and +(-2.5,.075*\i) .. (6.3,-\x);
}
\end{tikzpicture}}
\end{animateinline}
\end{document}

1 Answer 1

6

TikZ computes the bounding box of a tikzpicture environment from the objects it contains. This auto-computed bounding box may differ from animation frame to animation frame. With pkg animate, all frames are scaled to fit into the dimensions defined by the first animation frame, which may lead squeezing and/or stretching of frames if the BBox dimensions differ from those of the first frame. To solve this, enforce a common bounding box to be used by all frames:

\useasboundingbox (...,...) rectangle (...,...);

Complete example:

\documentclass{article}
\usepackage{tikz}
\usepackage{animate}

\begin{document}
\begin{animateinline}[controls,palindrome]{10}
  \multiframe{10}{i=0+1}{%
    \begin{tikzpicture}
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      \useasboundingbox (-0.3,0.3) rectangle (6.3,-6.3);
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      \clip (0,0.3)..controls + (.075*\i,-2.5) and +(-.075*\i,2.5) .. (0,-6.3)--
        (-0.3,-6)..controls + (2.5,-.075*\i) and +(-2.5,.075*\i) .. (6.3,-6)--
        (6,-6.3)..controls + (-.075*\i,2.5) and +(.075*\i,-2.5) .. (6,.3)--
        (6.3,0)..controls + (-2.5,.075*\i) and + (2.5,-.075*\i) .. (-.3,0);
      \foreach \x in {0,...,6}{
        \draw (\x,0.3)..controls + (.075*\i,-2.5) and +(-.075*\i,2.5) .. (\x,-6.3);
        \draw (-0.3,-\x)..controls + (2.5,-.075*\i) and +(-2.5,.075*\i) .. (6.3,-\x);
      }
    \end{tikzpicture}}
\end{animateinline}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .