This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
How to | Create Animations
Animations can convey much more information than static displays. The built-in Mathematica functions Animate and ListAnimate provide an immediate way to construct animations of graphics or any other kind of expression in a Mathematica notebook. There are many other ways to interact with animations, including using interface-building tools like Manipulate and Dynamic, or file manipulation tools like Import and Export.
Use Animate to animate a picture of for changing values of :
In[107]:=
Click for copyable input
Out[107]=
Mathematica can animate any expression, not just graphics. Here, Animate scans through integer powers of a polynomial. The DefaultDuration option specifies how long the animation should take from start to finish, in seconds:
In[1]:=
Click for copyable input
Out[1]=
    
Use ListAnimate to animate a list of objects. Setting the AnimationRunning option to False prevents the animation from starting automatically:
In[109]:=
Click for copyable input
In[110]:=
Click for copyable input
Out[110]=
    
For continuous ranges, Manipulate includes animation controls, which are hidden by default. Show them automatically by setting the Appearance option to . Notice that you can animate multiple variables at once:
    
Pass a list of graphics or any other expression to Export to create an animation in an "SWF", "AVI", "TIFF", or animated "GIF" file. Export will also create an animation instead of a list when given a Manipulate, Animate, or ListAnimate:
In[36]:=
Click for copyable input
In[37]:=
Click for copyable input
Out[37]=
Import a "QuickTime", "AVI", "TIFF", or animated "GIF" file with to obtain a list of images in the animation:
In[38]:=
Click for copyable input
Out[38]=
Import just a single frame of the animation:
In[39]:=
Click for copyable input
Out[39]=
In[40]:=
Click for copyable input
Out[40]=
    
The Animator control can be used directly to dynamically control an animating variable, outside the structure of Animate or Manipulate:
In[22]:=
Click for copyable input
Out[22]=
Out[23]=
A Dynamic that automatically changes itself is effectively a self-contained animation. DynamicModule localizes and stores the value of the variable counter:
In[31]:=
Click for copyable input
Out[31]=
The Clock function can also be used in Dynamic to drive a time-based animation. Here is a disk which changes color from Hue to Hue every 20 seconds:
In[49]:=
Click for copyable input
Out[49]=