API Reference
Color
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 46 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 14
- Method Color.Blend
- Method Color.Downsample
- Method Color.FromAnsi16
- Method Color.FromAnsi256
- Method Color.FromHex
- Method Color.FromRgb
- Property Color.Default
- Property RichColor.Color
- Property Style.Background
- Property Style.Foreground
- Method ThemeColor.Resolve
- Property ThemeColor.TrueColor
- Property Logo.From
- Property Logo.To
Accepted by parameters 32
- 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 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.WithBackground
- Method Style.WithForeground
- Constructor ThemeColor.ThemeColor
- Extension method Logo.WithFrom
- Extension method Logo.WithTo
- Method LogoFluent.WithFrom
- Method LogoFluent.WithTo
Methods
public Color Blend(Color other, Double amount) #ColorLinearly blends towards another colour in RGB space (used for gradients).
Parameters
- other ConsoleMonster.Styling.Color
- The target colour.
- amount System.Double
- 0 returns this colour, 1 returns other.
Returns
An RGB colour.
public Color Downsample(ColorDepth depth) #ColorConverts the colour to the closest colour representable at depth.
Parameters
- depth ConsoleMonster.Capabilities.ColorDepth
- The target colour depth.
Returns
The downsampled colour; Color.Default for ColorDepth.None.
public Boolean Equals(Color other) #BooleanIndicates 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
true if the current object is equal to the other parameter; otherwise, false.
public override Boolean Equals(Object? obj) #BooleanIndicates whether this instance and a specified object are equal.
Parameters
- obj System.Object?
- The object to compare with the current instance.
Returns
true if obj and this instance are the same type and represent the same value; otherwise, false.
public static Color FromAnsi16(Int32 index) #ColorCreates one of the 16 standard colours.
Parameters
- index System.Int32
- 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).
Returns
The colour.
public static Color FromAnsi256(Int32 index) #ColorCreates an xterm 256-palette colour.
Parameters
- index System.Int32
- Index 0-255.
Returns
The colour.
public static Color FromHex(String hex) #ColorParses #rgb or #rrggbb.
Parameters
- hex System.String
- The hex string, with or without the leading #.
Returns
The colour.
public static Color FromRgb(Byte r, Byte g, Byte b) #ColorCreates a 24-bit colour.
Parameters
- r System.Byte
- Red.
- g System.Byte
- Green.
- b System.Byte
- Blue.
Returns
The colour.
public override Int32 GetHashCode() #Int32Returns the hash code for this instance.
Returns
A 32-bit signed integer that is the hash code for this instance.
public static Boolean op_Equality(Color left, Color right) #BooleanEquality operator.
Parameters
- left ConsoleMonster.Styling.Color
- Left.
- right ConsoleMonster.Styling.Color
- Right.
Returns
Whether equal.
public static Boolean op_Inequality(Color left, Color right) #BooleanInequality operator.
Parameters
- left ConsoleMonster.Styling.Color
- Left.
- right ConsoleMonster.Styling.Color
- Right.
Returns
Whether different.
public Void ToRgb(out Byte r, out Byte g, out Byte b) #VoidReturns the approximate RGB value of the colour (palette colours use the Campbell scheme).
Parameters
- r System.Byte
- Red.
- g System.Byte
- Green.
- b System.Byte
- Blue.
public override String ToString() #StringReturns the fully qualified type name of this instance.
Returns
The fully qualified type name.
public static Boolean TryParse(String? text, out Color color) #BooleanParses 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 System.String?
- The text to parse.
- color ConsoleMonster.Styling.Color
- The parsed colour.
Returns
Whether parsing succeeded.