Skip to content

Instantly share code, notes, and snippets.

@hedcler
Created July 27, 2012 22:31
Show Gist options
  • Save hedcler/3190769 to your computer and use it in GitHub Desktop.
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
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