Struct Color
An ARGB color.
public readonly struct Color : IEquatable<Color>
- Implements
- Inherited Members
Constructors
Color(byte, byte, byte, byte)
Initializes a new instance of the Color struct.
public Color(byte a, byte r, byte g, byte b)
Parameters
a
byteThe alpha component.
r
byteThe red component.
g
byteThe green component.
b
byteThe blue component.
Properties
A
Gets the Alpha component of the color.
public byte A { get; }
Property Value
B
Gets the Blue component of the color.
public byte B { get; }
Property Value
G
Gets the Green component of the color.
public byte G { get; }
Property Value
R
Gets the Red component of the color.
public byte R { get; }
Property Value
Methods
Equals(Color)
public bool Equals(Color other)
Parameters
other
Color
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
Returns
FromArgb(byte, byte, byte, byte)
Creates a Color from alpha, red, green and blue components.
public static Color FromArgb(byte a, byte r, byte g, byte b)
Parameters
a
byteThe alpha component.
r
byteThe red component.
g
byteThe green component.
b
byteThe blue component.
Returns
- Color
The color.
FromRgb(byte, byte, byte)
Creates a Color from red, green and blue components.
public static Color FromRgb(byte r, byte g, byte b)
Parameters
Returns
- Color
The color.
FromUInt32(uint)
Creates a Color from an integer.
public static Color FromUInt32(uint value)
Parameters
value
uintThe integer value.
Returns
- Color
The color.
GetHashCode()
public override int GetHashCode()
Returns
Parse(ReadOnlySpan<char>)
Parses a color string.
public static Color Parse(ReadOnlySpan<char> s)
Parameters
s
ReadOnlySpan<char>The color string.
Returns
Parse(string)
Parses a color string.
public static Color Parse(string s)
Parameters
s
stringThe color string.
Returns
ToHsl()
Returns the HSL color model equivalent of this RGB color.
public HslColor ToHsl()
Returns
- HslColor
The HSL equivalent color.
ToHsl(byte, byte, byte, byte)
Converts the given RGBA color component values to their HSL color equivalent.
public static HslColor ToHsl(byte red, byte green, byte blue, byte alpha = 255)
Parameters
red
byteThe Red component in the RGB color model.
green
byteThe Green component in the RGB color model.
blue
byteThe Blue component in the RGB color model.
alpha
byteThe Alpha component.
Returns
ToHsv()
Returns the HSV color model equivalent of this RGB color.
public HsvColor ToHsv()
Returns
- HsvColor
The HSV equivalent color.
ToHsv(byte, byte, byte, byte)
Converts the given RGBA color component values to their HSV color equivalent.
public static HsvColor ToHsv(byte red, byte green, byte blue, byte alpha = 255)
Parameters
red
byteThe Red component in the RGB color model.
green
byteThe Green component in the RGB color model.
blue
byteThe Blue component in the RGB color model.
alpha
byteThe Alpha component.
Returns
ToString()
Returns the string representation of the color.
public override string ToString()
Returns
- string
The string representation of the color.
ToUInt32()
Returns the integer representation of the color.
public uint ToUInt32()
Returns
- uint
The integer representation of the color.
TryParse(ReadOnlySpan<char>, out Color)
Parses a color string.
public static bool TryParse(ReadOnlySpan<char> s, out Color color)
Parameters
s
ReadOnlySpan<char>The color string.
color
ColorThe parsed color
Returns
- bool
The status of the operation.
TryParse(string?, out Color)
Parses a color string.
public static bool TryParse(string? s, out Color color)
Parameters
Returns
- bool
The status of the operation.
Operators
operator ==(Color, Color)
Indicates whether the values of two specified Color objects are equal.
public static bool operator ==(Color left, Color right)
Parameters
Returns
- bool
True if left and right are equal; otherwise, false.
operator !=(Color, Color)
Indicates whether the values of two specified Color objects are not equal.
public static bool operator !=(Color left, Color right)
Parameters
Returns
- bool
True if left and right are not equal; otherwise, false.