Color Class

Color class

The Color class lets you specify colors as Red-Green-Blue (RGB) values, Hue-Saturation-Luminosity (HSL) values, Hue-Saturation-Value (HSV) values, Hue-Whiteness-Blackness (HWB) values, lightness-A-B (LAB) values, Luminance-Chroma-Hue (LCH) values, Cyan-Magenta-Yellow-Key (CMYK) values, Natural colors (NCOL) values, or with a color name. An Alpha channel is also available to indicate transparency.

public class Color

Constructors

NameDescription
Color()Initializes a new instance of the Color class. By default color is black.
Color(byte, byte, byte)Initializes a new instance of the Color class. All color components must be in the range 0-255.
Color(float, float, float)Initializes a new instance of the Color class. All color components must be in the range 0-1.
Color(int, int, int)Initializes a new instance of the Color class. All color components must be in the range 0-255.
Color(byte, byte, byte, byte)Initializes a new instance of the Color class. All color components must be in the range 0-255.
Color(float, float, float, float)Initializes a new instance of the Color class. All color components must be in the range 0-1.
Color(int, int, int, int)Initializes a new instance of the Color class. All color components must be in the range 0-255.

Properties

NameDescription
Alpha { get; }Represents the alpha component of the color.
Blue { get; }Represents the blue component of the color.
Green { get; }Represents the green component of the color.
Red { get; }Represents the red component of the color

Methods

NameDescription
static FromCmyk(float, float, float, float)Returns a new Color with the requested cyan, magenta, yellow, key (black) values.
static FromCmyka(float, float, float, float, float)Returns a new Color with the requested cyan, magenta, yellow, key (black), alpha values.
static FromGray(float)Returns a new Color with the requested gray value.
static FromHsl(float, float, float)Returns a new Color with the requested hue, saturation, saturation values.
static FromHsla(float, float, float, float)Returns a new Color with the requested hue, saturation, saturation, alpha values.
static FromHsv(float, float, float)Returns a new Color with the requested hue, saturation, value.
static FromHsva(float, float, float, float)Returns a new Color with the requested hue, saturation, value, alpha.
static FromHwb(float, float, float)Returns a new Color with the requested hue, whiteness, blackness values.
static FromHwba(float, float, float, float)Returns a new Color with the requested hue, whiteness, blackness values.
static FromInt(int)Returns a new Color with the requested ARGB value.
static FromLab(float, float, float)Returns a new Color with the requested lightness, A, B values.
static FromLaba(float, float, float, float)Returns a new Color with the requested lightness, A, B, alpha values.
static FromLch(float, float, float)Returns a new Color with the requested luminance, chroma, hue values.
static FromLcha(float, float, float, float)Returns a new Color with the requested luminance, chroma, hue, alpha values.
static FromOklab(float, float, float)Returns a new Color with the requested lightness, A, B values for OKLAB model.
static FromOklaba(float, float, float, float)Returns a new Color with the requested lightness, A, B, alpha values for OKLAB model.
static FromOklch(float, float, float)Returns a new Color with the requested luminance, chroma, hue values for OKLAB model.
static FromOklcha(float, float, float, float)Returns a new Color with the requested luminance, chroma, hue, alpha values for OKLAB model.
static FromRgb(byte, byte, byte)Returns a new Color with the requested ged, green, blue values. All color components must be in the range 0-255.
static FromRgb(float, float, float)Returns a new Color with the requested ged, green, blue values. All color components must be in the range 0-1.
static FromRgb(int, int, int)Returns a new Color with the requested ged, green, blue values. All color components must be in the range 0-255.
static FromRgba(byte, byte, byte, byte)Returns a new Color with the requested ged, green, blue, alpha values. All color components must be in the range 0-255.
static FromRgba(float, float, float, float)Returns a new Color with the requested ged, green, blue, alpha values. All color components must be in the range 0-1.
static FromRgba(int, int, int, int)Returns a new Color with the requested ged, green, blue, alpha values. All color components must be in the range 0-255.
static FromString(string)Parses string containing the CSS color and returns a new Color.
static FromUint(uint)Returns a new Color with the requested ARGB value.
AddLuminosity(float)Creates copy of the Color with Sum of its luminosity and the delta value.
Convert(ColorModel)Returns a color components in the format of the specified color model.
override Equals(object)Determines whether the specified Color is equal to this instance.
GetComplementary()Returns a new color that is on the opposite side of the color wheel from the original.
override GetHashCode()Returns a hash code.
GetHue()Returns a Hue of the Color.
GetLuminosity()Returns a luminosity of the Color.
GetSaturation()Returns a saturation of the Color.
ToInt()Encodes the Color ARGB components into int.
ToName()Returns the name of the color if it matches a color in the list of CSS named colors, or an empty string.
ToNaturalColorString(int)Returns a Natural colors (NCol) specified color using a color letter with a number to specify the distance (in percent) from the color.
ToRgbaHexString()Returns a Hexadecimal color is specified with: #RRGGBBAA.
ToRgbaString()Returns a string containing the RGBA color specified by: rgba(R, G, B, A).
ToRgbHexString()Returns a hexadecimal color is specified with: #RRGGBB.
ToRgbString()Returns a string containing the RGB color specified by: rgb(R, G, B).
override ToString()Returns a string that consists of the RGBA component values.
ToUint()Encodes the Color ARGB components into unsigned int.
WithAlpha(float)Creates copy of the Color with specified alpha component.
WithHue(float)Creates copy of the Color with specified Hue.
WithLuminosity(float)Creates copy of the Color with specified luminosity.
WithSaturation(float)Creates copy of the Color with specified saturation.

See Also