[gnome-shell/gbsneto/40-stuff: 22/68] environment: Add interpolation function




commit d5429c37737b667ad434a69b7a4f8709c77104fa
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Dec 31 14:18:42 2020 -0300

    environment: Add interpolation function
    
    We're going to interpolate a lot in the future, to it's
    worthy sharing this simple but effective interpolation
    function.
    
    Add Math.interpolate().

 js/ui/environment.js | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/js/ui/environment.js b/js/ui/environment.js
index fa3d490a58..5854847f6d 100644
--- a/js/ui/environment.js
+++ b/js/ui/environment.js
@@ -382,6 +382,10 @@ function init() {
     Math.clamp = function (x, lower, upper) {
         return Math.min(Math.max(x, lower), upper);
     };
+
+    Math.interpolate = function (start, end, progress) {
+        return start + progress * (end - start);
+    };
 }
 
 // adjustAnimationTime:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]