Skip to content

Instantly share code, notes, and snippets.

@jkosoy
Created May 23, 2012 18:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkosoy/2776908 to your computer and use it in GitHub Desktop.
Save jkosoy/2776908 to your computer and use it in GitHub Desktop.
Port of Processing's map() function to JS. See: http://processing.org/reference/map_.html
function map(val, a1, a2, b1, b2) { return ((val - a1) * (b2 -b1)/(a2 - a1)) + b1; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment