Skip to content

Instantly share code, notes, and snippets.

@AugustMiller
Last active October 2, 2021 14:14
Show Gist options
  • Save AugustMiller/85b54d49493bb71ba81e to your computer and use it in GitHub Desktop.
Save AugustMiller/85b54d49493bb71ba81e to your computer and use it in GitHub Desktop.
Map a number in one range to a number in another.
function mapNumber (number, inMin, inMax, outMin, outMax) {
return (number - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
}
@ionurboz
Copy link

I like it. Ty

@mahdisoultana
Copy link

thank you very much it's really handy function

@mo-renike
Copy link

Thanks for this. Came in handy

@vietnguyen1404
Copy link

i don't understand , plz explain for me , thanks you

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