• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] RGB color picker help.

Pfap

Member
Does anybody know how an RGB editor works or does anybody know of any good resources? I'm specifically looking for an explanation on how the gradient for each channel is calculated.


See how the red and green channels are both at 255 and also that the red channel has a yellow to green gradient; while, the green one is yellow to red.
bandicam 2019-03-27 21-03-41-138.png

In the below image switching the values of the red and blue channels changes the color gradients.

bandicam 2019-03-27 21-03-47-334.png

I know rgb goes from 0-255 for all 3 channels. But, is there an algorithm for calculating what the individual channels gradient should be based off of the states of the others?
 

CloseRange

Member
yes it's pretty simple.
lets say the color channels are 0, 255, 255 currently( the second picture you have)
the gradent for red would look like:
left: 0, 255, 255
right: 255, 255, 255

green would look like
left: 0, 0, 255
right: 0, 255, 255

blue would look like
left: 0, 255, 0
right: 0, 255, 255

simply take the current color, and replace the respective color with 0 for left and 255 for right
so if you want to calculate the the red's gradient, take the current color and replace the red channel with 0 for left and 255 for right
 

Pfap

Member
yes it's pretty simple.
lets say the color channels are 0, 255, 255 currently( the second picture you have)
the gradent for red would look like:
left: 0, 255, 255
right: 255, 255, 255

green would look like
left: 0, 0, 255
right: 0, 255, 255

blue would look like
left: 0, 255, 0
right: 0, 255, 255

simply take the current color, and replace the respective color with 0 for left and 255 for right
so if you want to calculate the the red's gradient, take the current color and replace the red channel with 0 for left and 255 for right
Nice! Thanks for that response, really explained well.
 
Top