-
-
Save ff6347/93ab4fb1f36bec176feb to your computer and use it in GitHub Desktop.
Extension of the native Number class to map a number in one range to a number in another.
This file contains hidden or 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
| Number.prototype.map = function ( in_min , in_max , out_min , out_max ) { | |
| return ( this - 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