fix color when hue is set to 1

This commit is contained in:
Nuno Donato 2016-02-18 09:43:04 +00:00
parent 16b0cf8bcb
commit b51c720c80

View file

@ -117,19 +117,21 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
} }
p_h *=6.0; p_h *=6.0;
p_h = Math::fmod(p_h,6);
i = Math::floor( p_h ); i = Math::floor( p_h );
f = p_h - i; f = p_h - i;
p = p_v * ( 1 - p_s ); p = p_v * ( 1 - p_s );
q = p_v * ( 1 - p_s * f ); q = p_v * ( 1 - p_s * f );
t = p_v * ( 1 - p_s * ( 1 - f ) ); t = p_v * ( 1 - p_s * ( 1 - f ) );
switch( i ) { switch( i ) {
case 0: case 0: // Red is the dominant color
r = p_v; r = p_v;
g = t; g = t;
b = p; b = p;
break; break;
case 1: case 1: // Green is the dominant color
r = q; r = q;
g = p_v; g = p_v;
b = p; b = p;
@ -139,7 +141,7 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
g = p_v; g = p_v;
b = t; b = t;
break; break;
case 3: case 3: // Blue is the dominant color
r = p; r = p;
g = q; g = q;
b = p_v; b = p_v;
@ -149,7 +151,7 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
g = p; g = p;
b = p_v; b = p_v;
break; break;
default: // cap_se 5: default: // (5) Red is the dominant color
r = p_v; r = p_v;
g = p; g = p;
b = q; b = q;