Last active
March 28, 2020 06:56
-
-
Save victornpb/51b0c17241ea483dee2c3a20d0f710eb to your computer and use it in GitHub Desktop.
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
/** | |
* Create a function that maps a value to a range | |
* @param {Number} inMin Input range minimun value | |
* @param {Number} inMax Input range maximun value | |
* @param {Number} outMin Output range minimun value | |
* @param {Number} outMax Output range maximun value | |
* @return {function} A function that converts a value | |
* | |
* @author Victor N. wwww.victorborges.com | |
* @see https://gist.github.com/victornpb/51b0c17241ea483dee2c3a20d0f710eb/ | |
*/ | |
function createRemap(inMin, inMax, outMin, outMax) { | |
return function remaper(x) { | |
return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment