#nullable enable
using System.Diagnostics.Contracts;
using System.Numerics;
namespace Terminal.Gui;
public readonly partial record struct Color {
///
///
/// A with all values set to , meaning white.
///
public static Color MaxValue => new Color (uint.MaxValue);
///
/// A with all values set to zero.
///
/// Though this returns a with , , , and all set to
/// zero, Terminal.Gui will treat it as black, because the alpha channel is not supported.
///
public static Color MinValue => new Color (uint.MinValue);
///
[Pure]
public override int GetHashCode () => Rgba.GetHashCode ();
///
/// Implicit conversion from to via where (
/// , , ) is (R,G,B).
///
///
/// This cast is narrowing and drops the alpha channel.
///
/// Use to maintain full value.
///
[Pure]
public static explicit operator Vector3 (Color color) => new Vector3 (color.R, color.G, color.B);
///
/// Implicit conversion from to , via the costructor.
///
[Pure]
public static implicit operator Color (int rgba) => new Color (rgba);
///
/// Implicit conversion from to by returning the value of the field.
///
[Pure]
public static implicit operator int (Color color) => color.Rgba;
///
/// Implicit conversion from to , via the costructor.
///
[Pure]
public static implicit operator Color (uint u) => new Color (u);
///
/// Implicit conversion from to by returning the value of the field.
///
[Pure]
public static implicit operator uint (Color color) => color.Argb;
///
/// Implicit conversion from to via lookup from
/// .
///
[Pure]
public static implicit operator Color (ColorName colorName) => ColorExtensions.ColorNameToColorMap [colorName];
///
/// Implicit conversion from to , where (, ,
/// , ) is (,,,), via
/// .
///
[Pure]
public static implicit operator Color (Vector4 v) => new Color ((byte)v.X, (byte)v.Y, (byte)v.Z, (byte)v.W);
///
/// Implicit conversion to , where = , =
/// , and = .
///
[Pure]
public static implicit operator Vector4 (Color color) => new Vector4 (color.R, color.G, color.B, color.A);
///
/// Implicit conversion from , where = , =
/// , and = .
///
[Pure]
public static implicit operator Color (Vector3 v) => new Color ((byte)v.X, (byte)v.Y, (byte)v.Z);
}