Skip to content

Instantly share code, notes, and snippets.

@bohnacker

bohnacker/map.js

Created Sep 3, 2017
Embed
What would you like to do?
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