Created
February 1, 2019 23:05
-
-
Save pyramation/712b94714e19b5cac8cade7f4434088f to your computer and use it in GitHub Desktop.
fit function
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
function fit(num, oldmin, oldmax, newmin, newmax) { | |
const ratio = (num - oldmin) / (oldmax - oldmin); | |
return newmin + ratio * (newmax - newmin); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment