Two very useful functions / formulas to convert a percentage number to any range values or any number to a percent range.
function rangeToPercent(number, min, max){ return ((number - min) / (max - min)); } function percentToRange(percent, min, max){ return ((max - min) * percent + min); } |
Enjoy!