using System.Drawing;
namespace Peridot;
///
/// Represetns a RGBA color with floating point values.
/// All components must be between 0.0 and 1.0.
///
public partial struct ColorB : IEquatable
{
///
/// Constructs a new ColorB from components.
///
/// Red component.
/// Green component.
/// Blue component.
/// Alpha component.
public ColorB(byte r, byte g, byte b, byte a)
{
(R, G, B, A) = (r, g, b, a);
}
///
/// Constructs a new ColorB from a Color.
///
/// Color.
public ColorB(Color color)
{
(R, G, B, A) = (color.R, color.G, color.B, color.A);
}
///
/// Constructs a new ColorB from a Vector4.
///
/// Color.
public ColorB(ColorF color)
{
color *= 255f;
(R, G, B, A) = ((byte)color.R, (byte)color.G, (byte)color.B, (byte)color.A);
}
///
/// The red color component.
///
public byte R;
///
/// The green color component.
///
public byte G;
///
/// The blue color component.
///
public byte B;
///
/// The alpha color component.
///
public byte A;
///
public bool Equals(ColorB other)
{
return (R, G, B, A) == (other.R, other.G, other.B, other.A);
}
///
public override bool Equals(object? obj)
{
return obj != null && obj is ColorB other && Equals(other);
}
///
public override int GetHashCode()
{
return HashCode.Combine(R, G, B, A);
}
///
public override string ToString()
{
return $"{{R: {R}, G: {G}, B: {B}, A: {A}}}";
}
}