Struct ConsoleRgbColor
A 24-bit console colour, as a shell frame understands it: three channels, no style semantics, no renderer dependency.
public readonly record struct ConsoleRgbColor : IEquatable<ConsoleRgbColor>
- Implements
- Inherited Members
Remarks
The platform's themes are authored in 24-bit hex (#0c0a50), but a console frame needs both
that exact value (for the ANSI escape sequences that set the terminal's own default colours) and
its nearest legacy ConsoleColor (for a terminal that cannot do either). This type
carries the first and computes the second, so neither the renderer nor the theme layer has to.
Constructors
ConsoleRgbColor(byte, byte, byte)
A 24-bit console colour, as a shell frame understands it: three channels, no style semantics, no renderer dependency.
public ConsoleRgbColor(byte R, byte G, byte B)
Parameters
Remarks
The platform's themes are authored in 24-bit hex (#0c0a50), but a console frame needs both
that exact value (for the ANSI escape sequences that set the terminal's own default colours) and
its nearest legacy ConsoleColor (for a terminal that cannot do either). This type
carries the first and computes the second, so neither the renderer nor the theme layer has to.
Properties
B
The blue channel.
public byte B { get; init; }
Property Value
Black
Black — the value TryParse(string?, out ConsoleRgbColor) yields for an unparseable token.
public static ConsoleRgbColor Black { get; }
Property Value
G
The green channel.
public byte G { get; init; }
Property Value
R
The red channel.
public byte R { get; init; }
Property Value
Methods
ToNearestConsoleColor()
The nearest legacy ConsoleColor, by squared distance in RGB space — what a console that cannot render 24-bit colour gets instead.
public ConsoleColor ToNearestConsoleColor()
Returns
ToString()
The #rrggbb form.
public override string ToString()
Returns
TryParse(string?, out ConsoleRgbColor)
Parses a #rrggbb or #rgb token (the leading # is optional).
public static bool TryParse(string? token, out ConsoleRgbColor color)
Parameters
tokenstringThe colour token to parse.
colorConsoleRgbColorThe parsed colour; Black when parsing fails.
Returns
- bool
trueiftokenis a hexadecimal colour literal.