From 9d8a5d303af1109e5c00cade3b9212daa58ae633 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sun, 21 Jan 2024 00:05:34 -0500 Subject: [PATCH] Ensure progress is 1 at end of animation --- src/anim.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/anim.c b/src/anim.c index fdcac02..408fd62 100644 --- a/src/anim.c +++ b/src/anim.c @@ -42,20 +42,18 @@ int hexagram_anim_step(hexagram_anim *anim, hexagram_anim_progress_fn *fn) { continue; } - if (interval <= offset + duration) { + if (offset + duration >= interval) { break; } offset += duration; } + /* Determine progress through current stop */ if (i == anim->count) { - /* We are apparently at the end. */ - return 0; - } - - /* Determine current progress through current stop */ - if (fn) { + i--; + progress = 1.0; + } else if (fn) { progress = fn(&anim->stops[i], (interval - offset) / anim->stops[i].duration); } else {