This may be a very stupid question but just wanted to clarify my issue. Having seen a few different algorithms for conversion between RGB & HSL, I have seen var_1 and var_2. I was just wondering what these variables actually are? I knew they'd show up as errors just wanted to fully understand why and where I need to make changes for the conversion.
void HSLToRGB( int H, int S, int L, int& R, int& G, int& B )
{
H = 240;
S = 47;
L = 58;
if (S == 0)
{
R = L * 255
G = L * 255
B = L * 255
}
else
{
if (L < 0.5) { var_2 = L * (1 + S); }
else
{
var_2 = (L + S) - (S * L);
var_1 = 2 * L - var_2;
}
var_1 = 2 * L- var_2;
R = 255 * Hue_2_RGB(var_1, var_2, H + (1 / 3));
G = 255 * Hue_2_RGB(var_1, var_2, H);
B = 255 * Hue_2_RGB(var_1, var_2, H - (1 / 3));
}
static float Hue_2_RGB(float v1, float v2, float vH)
{
if (vH < 0) { vH += 1; }
if (vH > 1) { vH -= 1; }
if ((6 * vH) < 1) { return (v1 + (v2 - v1) * 6 * vH); }
if ((2 * vH) < 1) {return (v2); }
if ((3 * vH) < 2)
{
return (v1 + (v2 - v1) * ((2 / 3) - vH) * 6);
return (v1);
}
}
Sorry if this is a dumb question just wanted to 100% understand in laymans term.
Thank you. I also have not included the code for RGB to HSL conversion.