The throbber has a function for determining which frame
to show based on the current time. This function was:
ƒrame(t) = number_of_frames ∙ (⅟₂ sin(t) + ⅟₂)
Which basically oscillates between 0 and number_of_frames - 1,
over and over again. There are two problems with this function;
- after it runs through all the frames in order, it then procedes
to run through them backward.
- This function also starts in the middle of the set of throbber
frames.
These problems don't matter for spinfinity, but will look wrong for most
other themes.
The new function is this:
ƒrame(t) = number_of_frames ∙ (1⁄duration)(t mod duration)
This function solves both problems. At time 0 it uses frame 0, and
after the last frame it jumps back to the first frame.
#define FRAMES_PER_SECOND 30
#endif
+#ifndef THROBBER_DURATION
+#define THROBBER_DURATION 2.0
+#endif
+
struct _ply_throbber
{
ply_array_t *frames;
int number_of_frames;
ply_pixel_buffer_t * const * frames;
bool should_continue;
+ double percent_in_sequence;
number_of_frames = ply_array_get_size (throbber->frames);
return true;
should_continue = true;
-
- throbber->frame_number = (.5 * sin (time) + .5) * number_of_frames;
+ percent_in_sequence = fmod (time, THROBBER_DURATION) / THROBBER_DURATION;
+ throbber->frame_number = (int) (number_of_frames * percent_in_sequence);
if (throbber->stop_trigger != NULL)
{