Color Struct
Represents a color.
public struct Color : IEquatable<Color>
Public Structure Color
Implements IEquatable(Of Color)
Implements
Properties
A
Gets the color opacity (0 = fully transparent, 255 = fully opaque).
Property Value
- System.Byte
The color opacity.
Argb
Gets the Opacity, Red, Green and Blue components in a single System.Int32 value.
Property Value
- System.Int32
The Opacity, Red, Green and Blue components in a single System.Int32 value.
B
Gets the Blue component (from 0 to 255).
Property Value
- System.Byte
The Blue component.
G
Gets the Green component (from 0 to 255).
Property Value
- System.Byte
The Green component.
Name
Gets the color name.
Property Value
The color name.
R
Gets the Red component (from 0 to 255).
Property Value
- System.Byte
The Red component.
Methods
Equals(Color)
Parameters
other
- Color
The other color to compare with this color instance.
Returns
Equals(Object)
Determines whether the specified System.Object is equal to this Color instance.
public override bool Equals(object obj)
Public Overrides Function Equals(obj As Object) As Boolean
Parameters
obj
- System.Object
The System.Object to compare with this color instance.
Returns
- System.Boolean
Overrides
FromHexString(String)
Initializes a new instance of the Color struct.
public static Color FromHexString(string hex)
Public Shared Function FromHexString(hex As String) As Color
Parameters
hex
- System.String
The string that represents the color in the format #AARRGGBB or #RRGGBB where AA is the byte that represents the alpha component. RR is the byte that represents the red component, GG is the byte that represents the green component and BB is the byte that represents the blue component.
Returns
FromHsl(Int32, Int32, Int32)
Creates a new color instance from the specified Hue, Saturation and Lightness components.
public static Color FromHsl(int h, int s, int l)
Public Shared Function FromHsl(h As Integer, s As Integer, l As Integer) As Color
Parameters
h
- System.Int32
The Hue component (from 0 to 255).
s
- System.Int32
The Saturation component (from 0 to 255).
l
- System.Int32
The Lightness component (from 0 to 255).
Returns
A new color instance from the specified Hue, Saturation and Lightness components.
FromHsl(Int32, Int32, Int32, Double)
Creates a new color instance from the specified Hue, Saturation and Lightness components and transparency.
public static Color FromHsl(int h, int s, int l, double transparency)
Public Shared Function FromHsl(h As Integer, s As Integer, l As Integer, transparency As Double) As Color
Parameters
h
- System.Int32
The Hue component (from 0 to 255).
s
- System.Int32
The Saturation component (from 0 to 255).
l
- System.Int32
The Lightness component (from 0 to 255).
transparency
- System.Double
The transparency (0 = fully opaque, 1 = fully transparent).
Returns
A new color instance from the specified Hue, Saturation and Lightness components and transparency.
FromName(ColorName)
Creates a new color instance from the specified color name.
public static Color FromName(ColorName name)
Public Shared Function FromName(name As ColorName) As Color
Parameters
name
- ColorName
The color name.
Returns
A color instance with the specified name.
FromName(ColorName, Double)
Creates a new color instance from the specified color name and luminance.
public static Color FromName(ColorName name, double luminance)
Public Shared Function FromName(name As ColorName, luminance As Double) As Color
Parameters
name
- ColorName
The color name.
luminance
- System.Double
The luminance (-1 = darkest, 0 = none, 1 = lightest).
Returns
A color instance with the specified name and luminance.
FromName(ColorName, Double, Double)
Creates a new color instance from the specified color name, luminance and transparency.
public static Color FromName(ColorName name, double luminance, double transparency)
Public Shared Function FromName(name As ColorName, luminance As Double, transparency As Double) As Color
Parameters
name
- ColorName
The color name.
luminance
- System.Double
The luminance (-1 = darkest, 0 = none, 1 = lightest).
transparency
- System.Double
The transparency (0 = fully opaque, 1 = fully transparent).
Returns
A color instance with the specified name, luminance and transparency.
FromRgb(Int32, Int32, Int32)
Creates a new color instance from the specified Red, Green and Blue components.
public static Color FromRgb(int r, int g, int b)
Public Shared Function FromRgb(r As Integer, g As Integer, b As Integer) As Color
Parameters
r
- System.Int32
The Red component (from 0 to 255).
g
- System.Int32
The Green component (from 0 to 255).
b
- System.Int32
The Blue component (from 0 to 255).
Returns
A new color instance from the specified Red, Green and Blue components.
FromRgb(Int32, Int32, Int32, Double)
Creates a new color instance from the specified Red, Green and Blue components and transparency.
public static Color FromRgb(int r, int g, int b, double transparency)
Public Shared Function FromRgb(r As Integer, g As Integer, b As Integer, transparency As Double) As Color
Parameters
r
- System.Int32
The Red component (from 0 to 255).
g
- System.Int32
The Green component (from 0 to 255).
b
- System.Int32
The Blue component (from 0 to 255).
transparency
- System.Double
The transparency (0 = fully opaque, 1 = fully transparent).
Returns
A new color instance from the specified Red, Green and Blue components and transparency.
GetHashCode()
Returns a hash code for this Color instance.
Returns
- System.Int32
An integer value that specifies a hash value for this Color instance.
Overrides
ToString()
Returns a System.String that represents this Color instance.
Returns
- System.String
A System.String that represents this Color instance.
Overrides
Operators
Equality(Color, Color)
Determines whether first
and second
Colors are equal.
public static bool operator ==(Color first, Color second)
Public Shared Operator =(first As Color, second As Color) As Boolean
Parameters
first
- Color
The first color.
second
- Color
The second color.
Returns
- System.Boolean
true if first
and second
colors are equal; otherwise, false.
Inequality(Color, Color)
Determines whether first
and second
Colors are not equal.
public static bool operator !=(Color first, Color second)
Public Shared Operator <>(first As Color, second As Color) As Boolean
Parameters
first
- Color
The first color.
second
- Color
The second color.
Returns
- System.Boolean
true if first
and second
colors are not equal; otherwise, false.