summaryrefslogtreecommitdiff
path: root/web/share/js/tools.js
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-02-21 04:18:15 +0300
committerMaxim Devaev <[email protected]>2022-02-21 04:18:15 +0300
commit96191a1b0809a62e5b14316190c3de46b05d9ec2 (patch)
tree6a1e6238ecb6fad8ce78f644af99c73533fbbe30 /web/share/js/tools.js
parent67839a52a22a4e470109d3d0c8acf4798843bcf6 (diff)
ocr
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() {