Parent: Object
The WLColor class represents a color in a platform-independent way. A WLColor consists of alpha, red, green, and blue components, each represented by a byte from 0 to 255. WealthLab uses WLColor throughout its API wherever a color needs to be specified without depending on a platform-specific color implementation. The original WLColor is not modified. WLColor provides static properties for a comprehensive set of standard named colors. For example:
WLColor.Black
WLColor.Blue
WLColor.Cyan
WLColor.DarkGray
WLColor.Gold
WLColor.Gray
WLColor.Green
WLColor.LightBlue
WLColor.Magenta
WLColor.Orange
WLColor.Purple
WLColor.Red
WLColor.Silver
WLColor.Teal
WLColor.White
WLColor.Yellow
These return fully opaque WLColor instances using the predefined RGB values. In the current implementation, Transparent and Empty therefore contain identical ARGB component values. WLColor also provides a set of predefined Neon colors:
WLColor.NeonPurple
WLColor.NeonBlue
WLColor.NeonYellow
WLColor.NeonOrange
WLColor.NeonRed
WLColor.NeonFuschia
WLColor.NeonGreen
These colors are useful for charts and other visual elements where a brighter, high-contrast color is desired.
The parameterless constructor creates a WLColor whose component values are initially zero. The three-component constructor creates an opaque color from the specified red, green, and blue values. A is set to 255. The four-component constructor creates a color using the specified alpha, red, green, and blue values. The copy constructor creates a new WLColor containing the same ARGB component values as c.
Gets or sets the alpha component of the color. A value of 0 is fully transparent, while 255 is fully opaque.
Gets or sets the blue component of the color. Values range from 0 to 255.
Returns a new, brighter version of the color. Each RGB component is increased by 20, up to a maximum of 255. The original alpha component is retained. If min is supplied, WealthLab continues brightening the result until its Brightness reaches at least the specified value, or until the method has made its maximum number of additional attempts. The original WLColor is not modified.
Returns the perceived brightness of the color as a value approximately ranging from 0.0 for black to 1.0 for white. Brightness is calculated using weighted RGB components:
Sqrt(
R² × 0.241 +
G² × 0.691 +
B² × 0.068
) / 255
The alpha component does not affect Brightness.
Returns a new, darker version of the color. Each RGB component is multiplied by 0.8. The original alpha component is retained. If max is supplied, WealthLab continues darkening the result until its Brightness is no greater than the specified value, or until the method has made its maximum number of additional attempts. The original WLColor is not modified.
Returns true if obj is a WLColor with the same alpha, red, green, and blue component values.
Gets or sets the green component of the color. Values range from 0 to 255.
Returns a hash code for the WLColor. WLColor instances having identical ARGB component values produce equivalent hash codes.
Returns a new WLColor using the same red, green, and blue components but with the specified alpha component. For example:
WLColor translucentRed = WLColor.Red.MakeTransparent(128);
Gets or sets the red component of the color. Values range from 0 to 255.
Returns a new WLColor using the same red, green, and blue components but with its alpha component set to a. The original WLColor is not modified.
Returns the WLColor as a comma-separated ARGB string:
A,R,G,B
For example:
255,255,0,0
represents opaque red. The resulting string can be restored using Parse.
Compares two WLColor instances by their ARGB component values. Two WLColor instances are considered equal when their A, R, G, and B properties are equal. The operators also correctly handle null references.
Returns a WLColor whose alpha, red, green, and blue components are all zero. Equivalent to:
new WLColor(0, 0, 0, 0)
Returns a fully transparent black WLColor. Equivalent to:
new WLColor(0, 0, 0, 0)
Creates a WLColor from ARGB component values. The second overload uses the red, green, and blue components of baseColor while replacing its alpha component with a. These methods provide an API similar to the corresponding System.Drawing.Color methods.
Creates an opaque WLColor using the specified red, green, and blue components. The alpha component is set to 255.
Returns a pseudo-random opaque color. The red, green, and blue components are each generated in the range 0 through 255.
Creates a WLColor from a string containing its alpha, red, green, and blue components. The standard format, as generated by ToString, is:
A,R,G,B
For compatibility, Parse also accepts pipe-separated values:
A|R|G|B
An ArgumentException is thrown if the string does not contain exactly four components.