ChartColor Struct

An sRGB color with an alpha channel, 8 bits per channel.

public readonly struct ChartColor : IEquatable<ChartColor>
Implements

Constructors

NameDescription
ChartColor(byte, byte, byte, byte)An sRGB color with an alpha channel, 8 bits per channel.

ChartColor(byte, byte, byte, byte)

An sRGB color with an alpha channel, 8 bits per channel.

public ChartColor(byte R, byte G, byte B, byte A = 255)

Parameters

R byte
The red channel.
G byte
The green channel.
B byte
The blue channel.
A byte
The alpha channel: 0 is transparent, 255 is opaque.

Properties

NameDescription
AThe alpha channel: 0 is transparent, 255 is opaque.
BThe blue channel.
BlackGets the opaque black color.
GThe green channel.
IsOpaqueGets a value that indicates whether the color is fully opaque.
OpacityGets the opacity of the color, from 0 to 1.
RThe red channel.
TransparentGets the transparent color.
WhiteGets the opaque white color.

The alpha channel: 0 is transparent, 255 is opaque.

public byte A { get; init; }

Property value

byte

The blue channel.

public byte B { get; init; }

Property value

byte

Gets the opaque black color.

public static ChartColor Black { get; }

Property value

ChartColor

The green channel.

public byte G { get; init; }

Property value

byte

Gets a value that indicates whether the color is fully opaque.

public bool IsOpaque { get; }

Property value

bool

Gets the opacity of the color, from 0 to 1.

public double Opacity { get; }

Property value

double

The red channel.

public byte R { get; init; }

Property value

byte

Transparent

ChartColor.cs

Gets the transparent color.

public static ChartColor Transparent { get; }

Property value

ChartColor

Gets the opaque white color.

public static ChartColor White { get; }

Property value

ChartColor

Methods

NameDescription
Deconstruct(byte, byte, byte, byte)
Equals(ChartColor)
Equals(object)
GetHashCode()
Parse(string)Parses a color: #rgb, #rgba, #rrggbb, #rrggbbaa, or a common CSS color name such as steelblue.
ToHexRgb()Returns the color as #rrggbb, without its alpha channel.
ToString()Returns the color as #rrggbb, or #rrggbbaa when it is not opaque.
TryParse(string?, ChartColor)Tries to parse a color: #rgb, #rgba, #rrggbb, #rrggbbaa, or a common CSS color name.
WithOpacity(double)Returns a copy of the color with another opacity.

Deconstruct(byte, byte, byte, byte)

public void Deconstruct(out byte R, out byte G, out byte B, out byte A)

Parameters

R byte
G byte
B byte
A byte

No documentation is available.

Equals overloads

Equals(ChartColor)

public bool Equals(ChartColor other)
Parameters
other ChartColor
Returns

bool

No documentation is available.

Equals(object)

public override bool Equals(object obj)
Parameters
obj object
Returns

bool

No documentation is available.

GetHashCode()

public override int GetHashCode()

Returns

int

No documentation is available.

Parse(string)

ChartColor.cs

Parses a color: #rgb, #rgba, #rrggbb, #rrggbbaa, or a common CSS color name such as steelblue.

public static ChartColor Parse(string value)

Parameters

value string
The text to parse.

Returns

ChartColor The color.

Exceptions

FormatException
value is not a supported color.

ToHexRgb()

ChartColor.cs

Returns the color as #rrggbb, without its alpha channel.

public string ToHexRgb()

Returns

string The hexadecimal notation of the color.

ToString()

ChartColor.cs

Returns the color as #rrggbb, or #rrggbbaa when it is not opaque.

public override string ToString()

Returns

string The hexadecimal notation of the color.

TryParse(string?, ChartColor)

ChartColor.cs

Tries to parse a color: #rgb, #rgba, #rrggbb, #rrggbbaa, or a common CSS color name.

public static bool TryParse(string? value, out ChartColor color)

Parameters

value string?
The text to parse.
color ChartColor
The color, when the method returns true.

Returns

bool true when value is a supported color.

WithOpacity(double)

ChartColor.cs

Returns a copy of the color with another opacity.

public ChartColor WithOpacity(double opacity)

Parameters

opacity double
The opacity, from 0 to 1.

Returns

ChartColor The color.

Operators

NameDescription
operator ==(ChartColor, ChartColor)
implicit operator ChartColor(string)Converts a text to a color with ChartColor.Parse.
operator !=(ChartColor, ChartColor)

operator ==(ChartColor, ChartColor)

public static bool operator ==(ChartColor left, ChartColor right)

Parameters

left ChartColor
right ChartColor

Returns

bool

No documentation is available.

implicit operator ChartColor(string)

ChartColor.cs

Converts a text to a color with ChartColor.Parse.

public static implicit operator ChartColor(string value)

Parameters

value string
The text to parse.

Returns

ChartColor

operator !=(ChartColor, ChartColor)

public static bool operator !=(ChartColor left, ChartColor right)

Parameters

left ChartColor
right ChartColor

Returns

bool

No documentation is available.