Skip to content

Instantly share code, notes, and snippets.

@peeke
Created September 2, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peeke/5d9f19367ead0f0823db8697c44e2de4 to your computer and use it in GitHub Desktop.
Save peeke/5d9f19367ead0f0823db8697c44e2de4 to your computer and use it in GitHub Desktop.
Convert number
function lerp(a, b, weight) {
return a + weight * (b - a)
}
function mapNumber({ from, to, input }) {
const normalized = (input - from[0]) / from[1]
return lerp(...to, normalized)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment