The whole reason that RGB requires 3 numbers is because it is essentially a 3D space. You would be trying to squeeze 3 continuous number lines into 1! You'd have to choose a scale, have a play around like below to see which colour blend through you like... (code written in VBA but easily portable)
For i = 1 To 255
' Scale with no red, increase and decrease blue and green respectively
Range("a" & i).Interior.Color = RGB(0, i, 255 - i)
' Use a MOD function to keep the values between 0 and 255
' note this can cause some abrupt changes in your scale
Range("b" & i).Interior.Color = RGB(128 + i Mod 255, i, 255 - i)
' You can increase and decrease different RGB values for desired result
Range("c" & i).Interior.Color = RGB((255 - i) Mod 255, (0 + i) Mod 255, i)
Next i
Output (columns made into rows for better viewing here):
So to go from RGB to a 1D scale (like those above) you would just have i
as your single variable, you could store a lookup if you wanted or create a function which does as each line above does, creating the colour from a single value of i
.
Now going back from this 1D scale to a 3D scale is technically impossible. You have lost the extra information you need. However, if you knew your mapping function to create the scale, you can simply get each RGB value by its respective input.
Hope this helps.