Skip to content

Instantly share code, notes, and snippets.

@mahdisoultana
Forked from AugustMiller/map.js
Created February 18, 2021 13:27
Show Gist options
  • Save mahdisoultana/4bb1d44c48d95c485033c204e8fc4d59 to your computer and use it in GitHub Desktop.
Save mahdisoultana/4bb1d44c48d95c485033c204e8fc4d59 to your computer and use it in GitHub Desktop.
Map a number in one range to a number in another.
const mapNumber = (number, in_min, in_max, out_min, out_max) => {
return (number - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
};
@mahdisoultana
Copy link
Author

Very Handy Function Mapping rang of number to another Range Number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment