Struct VhColor
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
RbyteThe red component.
GbyteThe green component.
BbyteThe blue component.
AbyteThe 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
B
The blue component.
public byte B { readonly get; set; }
Property Value
G
The green component.
public byte G { readonly get; set; }
Property Value
R
The red component.
public byte R { readonly get; set; }
Property Value
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
abyteThe alpha component: 0 is transparent, 255 opaque.
rbyteThe red component.
gbyteThe green component.
bbyteThe 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
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
valuestringThe text.
Returns
- VhColor
The color.
Exceptions
- ArgumentNullException
valueis 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)