MathGroup Archive 2001

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

Search the Archive

Re: Re: Mathematica generating gifs for avi's


On Sun, 8 Jul 2001 axc at whitesnake.ces.cwru.edu wrote:

> you're right it works. but listen to the steps i have to take to
> generate avi's for my presentation. nevermind generating names such as
> 'frame00001.gif' so that the shareware converter (in this case gif
> movie gear) loads them in the correct order - even so there are always
> several frames out of sequence and i have to permute them manually,
> for each .avi.

You could save yourself a lot of headaches by indexing your graphics as
you generate them and then using string manipulation functions to create
file names that are expected by the third-party program.

Suppose that we want to save out a large collection of graphics with a
Table[] operation.  For each Graphics object, we create an index and then
pad the index with an appropriate number of zeros.  Here, we pad the index
such that at leas four digits are always visible.

padZeros[str_String, len_Integer] :=
   Module[
     {numzeros, padstring},
     numzeros = len - StringLength[str];
     If[
       numzeros > 0,
       padstring = StringJoin @@ Table["0", {numzeros}];
       padstring <> str,
       str
     ]
   ]

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

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

-- 
P.J. Hinton
User Interface Programmer                         paulh at wolfram.com
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.



  • Prev by Date: Re: Mathematica and Scientific Workplace
  • Next by Date: Re: Math Fonts in EPS-exported graphs
  • Previous by thread: Re: Mathematica generating gifs for avi's
  • Next by thread: Re: Mathematica generating gifs for avi's