Created
July 27, 2012 22:31
-
-
Save hedcler/3190769 to your computer and use it in GitHub Desktop.
Re-maps a number from one range to another. In the example above, the number '25' is converted from a value in the range 0..100 into a value that ranges from the left edge (0) to the right edge (width) of the screen. Numbers outside the range are not cla
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
var map = function(value, istart, istop, ostart, ostop) { | |
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart)) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment