From: Abraham S. <ab...@cn...> - 2005-09-15 20:20:49
|
Hi. I have the need to both display animations real time and to save them as files. Unfortunately, currently there doesn't seem a good unified method (although code currently exists on the web page to do both). I decided to try to unify animations with a couple of simple Python classes: AnimationController - attached to an already drawn plot, and determines how specific plot will change over time (this is base class, so the functions: reset(), next(), prev(), and data() have to be overridden) Animation - A collection of plots and AnimationControllers (1-to-1). Each cycle will have AnimationController update their corresponding plots (this is base class, so the function run() has to be overridden) Then I have two backends for the Animation: GTKAnimation - creates a 'live' animation FileAnimation - creates an MPEG file so all you need to do, is create your own AnimationController, and you can automatically create an MPEG file, or display the data live. I thought I would throw this out there, and see if maybe other people were interested (and if maybe a toolkit should be created). Theres still some work to make it more flexible, and have more backends. Also, the FileAnimation is really a bad hack (using techniques suggested from previous posts). On my current system I couldn't get mencoder to work correctly (or mplayer, for that matter), so I had to use 'convert', but it's fairly easy to change it. Of course, ideally using the FFMPEG library would be best, but I don't have time to write the necessary SWIG files just now. Also included is a quick example of phase-shifting sine-waves. Abe |