Class TextColor
Namespace: Void.Minecraft.Components.Text.Colors
Assembly: Void.Minecraft.dll
Represents an RGB color used by a Minecraft text component.
public record TextColor : IEquatable<TextColor>Inheritance
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
TextColor(byte, byte, byte)
Represents an RGB color used by a Minecraft text component.
public TextColor(byte Red, byte Green, byte Blue)Parameters
Red byte
The red channel.
Green byte
The green channel.
Blue byte
The blue channel.
Properties
Blue
The blue channel.
public byte Blue { get; init; }Property Value
Green
The green channel.
public byte Green { get; init; }Property Value
Name
Gets the Minecraft color name, or an uppercase #RRGGBB value for an unnamed color.
public string Name { get; }Property Value
Red
The red channel.
public byte Red { get; init; }Property Value
Methods
Downsample()
Finds the nearest color in the sixteen-color legacy Minecraft palette.
public TextColor Downsample()Returns
The closest legacy color according to hue, saturation, and brightness distance.
FromString(string)
Parses a Minecraft color name or hexadecimal RGB value.
public static TextColor FromString(string value)Parameters
value string
A case-insensitive Minecraft color name or a #RRGGBB value.
Returns
The parsed color.
Exceptions
value is not a recognized name or valid hexadecimal color.
ToString()
Returns the canonical color identifier for this value.
public override string ToString()Returns
Remarks
Named Minecraft colors return their registered identifier, such as red or dark_blue.
Unmapped colors return a hexadecimal RGB string in #RRGGBB format.
Operators
implicit operator TextColor((byte Red, byte Green, byte Blue))
Creates a color from an RGB tuple.
public static implicit operator TextColor((byte Red, byte Green, byte Blue) color)Parameters
color (byte Red, byte Green, byte Blue)
The RGB channels.
Returns
A color containing the supplied channels.
implicit operator TextColor(Color)
Creates a text color from a drawing color, discarding its alpha channel.
public static implicit operator TextColor(Color color)Parameters
color Color
The drawing color.
Returns
The corresponding RGB text color.
implicit operator TextColor(string)
Parses a named or hexadecimal text color.
public static implicit operator TextColor(string color)Parameters
color string
A Minecraft color name or #RRGGBB value.
Returns
The parsed color.
Exceptions
color is not a recognized name or valid hexadecimal color.
implicit operator Color(TextColor)
Converts a text color to an opaque drawing color.
public static implicit operator Color(TextColor color)Parameters
color TextColor
The text color.
Returns
The corresponding drawing color.
implicit operator string(TextColor)
Converts a text color to its canonical identifier.
public static implicit operator string(TextColor color)Parameters
color TextColor
The text color.
Returns
The value of