Nilai peta JS dalam kisaran
(val, in_min, in_max, out_min, out_max) => (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
Thoughtful Tuatara
(val, in_min, in_max, out_min, out_max) => (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
function mapValues(value, oldRange, newRange) {
var newValue = (value - oldRange[0]) * (newRange[1] - newRange[0]) / (oldRange[1] - oldRange[0]) + newRange[0];
return Math.min(Math.max(newValue, newRange[0]) , newRange[1]);
}