#include #include #include void hexagram_anim_init(hexagram_anim *anim) { anim->current = 0; gettimeofday(&anim->start, NULL); } static inline double tv_seconds(struct timeval *tv) { return (double)tv->tv_sec + (double)tv->tv_usec / 1000000.0; } static inline double stop_offset(hexagram_anim *anim, size_t index) { double offset = 0.0; size_t i; for (i=0; istops[i].duration; } return offset; } static inline size_t stop_index(hexagram_anim *anim, double offset) { return 0; } int hexagram_anim_step(hexagram_anim *anim, cairo_t *bg, cairo_t *fg) { struct timeval tv; double offset, interval; size_t i; if (anim->current >= anim->count) { goto done; } gettimeofday(&anim->now, NULL); timersub(&anim->now, &anim->start, &tv); interval = tv_seconds(&tv); done: return 0; next: return 1; }