MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Animation?


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11772] Re: Animation?
  • From: "P.J. Hinton" <paulh@wolfram.com>
  • Date: Sat, 28 Mar 1998 00:25:12 -0500
  • Organization: Wolfram Research, Inc.
  • References: <6fd4hs$69d@smc.vnet.net>

On 26 Mar 1998, Chris Farr wrote:

> I have a sequence of 3d plots, grouped together, that I animate by 
> double-clicking on the first cell.  I would like to show others this 
> animation, yet when I saved the notebook, it was quite large about 3 
> MB.  Can I make the file size smaller so I can put it on a disk to show
> to others?

The reason for the sheer size is that the notebook stores both the
abbreviated PostScript needed to render the graphic as well as a bitmap
cache that helps you bypass the time needed to rerender each graphic
when the notebook is reopened.  

The size of the PostScript code is a function of the complexity of the
graph.  If you trying to create high quality graphics, then you
probably don't have much leeway in controlling this aspect.

The size of each bitmap cache is a function of the color depth of the
screeen; i.e. the cache will grow if you generate the graphics using
8-bit, 16-bit, and 24-bit displays, so generating the graphics at a
lower depth might be an option for you. 

> Also, is there anyway, I could export this animation to some kind of 
> animated gif file to reduce the size of this animation.  I would also 
> like to put this animation on a web page if possible. 
> Any ideas?

You can use the kernel function Display[ ] to export graphics a GIF
files. However, the job of stringing them together to make an animated
graphic will have to be done by an outside application

Here is an example that shows you how you can generate these GIFs with a
program.

(* Many animations stem from generating graphs of a function for various
parameters.  Here we see how one can generate a series of six graphs of
Sin[2 Pi f t] over the interval 0 <= t <= 1 and f = 0, 4, 8, 12, 16,
and 20. *) 

i = 0;graphicsList = 
  Table[{i++; ToString[i],
     Plot[Sin[2 \[Pi] f t],{t,0,1}, DisplayFunction -> Identity]},
      {f,0,20,4}];

(* We use a counter variable i to associate each graphic with an index
that indicates where in the animation the graphic will appear. The
index is converted to a string because it will be concatenated with
other strings to make a filename. *) 

(* Evaluation of the above expression will give a result that looks like
*)

{{"1",-Graphics-},{"2", -Graphics-},{"3", -Graphics-},{"4", -Graphics-},
  {"5", -Graphics-}, {"6", -Graphics-}}

(* We can then use the function programming construct Scan[] to apply a 
function to each element of the above list. *)

Scan[Display["frame" <> #[[1]] <> ".gif", #[[2]], "GIF"]&, graphicsList]

The strings containing numbers go into the slot #[[1]], and the graphics
objects go into the second slot #[[2]].  Each graphic is saved to a
filename of the form. 

                        frame<number>.gif

The files will be written to the current working directory of the
kernel.  If you wish to change the working directory, simply evaluate
the function

                        SetDirectory[<path>]

where <path> is a string with the name of the file's path.

--
P.J. Hinton
Mathematica Programming Group           paulh@wolfram.com Wolfram
Research, Inc.                  http://www.wolfram.com/~paulh/
Disclaimer: Opinions expressed herein are those of the author alone.




  • Prev by Date: Re: Vectors and Mathematica
  • Next by Date: Re: A stupid question...
  • Prev by thread: Animation?
  • Next by thread: Re: Animation?