Hex1bColor
Namespace: Hex1b.Theming
Assembly: Hex1b.dll
Represents a color that can be used in the terminal.
public readonly struct Hex1bColorProperties
AnsiIndex
The ANSI color index (0–7 for standard/bright, 0–255 for indexed). Only meaningful when is not .
Returns: Byte
public byte AnsiIndex { get; }B
Returns: Byte
public byte B { get; }Black
Returns: Hex1bColor
public static Hex1bColor Black { get; }Blue
Returns: Hex1bColor
public static Hex1bColor Blue { get; }Cyan
Returns: Hex1bColor
public static Hex1bColor Cyan { get; }DarkGray
Returns: Hex1bColor
public static Hex1bColor DarkGray { get; }Default
The default terminal foreground/background color.
Returns: Hex1bColor
public static Hex1bColor Default { get; }G
Returns: Byte
public byte G { get; }Gray
Returns: Hex1bColor
public static Hex1bColor Gray { get; }Green
Returns: Hex1bColor
public static Hex1bColor Green { get; }IsDefault
Returns: Boolean
public bool IsDefault { get; }Kind
The color encoding kind.
Returns: Hex1bColorKind
public Hex1bColorKind Kind { get; }LightGray
Returns: Hex1bColor
public static Hex1bColor LightGray { get; }Magenta
Returns: Hex1bColor
public static Hex1bColor Magenta { get; }R
Returns: Byte
public byte R { get; }Red
Returns: Hex1bColor
public static Hex1bColor Red { get; }White
Returns: Hex1bColor
public static Hex1bColor White { get; }Yellow
Returns: Hex1bColor
public static Hex1bColor Yellow { get; }Methods
FromBright(byte, byte, byte, byte)
Creates a bright ANSI color (indices 0–7, corresponding to SGR 90–97).
Parameters:
index(Byte): Color index 0–7.r(Byte): Approximate RGB red component.g(Byte): Approximate RGB green component.b(Byte): Approximate RGB blue component.
Returns: Hex1bColor
public static Hex1bColor FromBright(byte index, byte r, byte g, byte b)FromIndexed(byte, byte, byte, byte)
Creates a 256-color palette color (SGR 38;5;N).
Parameters:
index(Byte): Color index 0–255.r(Byte): Approximate RGB red component.g(Byte): Approximate RGB green component.b(Byte): Approximate RGB blue component.
Returns: Hex1bColor
public static Hex1bColor FromIndexed(byte index, byte r, byte g, byte b)FromRgb(byte, byte, byte)
Creates a color from RGB values.
Parameters:
Returns: Hex1bColor
public static Hex1bColor FromRgb(byte r, byte g, byte b)FromStandard(byte, byte, byte, byte)
Creates a standard ANSI color (indices 0–7, corresponding to SGR 30–37).
Parameters:
index(Byte): Color index 0–7.r(Byte): Approximate RGB red component (for rendering when palette is unavailable).g(Byte): Approximate RGB green component.b(Byte): Approximate RGB blue component.
Returns: Hex1bColor
public static Hex1bColor FromStandard(byte index, byte r, byte g, byte b)ToBackgroundAnsi()
Gets the ANSI escape code for setting this as the background color.
Returns: String
public string ToBackgroundAnsi()ToForegroundAnsi()
Gets the ANSI escape code for setting this as the foreground color.
Returns: String
public string ToForegroundAnsi()ToUnderlineColorAnsi()
Gets the ANSI escape code for setting this as the underline color (SGR 58).
Returns: String
public string ToUnderlineColorAnsi()Remarks
Colors preserve their original encoding so that when re-serialized they emit the same SGR code the workload originally sent. This ensures standard ANSI colors (e.g., SGR 34 = blue) remain palette-relative instead of being converted to fixed RGB values.