swarm-support
[Top][All Lists]
Advanced

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

ZoomRaster movies


From: Nelson Minar
Subject: ZoomRaster movies
Date: Mon, 21 Jul 1997 17:34:26 +0200

Hungary's cinematographic tradition is so rich and strong, I was
compelled to start making movies with Swarm. Well that, and Benedikt
prodded me a bit. The following is notes for a quick hack-up to record
the contents of a Raster widget to files. Look for it soon on a Swarm
anarchy site near you.

----------------------------------------------------------------------

Here you will find modified versions of four files from swarm-1.0.2.
  src/tkobjc/XColormap.h
  src/tkobjc/XColormap.m
  src/tkobjc/ZoomRaster.h
  src/tkobjc/ZoomRaster.m
To use this code, copy these files over the existing ones in swarm-1.0.2.

The change is to add the following method to ZoomRaster:
  -writeSelfToFile: (char *) f;

Using this method, you can have a ZoomRaster write the contents of the
window to a 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.

This code does not work unless the GUI is running. Sorry about that.
Benedikt might soon have code available to address this limitation.

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. Another is to use fboctree and
fbm2fli (part of the FBM tool suite) to convert the PPMs to one FLI,
an animation format popular on PCs. xanim can display FLI as well.
xanim is at http://xanim.va.pubnix.com/home.html

This code is new and should be considered SEVERELY RADIOACTIVE. Use at
your own risk. It's pretty straightforward. An array is allocated that
the ZoomRaster stores colours into. I've also had to hack up XColormap
a bit to return the RGB information. Some of the details of freeing
memory and background colours might be wrong.

If you use the XDrawer code (say, to represent agents with XPixmaps),
then the pixmaps will not be stored in the movie. Also, images are
written unzoomed.

The main problem with this code is the design. What's really needed in
Swarm is an abstraction of "2d coloured display" that's graphics
independent. Then ZoomRaster would use that abstract data object and
draw its contents. Or a FileRaster would write the image out to a
file. That's the "right" way, and maybe during the redesign of Swarm
for a Java-based GUI this abstraction will be implemented.

Nelson Minar <address@hidden>
Mon Jul 21 17:23:51 MET DST 1997
Budapest, Hungary


                  ==================================
   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]