comparison src/animate.c @ 51:5f5bd3ac9316

documentation
author Thinker K.F. Li <thinker@branda.to>
date Sat, 09 Aug 2008 21:34:07 +0800
parents c986e45c1e91
children 59a295651480
comparison
equal deleted inserted replaced
50:c986e45c1e91 51:5f5bd3ac9316
33 mb_timeval_t abs_start, abs_stop; 33 mb_timeval_t abs_start, abs_stop;
34 STAILQ(mb_action_t) actions; 34 STAILQ(mb_action_t) actions;
35 }; 35 };
36 36
37 /*! \brief A program describe a series of actions to animate shapes. 37 /*! \brief A program describe a series of actions to animate shapes.
38 *
39 * first_playing is an index to one of words. It always points to
40 * the first of words that is playing or waiting for playing.
38 */ 41 */
39 struct _mb_progm { 42 struct _mb_progm {
40 redraw_man_t *rdman; 43 redraw_man_t *rdman;
41 44
42 mb_timeval_t start_time; 45 mb_timeval_t start_time;
47 int max_words; 50 int max_words;
48 mb_word_t words[1]; 51 mb_word_t words[1];
49 }; 52 };
50 53
51 /*! \brief Basic class of nnimation actions. 54 /*! \brief Basic class of nnimation actions.
55 *
56 * A action must implement following 4 functions.
57 * \li start,
58 * \li step,
59 * \li stop,
60 * \li free, and
61 * \li *_new().
62 *
63 * *_new() must invokes mb_word_add_action() to add new object
64 * as one of actions in the word specified as an argument of it.
65 * It also means *_new() must have an argument with type of
66 * (mb_word_t *).
52 */ 67 */
53 struct _mb_action { 68 struct _mb_action {
54 int act_type;
55 void (*start)(mb_action_t *act, 69 void (*start)(mb_action_t *act,
56 const mb_timeval_t *now, 70 const mb_timeval_t *now,
57 const mb_timeval_t *playing_time, 71 const mb_timeval_t *playing_time,
58 redraw_man_t *rdman); 72 redraw_man_t *rdman);
59 void (*step)(mb_action_t *act, const mb_timeval_t *now, 73 void (*step)(mb_action_t *act, const mb_timeval_t *now,
262 mb_timeval_t start_time; 276 mb_timeval_t start_time;
263 co_aix saved_matrix[6]; 277 co_aix saved_matrix[6];
264 const mb_timeval_t *playing_time; 278 const mb_timeval_t *playing_time;
265 }; 279 };
266 280
267 static float comp_mb_timeval_ratio(mb_timeval_t *a, const mb_timeval_t *b) { 281 static float comp_mb_timeval_ratio(const mb_timeval_t *a,
282 const mb_timeval_t *b) {
268 float ratio; 283 float ratio;
269 284
270 ratio = (float)MB_TIMEVAL_SEC(a) * 1000000.0 + (float)MB_TIMEVAL_USEC(a); 285 ratio = (float)MB_TIMEVAL_SEC(a) * 1000000.0 + (float)MB_TIMEVAL_USEC(a);
271 ratio /= (float)MB_TIMEVAL_SEC(b) * 1000000.0 + (float)MB_TIMEVAL_USEC(b); 286 ratio /= (float)MB_TIMEVAL_SEC(b) * 1000000.0 + (float)MB_TIMEVAL_USEC(b);
272 return ratio; 287 return ratio;