|
![](/i/fill.gif) |
> > Sounds very, very useful (though I've *almost* learned to do this in
> > my head :) )
>
> Really? Well, HLS to RGB is easy, but the RGB back ot HLS is a real
bizatch
> to get the algorithm for. I basically just looked for patterns in the RGB
> values for different HLS inputs.
Sure ... why shouldn't he ... of course, I think the rgb2HLS-part is the
more easy way...
HLS2RGB is quite "harder" if you don't know the direction of the rainbow ...
> The lightness (chroma) is easy, (max(RGB)+min(RGB))/2
> The saturation (value) is (min(RGB)-max(RGB))/(2|L-0.5|-1)
[...snip...]
> use the following lookup chart:
> M=max, m=min,
> RGB n
> -----
> M-m 0
> -Mm 1
> mM- 2
> m-M 3
> -mM 4
> Mm- 5
> Then the hue is
> n+mod(n,2)-2(mod(n,2)-0.5)*(med(RGB)-min(RGB))/(max(RGB)-min(RGB))
... ohhh .. all those formulas ... Have you tried to determine the
RGB-values of a color from your feeling ???
Of course, you wont get the desired color on your first try, but If I see a
RGB-vector I think I can imagine the real Color, vice versa ...
For this I find it harder to recognise a color from a HLS-vector...
But I find such macro very useful to create a nice colorslide by code ...
this would be much more easier ..
I'll try it out ... If it runs: "Quite well done !" ... ;-)
--
,', Jan Walzer \V/ http://wa.lzer.net ,',
',',' student of >|< mailto:jan### [at] lzer net ',','
' ComputerScience /A\ +49-177-7403863 '
Post a reply to this message
|
![](/i/fill.gif) |