Too hungry to think. What would Goku do?

This commit is contained in:
XANTRONIX Development 2024-01-19 19:03:14 -05:00
parent 858c6c2532
commit 4610211f4e
2 changed files with 41 additions and 3 deletions

View file

@ -34,7 +34,7 @@ typedef struct _hexagram_anim_action {
typedef struct _hexagram_anim_stop { typedef struct _hexagram_anim_stop {
hexagram_anim_action *actions; hexagram_anim_action *actions;
size_t actionc; size_t actionc;
double duration_s; double duration;
} hexagram_anim_stop; } hexagram_anim_stop;
typedef struct _hexagram_anim { typedef struct _hexagram_anim {

View file

@ -1,4 +1,5 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <hexagram/anim.h> #include <hexagram/anim.h>
@ -8,6 +9,43 @@ void hexagram_anim_init(hexagram_anim *anim) {
gettimeofday(&anim->start, NULL); gettimeofday(&anim->start, NULL);
} }
int hexagram_anim_step(hexagram_anim *anim, cairo_t *bg, cairo_t *fg) { 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; i<index; i++) {
offset += anim->stops[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;
} }