scale function
Scales a value from one range to another.
This function takes a value within a specified range and scales it to a new range.
param value
The value to be scaled.
param min
The minimum value of the original range.
param max
The maximum value of the original range.
param newMin
The minimum value of the new range.
param newMax
The maximum value of the new range.
returns The scaled value within the new range.
Implementation
double scale(num value, num min, num max, num newMin, num newMax) {
return (value - min) * (newMax - newMin) / (max - min) + newMin;
}