WIP: reorganizing and beunsize mapping
This commit is contained in:
parent
569a03245c
commit
cad9433266
6 changed files with 502 additions and 401 deletions
11
src/utilityFunctions.ts
Normal file
11
src/utilityFunctions.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
export function mapNumber(value: number, fromMin: number, fromMax: number, toMin: number, toMax: number): number {
|
||||
if (value <= fromMin) return toMin;
|
||||
if (value >= fromMax) return toMax;
|
||||
|
||||
const absFromMax = fromMax - fromMin;
|
||||
const absToMax = toMax - toMin;
|
||||
|
||||
const mapped = (value / absFromMax) * absToMax;
|
||||
return mapped + toMin;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue