What is the rgb formula for a gradient going from white to blue?

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?

+5
source share
5 answers

A simple linear interpolation between white (255,255,255) and blue (0,0255) will be performed.

+9
source

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 -, -.

+7
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.

+2
source

white in RGB 255 255,255

So just take off the red and green

+1
source

Set R and G to (255 - button value).

255,255,255 = white 0,0,255 = blue

+1
source

All Articles