From: Ray Strode Date: Thu, 6 May 2010 14:04:26 +0000 (-0400) Subject: [throbber] Change frame sequencer function X-Git-Tag: 0.8.3~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a7be5ab6a349c07d88de97067aa03aaec5d340d;p=thirdparty%2Fplymouth.git [throbber] Change frame sequencer function 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. --- diff --git a/src/libply-splash-graphics/ply-throbber.c b/src/libply-splash-graphics/ply-throbber.c index bba639d1..45638b7a 100644 --- a/src/libply-splash-graphics/ply-throbber.c +++ b/src/libply-splash-graphics/ply-throbber.c @@ -55,6 +55,10 @@ #define FRAMES_PER_SECOND 30 #endif +#ifndef THROBBER_DURATION +#define THROBBER_DURATION 2.0 +#endif + struct _ply_throbber { ply_array_t *frames; @@ -133,6 +137,7 @@ animate_at_time (ply_throbber_t *throbber, 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); @@ -140,8 +145,8 @@ animate_at_time (ply_throbber_t *throbber, 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) {