FacePoke / client /src /lib /mapRange.ts
jbilcke-hf's picture
jbilcke-hf HF staff
working on improvements
e123fec
raw
history blame
282 Bytes
// Function to map a value from one range to another
export const mapRange = (value: number, inMin: number, inMax: number, outMin: number, outMax: number): number => {
return Math.min(outMax, Math.max(outMin, ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin));
};