I am trying to paint a WPF control\'s background based on a palette where each color has been assigned with values (e.g. Red = 0, DarkGreen = 10, Green = 20,LightGreen =30)
Where did you come up with the Values 10/20/30 for your DarkGreen/Green/Lightgreen colors.
You'll need some sort of correlation table between your assigned palette values & the real numeric representations of the colors... e.g.
Color Pal-Code RGB HSL
Red 0 255,0,0 0,240,120
Dark Green 10 0,128,0 80,240,60
Green 20 0,255,0 80,240,120
Light Green 30 128,255,128 80,240,180
From that correlation table, you could take any user "palette code", find the closed matching pair of palette codes from the table above and do a best-match range find on it. e.g. if some entered 25
(let's use HSL for convenience) then the formula would be...
Green 20 0,255,0 80,240,120
Light Green 30 128,255,128 80,240,180
25 is halfway between both codes so
Palette Code Hue Sat Luminence
20 80 240 120
30 80 240 180
-------------------------------------------------
25 80 240 150
If they had selected 6
, you'd need to find .6 of the range of colors between each value.
Red 0 255,0,0 0,240,120
Dark Green 10 0,128,0 80,240,60
Palette Code Hue Sat Luminence
0 0 240 120
10 80 240 60
-------------------------------------------------
6 48 240 84
0->80 = +80 * 60% = +48 So 0+48 = 48
240->240 = 0 * 60% = 0 So 240+0 = 240
120->60 = -60 * 60% = -36 So 120-36 = 84