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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1593>
This commit is contained in:
Georges Basile Stavracas Neto 2020-12-31 14:18:42 -03:00 committed by Marge Bot
parent a29e002a41
commit 07c970d90c

View File

@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported findUrls, spawn, spawnCommandLine, spawnApp, trySpawnCommandLine, /* exported findUrls, spawn, spawnCommandLine, spawnApp, trySpawnCommandLine,
formatTime, formatTimeSpan, createTimeLabel, insertSorted, formatTime, formatTimeSpan, createTimeLabel, insertSorted,
ensureActorVisibleInScrollView, wiggle */ ensureActorVisibleInScrollView, wiggle, lerp */
const { Clutter, Gio, GLib, Shell, St, GnomeDesktop } = imports.gi; const { Clutter, Gio, GLib, Shell, St, GnomeDesktop } = imports.gi;
const Gettext = imports.gettext; const Gettext = imports.gettext;
@ -435,3 +435,7 @@ function wiggle(actor, params) {
}, },
}); });
} }
function lerp(start, end, progress) {
return start + progress * (end - start);
}