From 07c970d90c768003f35a0d3f1fb9913d5a2b045d Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 31 Dec 2020 14:18:42 -0300 Subject: [PATCH] util: Add lerp function We're going to lerp a lot in the future, to it's worthy sharing this simple but effective interpolation function. Add Util.lerp(). Part-of: --- js/misc/util.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/misc/util.js b/js/misc/util.js index 314d7660f..2da489bbe 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -1,7 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported findUrls, spawn, spawnCommandLine, spawnApp, trySpawnCommandLine, formatTime, formatTimeSpan, createTimeLabel, insertSorted, - ensureActorVisibleInScrollView, wiggle */ + ensureActorVisibleInScrollView, wiggle, lerp */ const { Clutter, Gio, GLib, Shell, St, GnomeDesktop } = imports.gi; const Gettext = imports.gettext; @@ -435,3 +435,7 @@ function wiggle(actor, params) { }, }); } + +function lerp(start, end, progress) { + return start + progress * (end - start); +}