diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-07-21 14:33:49 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-07-21 14:34:45 +0400 |
commit | 25fab54e092fb453e418ed1c895c739f4c5d03c8 (patch) | |
tree | 2b92c83e1121cc6ce1458899956980acadc3350f /source/blender/blenlib/intern/math_color.c | |
parent | 256706ce7e88dfa4ec7f5ff215a03aea2aa5e71a (diff) |
Fix errors in hsv calculation from recent optimization patch.
Code was different from original here, result was apparent in color
picker wedge position.
Diffstat (limited to 'source/blender/blenlib/intern/math_color.c')
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 3dd8aab18d7..eb9e36bcbf4 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -212,17 +212,20 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv) { float k = 0.0f; float chroma; + float min_gb; if (g < b) { SWAP(float, g, b); k = -1.0f; } + min_gb = b; if (r < g) { SWAP(float, r, g); - k = -2.0f * 6e-1f - k; + k = -2.0f / 6.0f - k; + min_gb = min_ff(g, b); } - chroma = r - min_ff(g, b); + chroma = r - min_gb; *lh = fabsf(k + (g - b) / (6.0f * chroma + 1e-20f)); *ls = chroma / (r + 1e-20f); |