Note:
HSB meens Hue, Saturation and Brightness.
RBG meens Red, Green and Blue

and here is a screenshot of what im trying to make
typedef struct stRGB
{
int r;
int g;
int b;
} RGB;
RGB HSV_to_RGB(double H, double S, double V)
{
//HSV values = From 0 to 255
//RGB results = From 0 to 255
//Code from: http://www.easyrgb.com/math.php?MATH=M21#text21
RGB out;
H /= 255.0;
S /= 255.0;
V /= 255.0;
if ( S == 0.0 )
{
out.r = out.g = out.b = V*255;
}
else
{
double var_h, var_i, var_1, var_2, var_3, var_r, var_g, var_b;
if(H == 1.0) H = 0.0;
var_h = H * 6;
var_i = (int)var_h;
var_1 = V * ( 1 - S );
var_2 = V * ( 1 - S * ( var_h - var_i ) );
var_3 = V * ( 1 - S * ( 1 - ( var_h - var_i ) ) );
if ( var_i == 0 ) { var_r = V ; var_g = var_3 ; var_b = var_1; }
else if ( var_i == 1 ) { var_r = var_2 ; var_g = V ; var_b = var_1; }
else if ( var_i == 2 ) { var_r = var_1 ; var_g = V ; var_b = var_3; }
else if ( var_i == 3 ) { var_r = var_1 ; var_g = var_2 ; var_b = V; }
else if ( var_i == 4 ) { var_r = var_3 ; var_g = var_1 ; var_b = V; }
else { var_r = V ; var_g = var_1 ; var_b = var_2; }
out.r = var_r * 255;
out.g = var_g * 255;
out.b = var_b * 255;
}
return out;
}
RGB color = HSV_to_RGB(209, 142, 111);
Users browsing this forum: No registered users and 1 guest