premier test implémentation d'un composant calculant la zone

This commit is contained in:
2024-04-16 21:35:56 +00:00
parent 0ad4032a9b
commit 40241311ee
4 changed files with 122 additions and 24 deletions

13
traque-back/util.js Normal file
View File

@@ -0,0 +1,13 @@
/**
* Scale a value that is known to be in a range to a new range
* for instance map(50,0,100,1000,2000) will return 1500 as 50 is halfway between 0 and 100 and 1500 is halfway through 1000 and 2000
* @param {Number} value value to map
* @param {Number} oldMin minimum value of the number
* @param {Number} oldMax maximum value of the number
* @param {Number} newMin minimum value of the output
* @param {Number} newMax maximum value of the output
* @returns
*/
export function map(value, oldMin, oldMax, newMin, newMax) {
return ((value - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin;
}