Creating colors tones derivated from a base color

Cableguy

Expert
Licensed User
Longtime User
I need help!

I need to derive two colors from a base color, defined in runtime...
Example:
The user sets the base color to be Blue, I want to compute a two-tone lighter blue and a two-tone darker blue...

Since colors are treated as integers, I've been playing with adding colors, but not having satisfactory results..
 

lagore

Active Member
Licensed User
Longtime User
If you you take a pure blue in RGB it will have a value of 0,0,255 half way between pure blue and white the value is 127,127,255 you could take this as your mid colour and then use 64,64,255 as the light and 192,192,255 as the dark. So for the three pure colours (red,green,blue) the base colour's value stays at 255 and the other two vary at the same rate from 0 to 255. If you want a colour between red and blue (pinkish) this has an RGB value of 255,0,255 at full strength, 255,125,255 at the mid point and so on. If you have a look at the colour picker site you can see the relationship of the RGB colours.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I have been googling and did notice that....

In fact, using RGB(HEX) seems to be more easely linear than with RGB(DEC) ...

I played around with the gray color as a base, rgb(128,128.128)
And trying to achieve light gray rgb(211,211,211) by adding two colors...
The base one plus rgb(83,83.83)... it works with the gray... but Not with other base colors as Blue, Green or Red....

I have established that a two-tone difference is achieved by an offset of 102 in the G Chanel, at least in the base colors (web colors)
Still, I can manage to get it working
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
Look for HSL (Hue Saturation Lightness) color model and the math behind it. It will be much easier and nicer looking than doing the colors based on RGB.
 
Upvote 0
Top