Created
September 2, 2020 15:11
-
-
Save peeke/5d9f19367ead0f0823db8697c44e2de4 to your computer and use it in GitHub Desktop.
Convert number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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