Skip to content

Instantly share code, notes, and snippets.

@ryanramage
Created September 29, 2017 14:49
Show Gist options
  • Save ryanramage/d89e856e37eb6ef4be35aa3ef35f1166 to your computer and use it in GitHub Desktop.
Save ryanramage/d89e856e37eb6ef4be35aa3ef35f1166 to your computer and use it in GitHub Desktop.
Make a scaling function that maps from one range to another
const scale = (inMin, inMax, outMin, outMax) => (input) => outMin + ((outMax - outMin) * ((input - inMin) / (inMax - inMin)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment