From 65aa99c883fc215c4f89be44858157f535c12a17 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Tue, 16 Apr 2024 09:35:55 -0700 Subject: [PATCH] Precomputed easing values. When panning the star map it would be well to have a smooth animation for the movement. THese values are from easeInOutQuad at: => https://gist.github.com/gre/1650294 --- ui.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui.py b/ui.py index 159bf98..c4d791d 100755 --- a/ui.py +++ b/ui.py @@ -26,6 +26,17 @@ import data, stars DARK_GRAY = '#222' + +ease = 0.0, 0.02, 0.08, 0.18, 0.32, 0.5, 0.68, 0.82, 0.92, 0.98, 1.0 + +def eased(from_, to): + interval = to - from_ + for e in ease: + yield round(from_ + interval * e) + +def eased_xy(from_x, from_y, to_x, to_y): + yield from zip(eased(from_x, to_x), eased(from_y, to_y)) + class App: ''' A canvas with scrolling support.