src/math/Color.cpp
/** Converts a linear space RGB color to an HSV color */
Converts a linear space RGB color to an HSV color
Converts a linear space RGB color to an HSV color
FLinearColor FLinearColor::LinearRGBToHSV() const
	{
		const float RGBMin = FMath::Min(r, g, b);
		const float RGBMax = FMath::Max(r, g, b);
		const float RGBRange = RGBMax - RGBMin;
		const float Hue = (RGBMax == RGBMin ? 0.0f :
			RGBMax == r ? FMath::Fmod((((g - b) / RGBRange) * 60.0f) + 360.0f, 360.0f) :
			RGBMax == g ? (((b - r) / RGBRange) * 60.0f) + 120.0f :
			RGBMax == b ? (((r - g) / RGBRange) * 60.0f) + 240.0f :
			0.0f);
		const float Saturation = (RGBMax == 0.0f ? 0.0f : RGBRange / RGBMax);
		const float Value = RGBMax;
		return FLinearColor(Hue, Saturation, Value, a);
	}
FLinearColor FLinearColor :: LinearRGBToHSV ( ) const { const float RGBMin = FMath :: Min ( r , g , b ) ; const float RGBMax = FMath :: Max ( r , g , b ) ; const float RGBRange = RGBMax - RGBMin ; const float Hue = ( RGBMax == RGBMin ? 0.0f : RGBMax == r ? FMath :: Fmod ( ( ( ( g - b ) / RGBRange ) * 60.0f ) + 360.0f , 360.0f ) : RGBMax == g ? ( ( ( b - r ) / RGBRange ) * 60.0f ) + 120.0f : RGBMax == b ? ( ( ( r - g ) / RGBRange ) * 60.0f ) + 240.0f : 0.0f ) ; const float Saturation = ( RGBMax == 0.0f ? 0.0f : RGBRange / RGBMax ) ; const float Value = RGBMax ; return FLinearColor ( Hue , Saturation , Value , a ) ; }
Converts a linear space RGB color to an HSV color
Converts a linear space RGB color to an HSV color
// In the new color, r = H, g = S, b = V, a = a