Artificial intelligent assistant

Divide proportionnally to lowest possible value? I'm trying to write an algorithm to convert RGB to RGBW, and a problem I'm running in is that my white value should, depending on the luminance, go from: 255-------------------->0 and it's currently doing 255-------------------->120 How would I divide by 120, but proportionally to how close I am to 120, in the simplest way possible? P.S. I didn't learn maths in English, so sorry if I haven't used the correct terms :/

So you have $255\geq x\geq 120$. Subtract $120$ and you'll get: $$135\geq x-120\geq 0$$ multiply with $\frac{255}{135}$ to obtain: $$255\geq\frac{255}{135}(x-120)\geq 0$$ Now it's in the range that you want.

So to get the number between $255$ and $0$, subtract $120$ and then multiply by $\dfrac{255}{135}$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9e66f3cd4138ec54126b898b571ee869