Skip to content

Instantly share code, notes, and snippets.

@pdaug
Created June 26, 2024 11:54
Show Gist options
  • Save pdaug/39c24964327de9f65306df0278332dc9 to your computer and use it in GitHub Desktop.
Save pdaug/39c24964327de9f65306df0278332dc9 to your computer and use it in GitHub Desktop.
// 64 - 1024
// x
// 256 - 2048
const remap = function (x: number, inputMinimum: number, inputMaximum: number, outputMinimum: number, outputMaximum: number) {
const pointA = (x - inputMinimum) * (outputMaximum - outputMinimum);
const pointB = (inputMaximum - inputMinimum) + outputMinimum;
const result = pointA / pointB;
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment