Color
ConsoleMonster.Styling
A terminal colour: the default colour, a 16- or 256-palette index, or 24-bit RGB. Colours are downsampled to the profile's ColorDepth at encoding time.
Inheritance
- ValueType
- Color
Usage
Explore 66 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 24
- Property TerminalProfile.DefaultBackground
- Property TerminalProfile.DefaultForeground
- Method Color.Blend
- Method Color.Downsample
- Method Color.FromAnsi16
- Method Color.FromAnsi256
- Method Color.FromConsoleColor
- Method Color.FromHex
- Method Color.FromRgb
- Property Color.Default
- Property RichColor.Color
- Property Style.BackgroundColor
- Property Style.Color
- Property TerminalScheme.Background
- Property TerminalScheme.Cursor
- Property TerminalScheme.Foreground
- Property TerminalScheme.Palette
- Property TerminalScheme.Selection
- Property TerminalScheme.SignatureAccent
- Property ThemeCheckOptions.Background
- Method ThemeColor.Resolve
- Property ThemeColor.TrueColor
- Property Logo.EndColor
- Property Logo.StartColor
Accepted by parameters 42
- Method BrailleCanvas.Line
- Method BrailleCanvas.Set
- Method BrailleCanvas.VerticalSpan
- Method CharacterCanvas.Line
- Method CharacterCanvas.Set
- Method CharacterCanvas.VerticalSpan
- Method HalfBlockCanvas.Line
- Method HalfBlockCanvas.Set
- Method HalfBlockCanvas.VerticalSpan
- Method PixelCanvas.Line
- Method PixelCanvas.Set
- Method PixelCanvas.VerticalSpan
- Method TerminalProfile.WithDefaultColors
- Method TerminalProfile.WithDefaultColors
- Method Color.Blend
- Method Color.Equals
- Method Color.op_Equality
- Method Color.op_Equality
- Method Color.op_Inequality
- Method Color.op_Inequality
- Method Color.TryParse
- Method ConsoleColorMap.Background
- Method ConsoleColorMap.Foreground
- Method RichColor.From
- Method RichColor.op_Implicit
- Constructor Style.Style
- Constructor Style.Style
- Method Style.WithBackgroundColor
- Method Style.WithColor
- Constructor TerminalScheme.TerminalScheme
- Constructor TerminalScheme.TerminalScheme
- Constructor TerminalScheme.TerminalScheme
- Constructor TerminalScheme.TerminalScheme
- Constructor TerminalScheme.TerminalScheme
- Constructor TerminalScheme.TerminalScheme
- Extension method ThemeCheckOptions.Background
- Method ThemeCheckOptionsFluent.Background
- Constructor ThemeColor.ThemeColor
- Extension method Logo.EndColor
- Extension method Logo.StartColor
- Method LogoFluent.EndColor
- Method LogoFluent.StartColor
Methods
public Color Blend(Color other, double amount) #Linearly blends towards another colour in RGB space (used for gradients).
Parameters
- other ConsoleMonster.Styling.Color
- The target colour.
- amount double
- 0 returns this colour, 1 returns other.
public Color Downsample(ColorDepth depth) #Converts the colour to the closest colour representable at depth.
Parameters
- depth ConsoleMonster.Capabilities.ColorDepth
- The target colour depth.
public bool Equals(Color other) #Indicates whether the current object is equal to another object of the same type.
Parameters
- other ConsoleMonster.Styling.Color
- An object to compare with this object.
Returns
bool true if the current object is equal to the other parameter; otherwise, false.public override bool Equals(object? obj) #Indicates whether this instance and a specified object are equal.
Parameters
- obj object?
- The object to compare with the current instance.
Returns
bool true if obj and this instance are the same type and represent the same value; otherwise, false.public static Color FromAnsi16(int index) #Creates one of the 16 standard colours.
Parameters
- index int
- Index 0-15 (0 black, 1 maroon, 2 green, 3 olive, 4 navy, 5 purple, 6 teal, 7 silver, 8 grey, 9 red, 10 lime, 11 yellow, 12 blue, 13 fuchsia, 14 aqua, 15 white).
public static Color FromAnsi256(int index) #Creates an xterm 256-palette colour.
Parameters
- index int
- Index 0-255.
public static Color FromConsoleColor(ConsoleColor color) #Converts a host console color to its corresponding ANSI 16 palette color.
Parameters
- color System.ConsoleColor
- The host color, such as a foreground or background snapshot.
Exceptions
ArgumentOutOfRangeException– The value is not one of the 16 console colors.
public static Color FromHex(string hex) #Parses #rgb or #rrggbb.
Parameters
- hex string
- The hex string, with or without the leading #.
public static Color FromRgb(byte r, byte g, byte b) #Creates a 24-bit colour.
Parameters
- r byte
- Red.
- g byte
- Green.
- b byte
- Blue.
public override int GetHashCode() #Returns the hash code for this instance.
Returns
int A 32-bit signed integer that is the hash code for this instance.public static bool op_Equality(Color left, Color right) #Equality operator.
Parameters
- left ConsoleMonster.Styling.Color
- Left.
- right ConsoleMonster.Styling.Color
- Right.
Returns
bool Whether equal.public static bool op_Inequality(Color left, Color right) #Inequality operator.
Parameters
- left ConsoleMonster.Styling.Color
- Left.
- right ConsoleMonster.Styling.Color
- Right.
Returns
bool Whether different.public void ToRgb(out byte r, out byte g, out byte b) #Returns the approximate RGB value of the colour (palette colours use the Campbell scheme).
Parameters
- r byte
- Red.
- g byte
- Green.
- b byte
- Blue.
public override string ToString() #Returns the fully qualified type name of this instance.
Returns
string The fully qualified type name.public static bool TryParse(string? text, out Color color) #Parses a colour the way Spectre.Console markup does: one of the 256 xterm names (red, aqua, orange1, cadetblue, grey50, deepskyblue4_1), default, #rrggbb, #rgb, rgb(r,g,b), or a 256-palette index (208 or color(208)). Where an xterm name and a ConsoleColor name collide (darkred, darkcyan), the xterm colour wins here, as in Spectre markup; ConsoleColor names that are not xterm names (darkgray, darkyellow, magenta, cyan) keep the PowerShell mapping. Either meaning can be asked for explicitly: console.darkred is the ConsoleColor as Write-Host shows it, palette.darkred the palette colour. RichColor.TryParse reads bare ConsoleColor names first.
Parameters
- text string?
- The text to parse.
- color ConsoleMonster.Styling.Color
- The parsed colour.
Returns
bool Whether parsing succeeded.