0

Objective: First, I put a picture (named test.png) in a circle (made by TikZ). Then, I want to get an animated effect to enlarge the whole figure by controlling the value of the option scale.

The final typeset does not show enlarging figures, however.

Code:

\documentclass{article}
\usepackage{animate,calc,tikz,graphicx}

\newcounter{animate}
\newcommand\test[1]{
  \setcounter{animate}{10 * \real{#1}}
  \begin{animateinline}[autoplay]{12}
    \multiframe{\theanimate}{Rscale=0.1+0.1}{
      \begin{tikzpicture}[transform shape]
        \path
        [path picture={\node at (0,0)
           {\includegraphics[width=2.1cm]{test.png}};},
         draw=orange,thick,scale=\Rscale,
        ] 
        (0,0) circle (1cm);
      \end{tikzpicture}
    }
  \end{animateinline}
}

\begin{document}
\test{3.55}
\end{document}

enter image description here

2 Answers 2

2

From my understanding, \multiframe frames value cannot be a real number, it's must be a integral. And your animation graphic need some space for the picture getting bigger. So you need set a enough size of empty background for the picture (consider the final size of the picture). I draw frame for the background just for showing the effect. Following is a working example.

\documentclass{article}
\usepackage[margin=2cm,showframe]{geometry}
\usepackage{lipsum}
\usepackage{animate,calc,tikz,graphicx}

\newcounter{animate}
\newcommand\test[1]{%
\par{\noindent\centering\setcounter{animate}{10 * #1}%
\begin{animateinline}[poster=last,autoplay,loop]{20}
    \multiframe{\theanimate}{Rscale=0.1+0.1}{
      \begin{tikzpicture}
        \path [draw] (-4,-4) rectangle (4,4);
        \node[circle,draw=orange,thick,scale=\Rscale] at (0,0){\includegraphics[width=1cm]{test.png}};
      \end{tikzpicture}
    }
\end{animateinline}\par}
}

\begin{document}
\lipsum[1]
\test{4}
\lipsum[2]
\end{document}

enter image description here enter image description here

1

It is not clear, how you like to change image size. Just image in the fixed circle size?

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

\begin{document}
    \begin{animateinline}[poster=first, controls, autoplay,
                          ]{10}
\multiframe{12}{Rscale=1+1}%
{
\begin{tikzpicture}
    \path[path picture={\node at (0,0)
           {\includegraphics[scale=\Rscale]{example-image-duck}};},
          draw=orange,thick,
         ]  (0,0) circle (22mm);
\end{tikzpicture}
}
  \end{animateinline}
\end{document} 

enter image description here enter image description here enter image description here

1
  • Thank you so much!! What I want is: the size of the whole figure (that has been made by TikZ,including external picture and the circle) becomes larger and larger, not just the external picture.
    – lyl
    Jun 20 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.