Skip to content

Color

namespace Griff;
public struct Color

An RGBA color with 0–1 float channels. Saved as hex, e.g. “#F08C2EFF”.

public float A { get; init; }
public byte AByte { get; }
public float B { get; init; }
public byte BByte { get; }
public static Color Black { get; }
public static Color Blue { get; }
public static Color Cyan { get; }
public float G { get; init; }
public byte GByte { get; }
public static Color Gray { get; }
public static Color Green { get; }
public static Color Magenta { get; }
public static Color Orange { get; }
public float R { get; init; }
public byte RByte { get; }
public static Color Red { get; }
public static Color Transparent { get; }
public static Color White { get; }
public static Color Yellow { get; }
public void Deconstruct(out float R, out float G, out float B, out float A)
public override bool Equals(object obj)
public bool Equals(Color other)
public static Color FromBytes(byte r, byte g, byte b, byte a = 255)
public static Color FromHsv(float hue, float saturation, float value, float alpha = 1f)

The color with hue hue (degrees round the color wheel: 0 red, 120 green, 240 blue), saturation saturation (0 gray to 1 full) and value value (0 black to 1 bright).

public override int GetHashCode()
public static Color Lerp(Color a, Color b, float t)

The color t of the way from a to b (0 gives a, 1 gives b).

public string ToHex()
public ValueTuple<float, float, float> ToHsv()

The color’s hue (0 to 360 degrees, 0 for grays), saturation and value (each 0 to 1); see FromHsv.

public override string ToString()
public static bool TryParse(string? text, out Color color)

Parses “#RGB”, “#RRGGBB” or “#RRGGBBAA” (the # is optional).