Table of Contents

Struct VhColor

Namespace
VpnHood.Net.Toolkit.Graphics
Assembly
VpnHood.Net.Toolkit.dll

Represents a color by its red, green, blue and alpha components.

public record struct VhColor : IEquatable<VhColor>
Implements
Inherited Members

Constructors

VhColor(byte, byte, byte, byte)

Represents a color by its red, green, blue and alpha components.

public VhColor(byte R, byte G, byte B, byte A)

Parameters

R byte

The red component.

G byte

The green component.

B byte

The blue component.

A byte

The alpha component: 0 is transparent, 255 opaque.

Properties

A

The alpha component: 0 is transparent, 255 opaque.

public byte A { readonly get; set; }

Property Value

byte

B

The blue component.

public byte B { readonly get; set; }

Property Value

byte

G

The green component.

public byte G { readonly get; set; }

Property Value

byte

R

The red component.

public byte R { readonly get; set; }

Property Value

byte

Methods

FromArgb(byte, byte, byte, byte)

Creates a color from its alpha, red, green and blue components.

public static VhColor FromArgb(byte a, byte r, byte g, byte b)

Parameters

a byte

The alpha component: 0 is transparent, 255 opaque.

r byte

The red component.

g byte

The green component.

b byte

The blue component.

Returns

VhColor

The color.

FromRgb(byte, byte, byte)

Creates an opaque color from its red, green and blue components.

public static VhColor FromRgb(byte r, byte g, byte b)

Parameters

r byte

The red component.

g byte

The green component.

b byte

The blue component.

Returns

VhColor

The color.

Parse(string)

Parses a color written in hexadecimal as #RRGGBB or #AARRGGBB; the # may be left out.

public static VhColor Parse(string value)

Parameters

value string

The text.

Returns

VhColor

The color.

Exceptions

ArgumentNullException

value is null.

FormatException

The text is in neither form, or is not hexadecimal.

TryParse(string?, out VhColor)

Tries to parse a color written as Parse(string) reads it.

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

Parameters

value string

The text, or null.

color VhColor

The color, when parsed; otherwise, the default.

Returns

bool

true if the text is a color; false if it is null, blank or malformed.