Table of Contents

Struct ConsoleRgbColor

Namespace
RDCore.SDK.ConsoleIO
Assembly
RDCore.SDK.dll

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

R byte

The red channel.

G byte

The green channel.

B byte

The blue channel.

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

byte

Black

Black — the value TryParse(string?, out ConsoleRgbColor) yields for an unparseable token.

public static ConsoleRgbColor Black { get; }

Property Value

ConsoleRgbColor

G

The green channel.

public byte G { get; init; }

Property Value

byte

R

The red channel.

public byte R { get; init; }

Property Value

byte

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

ConsoleColor

ToString()

The #rrggbb form.

public override string ToString()

Returns

string

TryParse(string?, out ConsoleRgbColor)

Parses a #rrggbb or #rgb token (the leading # is optional).

public static bool TryParse(string? token, out ConsoleRgbColor color)

Parameters

token string

The colour token to parse.

color ConsoleRgbColor

The parsed colour; Black when parsing fails.

Returns

bool

true if token is a hexadecimal colour literal.