Rgb struct
Namespace: Arlecchino.Rendering.Colors · Assembly: Arlecchino.Core
A 24-bit color. Shown exactly only where the terminal supports true color; otherwise it is mapped to the nearest palette entry — see TerminalCapabilities.
public readonly struct Rgb : IEquatable<Rgb>
Implements IEquatable<T><Rgb>
Constructors
| Member | Summary |
|---|---|
Rgb(byte, byte, byte) | A 24-bit color. Shown exactly only where the terminal supports true color; otherwise it is mapped to the nearest palette entry — see TerminalCapabilities. |
Properties
| Member | Summary |
|---|---|
Blue | Blue channel. |
Green | Green channel. |
Hex | The color as #RRGGBB. |
Red | Red channel. |
Methods
| Member | Summary |
|---|---|
Deconstruct(out byte, out byte, out byte) | |
FromHsl(int, int, int) | Builds a color from hue, saturation and lightness — the form the color modal edits. |
ToHsl() | Splits the color back into hue, saturation and lightness. Channels are whole numbers, so a round trip through Rgb.FromHsl can shift a color by a unit or two. |
ToString() | Writes the color as its hexadecimal form. |
TryParseHex(string, out Rgb) | Reads a color written as #RRGGBB or RRGGBB. |
Constructors in detail
Rgb(byte, byte, byte)
public Rgb(byte Red, byte Green, byte Blue);
A 24-bit color. Shown exactly only where the terminal supports true color; otherwise it is mapped to the nearest palette entry — see TerminalCapabilities.
Parameters
| Name | Type | Description |
|---|---|---|
Red | byte | Red channel. |
Green | byte | Green channel. |
Blue | byte | Blue channel. |
Properties in detail
Blue
public byte Blue { get; init; }
Blue channel.
Type byte
Green
public byte Green { get; init; }
Green channel.
Type byte
Hex
public string Hex { get; }
The color as #RRGGBB.
Type string
Red
public byte Red { get; init; }
Red channel.
Type byte
Methods in detail
Deconstruct(out byte, out byte, out byte)
public void Deconstruct(out byte Red, out byte Green, out byte Blue);
Parameters
| Name | Type | Description |
|---|---|---|
Red | byte | |
Green | byte | |
Blue | byte |
FromHsl(int, int, int)
public static Rgb FromHsl(int hue, int saturation, int lightness);
Builds a color from hue, saturation and lightness — the form the color modal edits.
Parameters
| Name | Type | Description |
|---|---|---|
hue | int | Degrees around the wheel; values outside 0..359 wrap. |
saturation | int | Percent, clamped to 0..100. |
lightness | int | Percent, clamped to 0..100. |
Returns Rgb — The matching color.
ToHsl()
public ValueTuple<int, int, int> ToHsl();
Splits the color back into hue, saturation and lightness. Channels are whole numbers, so a round trip through Rgb.FromHsl can shift a color by a unit or two.
Returns ValueTuple<T1, T2, T3><int, int, int> — Hue in degrees, saturation and lightness in percent.
ToString()
public override string ToString();
Writes the color as its hexadecimal form.
Returns string — Rgb.Hex.
TryParseHex(string, out Rgb)
public static bool TryParseHex(string text, out Rgb color);
Reads a color written as #RRGGBB or RRGGBB.
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The text to read. |
color | Rgb | The color, or default when the text is not six hex digits. |
Returns bool — true when the text was a color.