Skip to content

Instantly share code, notes, and snippets.

@bohnacker
Created September 3, 2017 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bohnacker/890893dfddb4b5521a031f532df64944 to your computer and use it in GitHub Desktop.
Save bohnacker/890893dfddb4b5521a031f532df64944 to your computer and use it in GitHub Desktop.
Map a value from one range to another
function map(val, low1, high1, low2, high2) {
return (val - low1) / (high1 - low1) * (high2 - low2) + low2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment