What is Animation?

Animation is a program to move, resize, rotate, ..., changing graphics on the output screen.

program.png

XXX: Program is a sequence of actions duration a perior. Actions are grouped into words. A program defines the order and time of playing of words. A word defines how long to perform a set of actions. Actions in a word are performed concurrently.

Animation shapes are updated periodically. Every action are working with start, step, and stop 3 calls. start is called when start time the word, contain it, due. step is called periodically in duration of playing time start at 'start time'. When the clock run out the playing time of a word, it call stop of actions in the word.

A program is driven by a timer. Once a program is started, it registers with timer for periodic running. mb_tman_t is timer of MadButterfly. The update frequence is 10fps by default, now.

How to Use Animation Program?

Following code block creates a program with 2 words. First word is started immediately after the program been started. It is consisted for 1 second. Second word is started 1 second after the program been started. It is consisted for 2 seconds. There are 2 action in first word, they shift graphics managed by coord1 & coord2 by (50,50) and (-50,50) pixels, respectly. The shifting is performed incrementally in 1 second. Second word shifts coord1 and coord2, too. And, graphics managed by coord3 are hidden at end of the word. At end of code in the block, mb_progm_start() starts the program. 3rd argument of mb_progm_start() must be current wall time.

        progm = mb_progm_new(10, &rdman);
        
        MB_TIMEVAL_SET(&start, 0, 0);
        MB_TIMEVAL_SET(&playing, 1, 0);
        word = mb_progm_next_word(progm, &start, &playing);

        act = mb_shift_new(50, 50, coord1, word);
        act = mb_shift_new(-50, 50, coord2, word);

        MB_TIMEVAL_SET(&start, 1, 0);
        MB_TIMEVAL_SET(&playing, 2, 0);
        word = mb_progm_next_word(progm, &start, &playing);

        act = mb_shift_new(0, 20, coord1, word);
        act = mb_shift_new(0, -20, coord2, word);
        act = mb_visibility_new(VIS_HIDDEN, coord3, word);

        gettimeofday(&tv, NULL);
        MB_TIMEVAL_SET(&mbtv, tv.tv_sec, tv.tv_usec);
        mb_progm_start(progm, tman, &mbtv);

See also:
animate.c
SourceForge.net Logo