Closed natj closed 10 years ago
I dunno, for me the wrap-around seemed more intuitive but I can change it to your method too, if you think it is more suitable.
On a more general scale, I think we should pick one method and stick to that with every function that has a hue defined using the angle...
I'm not an expert in color spaces, but it's really a question of whether if the boundaries wrap around in h
.
Hue is defined differently in various color spaces. However, in terms of CIELUV, hue is just atan(v/u). As a result, h=n and h=n+360 are the same [u,v] coordinate. From a color point of view, wrapping should be the preferred treatment.
In which case, it looks like the entire while !(0 <= h <= 360) ... end
block can be replaced by h = mod(h, 360)
. The code generated by the latter is more efficient.
Ugh, you are completely right @jiahao! I'll change that part to use mod
in a sec...
If you need, I can squeeze these into a single commit. However, I think these should also merge without any conflict separately.
I squashed everything into a one big commit for easier merge.
Looks good to me.
This is a relatively simple fix for #17 by checking if we are on the edge of the RGB cube and returning the related color without any further calculations.
I also added a description of
colormap
and related functions to README. Feel free to correct me in case of possible typos, as I am not a native english speaker.