I want to have a button with numbers in the range 0 ... 255. I would like the button color to be white when it is zero and blue (RGB = (0,0,255)) when it is 255. How can I do this? At first I tried to make it RGB = (0,0,0) at the beginning, but it will only make it black.
How can i do this?
A simple linear interpolation between white (255,255,255) and blue (0,0255) will be performed.
A blue to white gradient starts with:
0,0,255
with R and G values growing at the same speed: 1,1,255 ... 10,10,255 ... 255255255
2 -, -.
whitebluegradient(n): if n < 0: n = 0 if n > 255: n = 255 r = 255-n g = r b = 255 return rgb (r,g,b)
(255,255,255 = ) n = 0 (0,0255 = ) n = 255.
n = 0
n = 255
white in RGB 255 255,255
So just take off the red and green
Set R and G to (255 - button value).
255,255,255 = white 0,0,255 = blue