swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making movies in batchmode


From: Benedikt Stefansson
Subject: Making movies in batchmode
Date: Thu, 24 Jul 1997 18:32:34 +0200

Budapest, July 24th 1997 

I'm  glad to announce  that I have hacked Nelson's  ZoomRaster and
XColormap so that you can  now run Swarm programs  in batchmode, save 
the image on the raster and create animations offline. 

I'm uploading a tar archive with two new classes, BatchRaster and
BatchColormap, and a Perl script to convert the PPM images that result
into GIFs that you can view as an animation. It should pop up on the
http://www.santafe.edu/projects/swarm/users/user-community.html page
when Glen has the time to update it.


-More information... 

The two classes I have created should behave exactly as ZoomRaster and
XColormap. Note that to compile BatchColormap the file colors.m has to
be in the same directory. See the PS to this message for more info.

Since the Swarm GUI will be ported to Java in the very near future,
these classes will probably have to be reoriented within the Swarm libs
and at this point it is probably better to keep them somwhere in a
seperate place.

BatchColormap: 

Has all the functionality of XColormap,  but is subclassed from Swarm,
(i.e. swarmobject) so do static typing accordingly. 

BatchRaster: 

Also subclassed from Swarm. Adds the  writeSelfToFile:  method as in  
Nelson's hacked  version of ZoomRaster.  I took  out several  methods
that don't  make any  sense, notably: 
        -setWindowTitle: 
        -setButton:Client:Message: 
        -increaseZoom 
        -decreaseZoom 
        -setZoomFactor: 

-How to use... 

Read Nelson's posting from earlier this week. To quote: 

"The [BatchRaster] object now has a method to write it self to file. You
can then schedule writes with  some frequency to get  the frames of  a
movie. For instance, this is a handy ObserverSwarm method suitable for
scheduling: 
 
 -writeFrame {
    char filename[256];
    sprintf(filename, "%06d.ppm", getCurrentTime());
    [worldRaster writeSelfToFile: filename];
  }

this will make a file called 000023.ppm, where 000023 is the current
simulation time. Schedule as desired. Files are 3 bytes per pixel.

The image format is PPM, the "Portable Pixmap" format. xv knows how to
read it and there's a suite of tools called "netpbm" that have all
sorts of capabilities like converting PPM to GIF, etc. Many Unix
systems already have these programs installed. Try running "ppmtogif".

One way to show a movie is to convert all the PPM files to GIF and
then run "xanim *.gif" on all the GIFs."

-And finally...

As an addendum to this, the GIF files that result are much smaller
than the PPM files, so it pays to convert those quickly. A 50 x 50
results in (approx) 250 byte (not Kb!) GIF file for example. since it is 
only 2500 pixels. The image is very small on the screen. Once you have
xanim check the doc's for info on how you resize the animation.

A fun thing is to use this to create animated GIF89 movies for
Netscape, but you need to use ImageMagick or something equivalent to
resize the GIFs on the fly and a program like gifmerge to create the
animation.

I hope you all have a fun time with this. Please let me know if there
are problems (and successes!).

Benedikt Stefansson
Department of Economics, UCLA

PS: Some background... 

After I had  bugged Nelson into hacking  a version  of ZoomRaster that
can save it self to disk, I couldn't  resist the challenge of creating
a "BatchRaster" that can do the same without the GUI running. 

This should have been  straightforward; Nelson had already written the
crucial part of the code, all I needed was to give the delete, copy and
paste buttons some workout. The problem was that I wanted the
-setColor:toName: method to work and that required a mapping from X11
colornames to RGB values. 

The solution was  to extract  this  information from the rgb.txt  file
which  sits somewhere in   your   X11 libraries (in  different  places
depending on machines). Since I didn't have the patience to write C code
that would  parse this  ASCII file  at runtime   the mappings are  now
"hardcoded" into a file called colors.m which is needed to compile the
colormap object. 

I   used a  Perl  script  to  create the   colors.m  file, and  if you
experience any  problems with the colormapping on  your machine,  I am
happy to give you the script so  you can generate an appropriate color
file.

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]