Top |
int | abydos_get_frame_count () |
double | abydos_get_total_duration () |
int | abydos_get_frame_at_time () |
double | abydos_get_frame_duration () |
double | abydos_get_time () |
int | abydos_get_frame () |
cairo_bool_t | abydos_set_time () |
cairo_bool_t | abydos_add_time () |
void | abydos_set_frame () |
void | abydos_set_frame_default () |
void | abydos_next_frame () |
double | abydos_get_delay () |
Two approaches can be used for handling animations. Either by frame or by time. The latter is usually more convinient for displaying the animation. Abydos can tell you for how long you should display a frame, or how long you should wait before updating the time of the animation and redraw it. But measuring time is beyond the scope of abydos. Basically you do something like this.
1 2 3 4 5 6 7 8 |
last_time = now(); for(;;){ abydos_render(ar,cr,0); delay(abydos_get_delay(ar)); this_time = now(); abydos_add_time(ar,this_time - last_time) last_time = this_time; } |
Of course you don't want to use a simple delay in a real application.
Instead you should use some kind of event scheduler to get a callback.
Please also note that if you need to round the delay time you get from
abydos_get_delay()
you must round it up. Otherwise the time of the
animation will be set to right before the frame change (and the next time
it will be rounded down to zero and you will get nowere).
int
abydos_get_frame_count (abydos_t *ar
);
Get the number of frames of an animation. Some animations may not be
based around the concept of frames but are continous to their nature. In
this case ABYDOS_FEATURE_SCALABLE_TIME
will be set and frames will be
placed at reasonable intervals. It is also possible that
ABYDOS_FEATURE_SCALABLE_TIME
is set for singe frame images (and duration
of zero). In that case the image will still be animated somehow, but
depending on some external variable (such as the clock time).
retutns: The number of frames.
double
abydos_get_total_duration (abydos_t *ar
);
Get the total duration of an animation.
int abydos_get_frame_at_time (abydos_t *ar
,double sec
);
Get the index if the frame at sec
. Note that this cannot simply be
calculated by dividing sec
with the duration of the first frame, since
frames may have different duration.
double abydos_get_frame_duration (abydos_t *ar
,int frame
);
Get the time (into the animation) at which frame
should appear.
cairo_bool_t abydos_set_time (abydos_t *ar
,double sec
);
Set the time of the animation in seconds. It will also implicitly set the corresponding frame.
cairo_bool_t abydos_add_time (abydos_t *ar
,double sec
);
Advance the animation sec
seconds. It will also implicitly set the
corresponding frame.
void abydos_set_frame (abydos_t *ar
,int frame
);
Select frame
which will also implicitly set the time of the animation to
the time for this frame.
void
abydos_set_frame_default (abydos_t *ar
);
Selectes the frame that is defined as the default frame (or the first frame if no default frame is defined). Call this function if you intend to show only one frame. (It is currently assumed that you are going to show the animation from beginning to end so the first frame is initially selected, but that may change.)
void
abydos_next_frame (abydos_t *ar
);
Advance the animation one frame and increse the time accordingly.
double
abydos_get_delay (abydos_t *ar
);
Get the amount of time until the next frame in seconds. Note that if this value needs to be rounded for some reason, it must be rounded up (otherwise the next time advancement will land right before the frame change).