Skip to content

Instantly share code, notes, and snippets.

@remyhunt
Last active May 12, 2020 16:25
Show Gist options
  • Save remyhunt/7c4266a0503eb44860d7b52a80b3b0b2 to your computer and use it in GitHub Desktop.
Save remyhunt/7c4266a0503eb44860d7b52a80b3b0b2 to your computer and use it in GitHub Desktop.
/* a simple but elegant map function that I pretty much find myself needing. */
function map(x, in_min, in_max, out_min, out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment