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

:
| Out[1]= |  |
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:
| Out[2]= |  |
Use
ListAnimate to animate a list of objects. Setting the
AnimationRunning option to
False prevents the animation from starting automatically:
| Out[4]= |  |
For continuous ranges,
Manipulate includes animation controls, which are hidden by default. Show them automatically by setting the
Appearance option to
"Open". 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:
| Out[7]= |  |
Import a
"QuickTime",
"AVI",
"TIFF", or animated
"GIF" file with
"ImageList" to obtain a list of images in the animation:
| Out[8]= |  |
Import just a single frame of the animation:
| Out[9]= |  |
| Out[10]= |  |
The
Animator control can be used directly to dynamically control an animating variable, outside the structure of
Animate or
Manipulate:
| Out[11]= |  |
| Out[11]= |  |
A
Dynamic that automatically changes itself is effectively a self-contained animation.
DynamicModule localizes and stores the value of the variable counter:
| Out[12]= |  |
The
Clock function can also be used in
Dynamic to drive a time-based animation. Here is a disk which changes color from
Hue[0] to
Hue[1] every 20 seconds:
| Out[13]= |  |