Last active
March 9, 2018 21:54
-
-
Save SankaitLaroiya/fca8814c4f3b822c6aa6416bb2e83ebb to your computer and use it in GitHub Desktop.
(JS) Scale Numbers Between a Given Range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code snippet taken from: | |
// https://stackoverflow.com/a/31687097 | |
function scaleBetween(unscaledNum, minAllowed, maxAllowed, min, max) { | |
return (maxAllowed - minAllowed) * (unscaledNum - min) / (max - min) + minAllowed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment