Class ANSIColor
Provides ANSI terminal color palette definitions and conversion utilities. Supports the standard 16-color ANSI palette (backed by a Scylla.Core.Util.Palette.ColorPalette), the 256-color extended palette (16 ANSI + 216 color cube + 24 grayscale), and 24-bit truecolor.
The active 16-color palette can be swapped via SetPalette(ColorPalette) to use any Scylla.Core.Util.Palette.ColorPalette with at least 16 entries (e.g. CGA, C64). The 256-color extension (color cube + grayscale ramp) is automatically rebuilt when the palette changes.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public static class ANSIColor
Properties
ActivePalette
The currently active 16-color palette backing this ANSI color provider.
Declaration
public static ColorPalette ActivePalette { get; }
Property Value
| Type | Description |
|---|---|
| ColorPalette |
Black
ANSI color 0: Black.
Declaration
public static Color32 Black { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Blue
ANSI color 4: Blue.
Declaration
public static Color32 Blue { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightBlack
ANSI color 8: Bright Black (dark gray).
Declaration
public static Color32 BrightBlack { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightBlue
ANSI color 12: Bright Blue.
Declaration
public static Color32 BrightBlue { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightCyan
ANSI color 14: Bright Cyan.
Declaration
public static Color32 BrightCyan { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightGreen
ANSI color 10: Bright Green.
Declaration
public static Color32 BrightGreen { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightMagenta
ANSI color 13: Bright Magenta.
Declaration
public static Color32 BrightMagenta { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightRed
ANSI color 9: Bright Red.
Declaration
public static Color32 BrightRed { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightWhite
ANSI color 15: Bright White.
Declaration
public static Color32 BrightWhite { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
BrightYellow
ANSI color 11: Bright Yellow.
Declaration
public static Color32 BrightYellow { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Cyan
ANSI color 6: Cyan.
Declaration
public static Color32 Cyan { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Green
ANSI color 2: Green.
Declaration
public static Color32 Green { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Magenta
ANSI color 5: Magenta.
Declaration
public static Color32 Magenta { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Red
ANSI color 1: Red.
Declaration
public static Color32 Red { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
White
ANSI color 7: White (light gray).
Declaration
public static Color32 White { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Yellow
ANSI color 3: Yellow.
Declaration
public static Color32 Yellow { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Methods
FromIndex(int)
Gets a color from the 256-color palette by index. Colors 0-15: from the active 16-color palette. Colors 16-231: 6x6x6 color cube. Colors 232-255: grayscale ramp.
Declaration
public static Color32 FromIndex(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Palette index (0-255). |
Returns
| Type | Description |
|---|---|
| Color32 | The color at the specified index. |
FromRGB(byte, byte, byte)
Creates a Color32 from RGB byte values (24-bit truecolor).
Declaration
public static Color32 FromRGB(byte r, byte g, byte b)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | r | Red component (0-255). |
| byte | g | Green component (0-255). |
| byte | b | Blue component (0-255). |
Returns
| Type | Description |
|---|---|
| Color32 | The Color32 value. |
FromStandard(int)
Gets a standard ANSI color by index (0-15). Indices outside 0-15 are clamped.
Declaration
public static Color32 FromStandard(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Standard color index (0-15). |
Returns
| Type | Description |
|---|---|
| Color32 | The ANSI color. |
ResetPalette()
Resets the active palette to the default xterm ANSI palette. Must only be called from the main thread.
Declaration
public static void ResetPalette()
SetPalette(ColorPalette)
Replaces the active 16-color palette with the specified palette. The palette must have at least 16 entries. Only the first 16 entries are used for ANSI color indices 0-15; the 256-color extension (color cube + grayscale ramp) is automatically rebuilt. Must only be called from the main thread.
Declaration
public static void SetPalette(ColorPalette palette)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorPalette | palette | The palette to use. Must contain at least 16 color entries. |