This is really simple math.
First remove the need for a negative number:
For the range -60 ↔ + 20: x + 60
Now we have a range of 0 ↔ 80, just scale it to 255: (x / 80) * 255
Put this all in the formula, and this is what you should get: y = ((x + 60) / 80) * 255
So basically:
y = ((x + negativeValue) / MaxValue) * MaxScale
I hope you understand now!
source share