From ecf831d4ac4738fa26caecd4e4f95da3b686a716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 6 Jan 2025 00:56:40 +0100 Subject: [PATCH] frobar-ng: Improve animation --- hm/desktop/frobar/.dev/new.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hm/desktop/frobar/.dev/new.py b/hm/desktop/frobar/.dev/new.py index 7f314ab..d5b74b8 100644 --- a/hm/desktop/frobar/.dev/new.py +++ b/hm/desktop/frobar/.dev/new.py @@ -139,13 +139,14 @@ class Section(ComposableText): # Geometric series, with a cap ANIM_A = 0.025 ANIM_R = 0.9 - ANIM_MIN = 0.001 + ANIM_MIN = 0.005 async def animate(self) -> None: increment = 1 if self.size < self.targetSize else -1 loop = asyncio.get_running_loop() frameTime = loop.time() animTime = self.ANIM_A + skipped = 0 while self.size != self.targetSize: self.size += increment @@ -158,9 +159,12 @@ class Section(ComposableText): # In case of stress, skip refreshing by not awaiting if sleepTime > 0: + if skipped > 0: + log.warning(f"Skipped {skipped} animation frame(s)") + skipped = 0 await asyncio.sleep(sleepTime) else: - log.warning("Skipped an animation frame") + skipped += 1 def setText(self, text: str | None) -> None: # OPTI Don't redraw nor reset animation if setting the same text