using System;
namespace OpenMacroBoard.SDK
{
///
/// Represents a color value.
///
public readonly partial struct OmbColor : IEquatable
{
private OmbColor(byte r, byte g, byte b)
{
R = r;
G = g;
B = b;
}
///
/// The red part of the color.
///
public byte R { get; }
///
/// The green part of the color.
///
public byte G { get; }
///
/// The blue part of the color.
///
public byte B { get; }
///
/// Checks whether two structures are equal.
///
/// The left hand operand.
/// The right hand operand.
///
/// True if the parameter is equal to the parameter;
/// otherwise, false.
///
public static bool operator ==(OmbColor left, OmbColor right)
{
return left.Equals(right);
}
///
/// Checks whether two structures are equal.
///
/// The left hand operand.
/// The right hand operand.
///
/// True if the parameter is not equal to the parameter;
/// otherwise, false.
///
public static bool operator !=(OmbColor left, OmbColor right)
{
return !left.Equals(right);
}
///
/// Creates a from RGB bytes.
///
/// The red component (0-255).
/// The green component (0-255).
/// The blue component (0-255).
/// The .
public static OmbColor FromRgb(byte r, byte g, byte b)
{
return new OmbColor(r, g, b);
}
///
public override string ToString()
{
return $"#{R:X2}{G:X2}{B:X2}";
}
///
public bool Equals(OmbColor other)
{
return
R == other.R &&
G == other.G &&
B == other.B;
}
///
public override bool Equals(object obj)
{
return obj is OmbColor other && Equals(other);
}
///
public override int GetHashCode()
{
return HashCode.Combine(R, G, B);
}
}
}