Skip to content

Instantly share code, notes, and snippets.

@stekhn
Created November 17, 2015 09:21
Show Gist options
  • Save stekhn/f5150f8b7e5b3d6056e0 to your computer and use it in GitHub Desktop.
Save stekhn/f5150f8b7e5b3d6056e0 to your computer and use it in GitHub Desktop.
Map value to range
function mapValue(value, fromMin, toMin, fromMax, toMax) {
return (value - fromMin) / (toMin - fromMin) * (toMax - fromMax) + fromMax;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment