Fix Color doc comments
This commit is contained in:
@@ -137,6 +137,26 @@ String Color::ToHexString() const
|
||||
return String(result, 6);
|
||||
}
|
||||
|
||||
bool Color::IsTransparent() const
|
||||
{
|
||||
return Math::IsZero(R + G + B + A);
|
||||
}
|
||||
|
||||
bool Color::HasOpacity() const
|
||||
{
|
||||
return !Math::IsOne(A);
|
||||
}
|
||||
|
||||
bool Color::NearEqual(const Color& a, const Color& b)
|
||||
{
|
||||
return Math::NearEqual(a.R, b.R) && Math::NearEqual(a.G, b.G) && Math::NearEqual(a.B, b.B) && Math::NearEqual(a.A, b.A);
|
||||
}
|
||||
|
||||
bool Color::NearEqual(const Color& a, const Color& b, float epsilon)
|
||||
{
|
||||
return Math::NearEqual(a.R, b.R, epsilon) && Math::NearEqual(a.G, b.G, epsilon) && Math::NearEqual(a.B, b.B, epsilon) && Math::NearEqual(a.A, b.A, epsilon);
|
||||
}
|
||||
|
||||
Vector3 Color::ToVector3() const
|
||||
{
|
||||
return Vector3(R, G, B);
|
||||
@@ -158,6 +178,21 @@ Vector3 Color::ToHSV() const
|
||||
return Vector3(hue, saturation, value);
|
||||
}
|
||||
|
||||
void Color::Lerp(const Color& start, const Color& end, float amount, Color& result)
|
||||
{
|
||||
result.R = Math::Lerp(start.R, end.R, amount);
|
||||
result.G = Math::Lerp(start.G, end.G, amount);
|
||||
result.B = Math::Lerp(start.B, end.B, amount);
|
||||
result.A = Math::Lerp(start.A, end.A, amount);
|
||||
}
|
||||
|
||||
Color Color::Lerp(const Color& start, const Color& end, float amount)
|
||||
{
|
||||
Color result;
|
||||
Lerp(start, end, amount, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Color Color::LinearToSrgb(const Color& linear)
|
||||
{
|
||||
#define LINEAR_TO_SRGB(value) value < 0.00313067f ? value * 12.92f : Math::Pow(value, (1.0f / 2.4f)) * 1.055f - 0.055f
|
||||
|
||||
@@ -716,7 +716,7 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the color to HSV color space (returned as vector).
|
||||
/// Gets Hue[0-360], Saturation[0-1] and Value[0-1] from RGB color.
|
||||
/// </summary>
|
||||
/// <returns>The HSV color.</returns>
|
||||
public Vector3 ToHSV()
|
||||
@@ -743,51 +743,6 @@ namespace FlaxEngine
|
||||
return new Vector3(hue, saturation, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert color from the RGB color space to HSV color space.
|
||||
/// </summary>
|
||||
/// <param name="rgbColor">Color of the RGB.</param>
|
||||
/// <param name="h">The output Hue.</param>
|
||||
/// <param name="s">The output Saturation.</param>
|
||||
/// <param name="v">The output Value.</param>
|
||||
public static void RGBToHSV(Color rgbColor, out float h, out float s, out float v)
|
||||
{
|
||||
if ((rgbColor.B > rgbColor.G) && (rgbColor.B > rgbColor.R))
|
||||
RGBToHSVHelper(4f, rgbColor.B, rgbColor.R, rgbColor.G, out h, out s, out v);
|
||||
else if (rgbColor.G <= rgbColor.R)
|
||||
RGBToHSVHelper(0f, rgbColor.R, rgbColor.G, rgbColor.B, out h, out s, out v);
|
||||
else
|
||||
RGBToHSVHelper(2f, rgbColor.G, rgbColor.B, rgbColor.R, out h, out s, out v);
|
||||
}
|
||||
|
||||
private static void RGBToHSVHelper(float offset, float dominantcolor, float colorone, float colortwo, out float h, out float s, out float v)
|
||||
{
|
||||
v = dominantcolor;
|
||||
if (Mathf.IsZero(v))
|
||||
{
|
||||
s = 0f;
|
||||
h = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
var single = colorone <= colortwo ? colorone : colortwo;
|
||||
float vv = v - single;
|
||||
if (Mathf.IsZero(vv))
|
||||
{
|
||||
s = 0f;
|
||||
h = offset + (colorone - colortwo);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = vv / v;
|
||||
h = offset + (colorone - colortwo) / vv;
|
||||
}
|
||||
h = h / 6f;
|
||||
if (h < 0f)
|
||||
h = h + 1f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the contrast of a color.
|
||||
/// </summary>
|
||||
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
/// Creates RGB color from Hue[0-360], Saturation[0-1] and Value[0-1] packed to XYZ vector.
|
||||
/// </summary>
|
||||
/// <param name="hsv">The HSV color.</param>
|
||||
/// <param name="alpha">The alpha value. Default is 1.</param>
|
||||
/// <param name="alpha">The alpha value. Default is 1.</param>
|
||||
/// <returns>The RGB color.</returns>
|
||||
static Color FromHSV(const Vector3& hsv, float alpha = 1.0f);
|
||||
|
||||
@@ -264,28 +264,15 @@ public:
|
||||
}
|
||||
|
||||
// Returns true if color is fully transparent (all components are equal zero).
|
||||
bool IsTransparent() const
|
||||
{
|
||||
return Math::IsZero(R + G + B + A);
|
||||
}
|
||||
bool IsTransparent() const;
|
||||
|
||||
// Returns true if color has opacity channel in use (different from 1).
|
||||
bool HasOpacity() const
|
||||
{
|
||||
return !Math::IsOne(A);
|
||||
}
|
||||
bool HasOpacity() const;
|
||||
|
||||
public:
|
||||
|
||||
static bool NearEqual(const Color& a, const Color& b)
|
||||
{
|
||||
return Math::NearEqual(a.R, b.R) && Math::NearEqual(a.G, b.G) & Math::NearEqual(a.B, b.B) && Math::NearEqual(a.A, b.A);
|
||||
}
|
||||
|
||||
static bool NearEqual(const Color& a, const Color& b, float epsilon)
|
||||
{
|
||||
return Math::NearEqual(a.R, b.R, epsilon) && Math::NearEqual(a.G, b.G, epsilon) & Math::NearEqual(a.B, b.B, epsilon) && Math::NearEqual(a.A, b.A, epsilon);
|
||||
}
|
||||
static bool NearEqual(const Color& a, const Color& b);
|
||||
static bool NearEqual(const Color& a, const Color& b, float epsilon);
|
||||
|
||||
public:
|
||||
|
||||
@@ -296,7 +283,7 @@ public:
|
||||
Vector4 ToVector4() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets Hue[0-1], Saturation[0-1] and Value[0-360] from RGB color.
|
||||
/// Gets Hue[0-360], Saturation[0-1] and Value[0-1] from RGB color.
|
||||
/// </summary>
|
||||
/// <returns>HSV color</returns>
|
||||
Vector3 ToHSV() const;
|
||||
@@ -308,13 +295,7 @@ public:
|
||||
/// <param name="end">The end color.</param>
|
||||
/// <param name="amount">The value between 0 and 1 indicating the weight of interpolation.</param>
|
||||
/// <param name="result">When the method completes, contains the linear interpolation of the two colors.</param>
|
||||
static void Lerp(const Color& start, const Color& end, float amount, Color& result)
|
||||
{
|
||||
result.R = Math::Lerp(start.R, end.R, amount);
|
||||
result.G = Math::Lerp(start.G, end.G, amount);
|
||||
result.B = Math::Lerp(start.B, end.B, amount);
|
||||
result.A = Math::Lerp(start.A, end.A, amount);
|
||||
}
|
||||
static void Lerp(const Color& start, const Color& end, float amount, Color& result);
|
||||
|
||||
/// <summary>
|
||||
/// Performs a linear interpolation between two colors.
|
||||
@@ -323,12 +304,7 @@ public:
|
||||
/// <param name="end">The end color.</param>
|
||||
/// <param name="amount">The value between 0 and 1 indicating the weight of interpolation.</param>
|
||||
/// <returns>The linear interpolation of the two colors.</returns>
|
||||
static Color Lerp(const Color& start, const Color& end, float amount)
|
||||
{
|
||||
Color result;
|
||||
Lerp(start, end, amount, result);
|
||||
return result;
|
||||
}
|
||||
static Color Lerp(const Color& start, const Color& end, float amount);
|
||||
|
||||
// Converts a [0.0, 1.0] linear value into a [0.0, 1.0] sRGB value.
|
||||
static Color LinearToSrgb(const Color& linear);
|
||||
|
||||
Reference in New Issue
Block a user