45 hsv(): h(0.0),
s(0.0), v(0.0) {}
54 static void rgb2hsv (
float r,
float g,
float b,
float &h,
float &s,
float &v)
60 double var_Min = std::min(std::min(var_R,var_G),var_B);
61 double var_Max = std::max(std::max(var_R,var_G),var_B);
62 double del_Max = var_Max - var_Min;
64 if (fabs(del_Max)<0.00001) {
71 if ( var_R == var_Max ) h = (var_G - var_B)/del_Max;
72 else if ( var_G == var_Max ) h = 2.0 + (var_B - var_R)/del_Max;
73 else if ( var_B == var_Max ) h = 4.0 + (var_R - var_G)/del_Max;
81 static void hsv2rgb (
float h,
float s,
float v,
float &
r,
float &
g,
float &
b)
87 float p = v * ( 1 - s );
88 float q = v * ( 1 - s * f );
89 float t = v * ( 1 - s * ( 1 - f ) );
91 if (i==0) {r = v; g = t; b = p;}
92 else if (i==1) {r = q; g = v; b = p;}
93 else if (i==2) {r = p; g = v; b = t;}
94 else if (i==3) {r = p; g = q; b = v;}
95 else if (i==4) {r = t; g = p; b = v;}
96 else if (i==5) {r = v; g = p; b = q;}
101 return a * (1 - t) + b * t;
122 cr.
h = linearInterpolate(ca.
h, cb.
h, t);
123 cr.
s = linearInterpolate(ca.
s, cb.
s, t);
124 cr.
v = linearInterpolate(ca.
v, cb.
v, t);
static color::rgba interpolateColor(color::rgba start, color::rgba goal, float t)
static void rgb2hsv(float r, float g, float b, float &h, float &s, float &v)
static float linearInterpolate(float a, float b, float t)
static void hsv2rgb(float h, float s, float v, float &r, float &g, float &b)