summaryrefslogtreecommitdiff
path: root/web/share/js/tools.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/share/js/tools.js')
-rw-r--r--web/share/js/tools.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js
index a412cc0d..006453bd 100644
--- a/web/share/js/tools.js
+++ b/web/share/js/tools.js
@@ -83,6 +83,16 @@ export var tools = new function() {
return `${hours}:${mins}:${secs}.${millis}`;
};
+ self.remap = function(x, a1, b1, a2, b2) {
+ let remapped = Math.round((x - a1) / b1 * (b2 - a2) + a2);
+ if (remapped < a2) {
+ return a2;
+ } else if (remapped > b2) {
+ return b2;
+ }
+ return remapped;
+ };
+
/************************************************************************/
self.el = new function() {