0

Okay, so I have tried to go over this package: http://mirror.its.dal.ca/ctan/macros/latex/contrib/animate/animate.pdf

And I'm having a hard time trying to understand it. So right now, I just tried to start off simple to basically self-teach myself how to animate a ball that rolls from one end of the line to the other.

I'll present my drawing code for the line and ball:

\documentclass[tikz]{standalone}

\usepackage{animate}

\standaloneconfig{border=5cm}

\begin{document}
\begin{tikzpicture}
    \filldraw[very thick, fill=red!50] (0,0) circle [radius=10cm];
    \draw (-10,-10) -- (110,-10);
\end{tikzpicture}
\end{document}

All I want to do is translate the circle from (0,0) to (100,0). Just trying to figure out how to do something as simple as that seems rather difficult from the animate package.

Basically, I have two questions, in a way:

  • Is there a nice simple code for something like this?

  • Are there some really simple examples on this package or some nicer and simpler documentation?

2

All you need to do is to parameterize the x-position of the ball, put a loop around the tikzpicture and place everything into an animateinline environment:

\documentclass{standalone}
\standaloneconfig{border=1ex}

\usepackage{animate}
\usepackage{tikz}

\begin{document}

\begin{animateinline}[controls]{30} % 30 frames per second
  \multiframe{101}{iPosition=0+1}{ % iPosition=0...100
    \begin{tikzpicture}[x=0.1cm,y=0.1cm]
      \filldraw[very thick, fill=red!50] (\iPosition,0) circle [radius=10];
      \draw (-10,-10) -- (110,-10);
    \end{tikzpicture}
  }
\end{animateinline}

\end{document}

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.