[metapost] Animated graphics with Metapost?

Karel akk64 at quick.cz
Sat Jun 11 11:37:00 CEST 2011

luigi scarso napsal(a):
> On Sat, Jun 11, 2011 at 8:18 AM, Dirk Laurie <dpl at sun.ac.za> wrote:
>> I'd like to make an incremental version of a drawing, i.e.
>> when displayed it starts of with just a line and gradually
>> adds more lines, points, color fill-ins etc, which one can
>> then display as an animation.
>> I've thought of this approach:
>> 1. Make a Metapost drawing of each stage, with the visible parts
>>    in black and the not-yet visible parts white.  This is the
>>    same drawing each time with only the colors varying so that
>>    there is no problem about superimposing frames of different size.

In that stage it is not necessary to draw whole  image  in white, 
you can keep only its bounding box and then use it with every next 
picture (see mpman.pdf, bbox macro, then use setbounds for every 
partial picture).

Now you can define a sequence of pictures:

picture p[];
path bb;

p1:=image(...first drawing..);
p2:=image(some add. drawing);
p<number>:=image(last part of drawing);

Finally you can produce a sequence of final PS pictures:

beginfig(0); %% the whole picture for the common bbox
for k=1 upto <number>: draw p[k]; endfor

for $=1 upto <number>:
beginfig($); for k=1 upto $: draw p[k]; endfor
setbounds currentpicture  to bb;

>> 2. Import the Postscript files into GIMP and get it to make them
>>    into an animated GIF.

There are many ways how to convert resulting PS files into one 

Happy mposting,
Karel Horak

More information about the metapost mailing list