Source.cpp
// function that converts rgb color to hsl color
// (important because rgb color might vary due to brightness)
// (thats why we use hsl (hue, saturation, luminescence) color with certain tolerance for more accurate bot)

function that converts rgb color to hsl color
(important because rgb color might vary due to brightness)
(thats why we use hsl (hue, saturation, luminescence) color with certain tolerance for more accurate bot)
function that converts rgb color to hsl color ( important because rgb color might vary due to brightness ) ( thats why we use hsl ( hue saturation luminescence ) color with certain tolerance for more accurate bot )
stHSL RgbToHsl(stRGB rgb)
{
	stHSL hsl;
	float r = rgb.r / 255.0f;
	float g = rgb.g / 255.0f;
	float b = rgb.b / 255.0f;
	float h, s, v;
	float max = tmax(r, g, b);
	float min = tmin(r, g, b);
	v = max;
	if (max == 0.0f)
	{
		s = 0;
		h = 0;
	}
	else if (max - min == 0.0f)
	{
		s = 0;
		h = 0;
	}
	else
	{
		s = (max - min) / max;
		if (max == r)
		{
			h = 60 * ((g - b) / (max - min)) + 0;
		}
		else if (max == g)
		{
			h = 60 * ((b - r) / (max - min)) + 120;
		}
		else
		{
			h = 60 * ((r - g) / (max - min)) + 240;
		}
	}
	if (h < 0)
	{
		h += 360.0f;
	}
	hsl.h = h;
	hsl.s = s * 100;
	hsl.l = v * 100;
	return hsl;
}
stHSL RgbToHsl ( stRGB rgb ) { stHSL hsl ; float r = rgb . r / 255.0f ; float g = rgb . g / 255.0f ; float b = rgb . b / 255.0f ; float h , s , v ; float max = tmax ( r , g , b ) ; float min = tmin ( r , g , b ) ; v = max ; if ( max == 0.0f ) { s = 0 ; h = 0 ; } else if ( max - min == 0.0f ) { s = 0 ; h = 0 ; } else { s = ( max - min ) / max ; if ( max == r ) { h = 60 * ( ( g - b ) / ( max - min ) ) + 0 ; } else if ( max == g ) { h = 60 * ( ( b - r ) / ( max - min ) ) + 120 ; } else { h = 60 * ( ( r - g ) / ( max - min ) ) + 240 ; } } if ( h < 0 ) { h += 360.0f ; } hsl . h = h ; hsl . s = s * 100 ; hsl . l = v * 100 ; return hsl ; }
function that converts rgb color to hsl color
(important because rgb color might vary due to brightness)
(thats why we use hsl (hue, saturation, luminescence) color with certain tolerance for more accurate bot)
function that converts rgb color to hsl color ( important because rgb color might vary due to brightness ) ( thats why we use hsl ( hue saturation luminescence ) color with certain tolerance for more accurate bot )