Skip to content

Instantly share code, notes, and snippets.

@gntlechaos
Created April 23, 2020 15:34
Show Gist options
  • Save gntlechaos/0b7ad1774d0354529bec9f70014eee21 to your computer and use it in GitHub Desktop.
Save gntlechaos/0b7ad1774d0354529bec9f70014eee21 to your computer and use it in GitHub Desktop.
Re-maps a number from one range to another.
//This function acts like java Processing's map()
function mapMinMax(value,oldMin,oldMax,newMin, newMax) {
return (newMax-newMin)*(value-oldMin)/(oldMax-oldMin)+newMin;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment