Table of Contents

Class Color

Namespace
Alternet.Drawing
Assembly
Alternet.UI.Common.dll

Represents an ARGB (alpha, red, green, blue) color.

[Serializable]
[TypeConverter(typeof(ColorConverter))]
public class Color : IEquatable<Color>
Inheritance
Color
Implements

Remarks

Named colors are represented by using the properties of the Color structure.

The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). Each of the four components is a number from 0 through 255, with 0 representing no intensity and 255 representing full intensity. The alpha component specifies the transparency of the color: 0 is fully transparent, and 255 is fully opaque. To determine the alpha, red, green, or blue component of a color, use the A, R, G, or B property, respectively. You can create a custom color by using one of the FromArgb(int) method.

Constructors

Color()

Initializes a new instance of the Color class.

Color(ColorStruct)

Initializes a new instance of the Color class from the ColorStruct.

Color(KnownColor)

Initializes a new instance of the Color class from the KnownColor.

Color(KnownSystemColor)

Initializes a new instance of the Color class from the KnownSystemColor.

Color(byte, byte, byte)

Initializes a new instance of the Color class with the specified parameters.

Color(byte, byte, byte, byte)

Initializes a new instance of the Color class with the specified parameters.

Fields

ARGBAlphaMask

Bit mask for Alpha component of the color.

ARGBAlphaShift

Shift count for Alpha component of the color.

ARGBBlueMask

Bit mask for Blue component of the color.

ARGBBlueShift

Shift count for Blue component of the color.

ARGBGreenMask

Bit mask for Green component of the color.

ARGBGreenShift

Shift count for Green component of the color.

ARGBRedMask

Bit mask for Red component of the color.

ARGBRedShift

Shift count for Red component of the color.

AliceBlue

Gets a system-defined color.

AntiqueWhite

Gets a system-defined color.

Aqua

Gets a system-defined color.

Aquamarine

Gets a system-defined color.

Azure

Gets a system-defined color.

Beige

Gets a system-defined color.

Bisque

Gets a system-defined color.

Black

Gets a system-defined color.

BlanchedAlmond

Gets a system-defined color.

Blue

Gets a system-defined color.

BlueViolet

Gets a system-defined color.

Brown

Gets a system-defined color.

BurlyWood

Gets a system-defined color.

CadetBlue

Gets a system-defined color.

Chartreuse

Gets a system-defined color.

Chocolate

Gets a system-defined color.

Coral

Gets a system-defined color.

CornflowerBlue

Gets a system-defined color.

Cornsilk

Gets a system-defined color.

Crimson

Gets a system-defined color.

Cyan

Gets a system-defined color.

DarkBlue

Gets a system-defined color.

DarkCyan

Gets a system-defined color.

DarkGoldenrod

Gets a system-defined color.

DarkGray

Gets a system-defined color.

DarkGreen

Gets a system-defined color.

DarkKhaki

Gets a system-defined color.

DarkMagenta

Gets a system-defined color.

DarkOliveGreen

Gets a system-defined color.

DarkOrange

Gets a system-defined color.

DarkOrchid

Gets a system-defined color.

DarkRed

Gets a system-defined color.

DarkSalmon

Gets a system-defined color.

DarkSeaGreen

Gets a system-defined color.

DarkSlateBlue

Gets a system-defined color.

DarkSlateGray

Gets a system-defined color.

DarkTurquoise

Gets a system-defined color.

DarkViolet

Gets a system-defined color.

DeepPink

Gets a system-defined color.

DeepSkyBlue

Gets a system-defined color.

DimGray

Gets a system-defined color.

DodgerBlue

Gets a system-defined color.

Empty

Represents an empty color.

Firebrick

Gets a system-defined color.

FloralWhite

Gets a system-defined color.

ForestGreen

Gets a system-defined color.

Fuchsia

Gets a system-defined color.

Gainsboro

Gets a system-defined color.

GhostWhite

Gets a system-defined color.

Gold

Gets a system-defined color.

Goldenrod

Gets a system-defined color.

Gray

Gets a system-defined color.

Green

Gets a system-defined color.

GreenYellow

Gets a system-defined color.

Honeydew

Gets a system-defined color.

HotPink

Gets a system-defined color.

IndianRed

Gets a system-defined color.

Indigo

Gets a system-defined color.

Ivory

Gets a system-defined color.

Khaki

Gets a system-defined color.

Lavender

Gets a system-defined color.

LavenderBlush

Gets a system-defined color.

LawnGreen

Gets a system-defined color.

LemonChiffon

Gets a system-defined color.

LightBlue

Gets a system-defined color.

LightCoral

Gets a system-defined color.

LightCyan

Gets a system-defined color.

LightGoldenrodYellow

Gets a system-defined color.

LightGray

Gets a system-defined color.

LightGreen

Gets a system-defined color.

LightPink

Gets a system-defined color.

LightSalmon

Gets a system-defined color.

LightSeaGreen

Gets a system-defined color.

LightSkyBlue

Gets a system-defined color.

LightSlateGray

Gets a system-defined color.

LightSteelBlue

Gets a system-defined color.

LightYellow

Gets a system-defined color.

Lime

Gets a system-defined color.

LimeGreen

Gets a system-defined color.

Linen

Gets a system-defined color.

Magenta

Gets a system-defined color.

Maroon

Gets a system-defined color.

MediumAquamarine

Gets a system-defined color.

MediumBlue

Gets a system-defined color.

MediumOrchid

Gets a system-defined color.

MediumPurple

Gets a system-defined color.

MediumSeaGreen

Gets a system-defined color.

MediumSlateBlue

Gets a system-defined color.

MediumSpringGreen

Gets a system-defined color.

MediumTurquoise

Gets a system-defined color.

MediumVioletRed

Gets a system-defined color.

MidnightBlue

Gets a system-defined color.

MintCream

Gets a system-defined color.

MistyRose

Gets a system-defined color.

Moccasin

Gets a system-defined color.

NavajoWhite

Gets a system-defined color.

Navy

Gets a system-defined color.

OldLace

Gets a system-defined color.

Olive

Gets a system-defined color.

OliveDrab

Gets a system-defined color.

Orange

Gets a system-defined color.

OrangeRed

Gets a system-defined color.

Orchid

Gets a system-defined color.

PaleGoldenrod

Gets a system-defined color.

PaleGreen

Gets a system-defined color.

PaleTurquoise

Gets a system-defined color.

PaleVioletRed

Gets a system-defined color.

PapayaWhip

Gets a system-defined color.

PeachPuff

Gets a system-defined color.

Peru

Gets a system-defined color.

Pink

Gets a system-defined color.

Plum

Gets a system-defined color.

PowderBlue

Gets a system-defined color.

Purple

Gets a system-defined color.

RebeccaPurple

Gets a system-defined color.

Red

Gets a system-defined color.

RosyBrown

Gets a system-defined color.

RoyalBlue

Gets a system-defined color.

SaddleBrown

Gets a system-defined color.

Salmon

Gets a system-defined color.

SandyBrown

Gets a system-defined color.

SeaGreen

Gets a system-defined color.

SeaShell

Gets a system-defined color.

Sienna

Gets a system-defined color.

Silver

Gets a system-defined color.

SkyBlue

Gets a system-defined color.

SlateBlue

Gets a system-defined color.

SlateGray

Gets a system-defined color.

Snow

Gets a system-defined color.

SpringGreen

Gets a system-defined color.

SteelBlue

Gets a system-defined color.

Tan

Gets a system-defined color.

Teal

Gets a system-defined color.

Thistle

Gets a system-defined color.

Tomato

Gets a system-defined color.

Transparent

Gets a system-defined color.

Turquoise

Gets a system-defined color.

Violet

Gets a system-defined color.

Wheat

Gets a system-defined color.

White

Gets a system-defined color.

WhiteSmoke

Gets a system-defined color.

Yellow

Gets a system-defined color.

YellowGreen

Gets a system-defined color.

Properties

A

Gets the alpha component value of this Color structure.

AHex

Gets A as hex string.

ARGBWeb

If color is opaque returns RGBWeb; otherwise returns "rgba({R},{G},{B}, {alpha})" string.

AsBrush

Creates SolidBrush instance for this color.

AsFillPaint

Gets SKPaint for this color with Fill style.

AsPen

Creates Pen instance for this color.

AsStrokeAndFillPaint

Gets SKPaint for this color with Fill style.

AsStrokePaint

Gets SKPaint for this color with Stroke style.

AsStruct

Gets this color as ColorStruct.

B

Gets the blue component value of this Color structure.

BHex

Gets B as hex string.

G

Gets the green component value of this Color structure.

GHex

Gets G as hex string.

IsBlack

Gets true if this color is black.

IsEmpty

Specifies whether this Color structure is uninitialized.

IsKnownColor

Gets a value indicating whether this Color structure is a predefined color. Predefined colors are represented by the elements of the KnownColor enumeration.

IsNamedColor

Gets a value indicating whether this Color structure is a named color or a member of the KnownColor enumeration.

IsOk

Specifies whether this Color structure is initialized.

IsOpaque

Returns true if color is opaque (A is 255).

IsSystemColor

Gets a value indicating whether this Color structure is a system color. A system color is a color that is used in a Windows display element. System colors are represented by elements of the KnownColor enumeration.

Name

Gets the name of this Color.

NameAndARGBValue

Gets color name and ARGB for the debug purposes.

R

Gets the red component value of this Color structure.

RGBHex

Gets RGB as hex string in the format #RRGGBB.

RGBWeb

Gets RGB as web string in the format "rgb({R},{G},{B})". Fo example for the black color it will return "rgb(0,0,0)".

RHex

Gets R as hex string.

SkiaColor

Gets this color as SKColor.

State

Gets state flags of this object.

Methods

AlphaBlend(byte, byte, double)

Used by ChangeLightness(int) and MakeDisabled(ref RGBValue, byte).

AsImage(SizeI)

Creates GenericImage of the specified size filled with this color.

AsUInt()

Gets the 32-bit ARGB value of this Color structure.

ChangeLightness(ref RGBValue, int)

Darkens or lightens a color, based on the specified percentage ialpha of 0 would be completely black, 200 completely white an ialpha of 100 returns the same color.

ChangeLightness(int)

Darkens or lightens a color, based on the specified percentage ialpha of 0 would be completely black, 200 completely white an ialpha of 100 returns the same color.

EqualARGB(Color)

Indicates whether ARGB of this color is equal to ARGB of another color.

Equals(Color?)

Indicates whether the current object is equal to another object of the same type.

Equals(object?)

Determines whether the specified object is equal to the current object.

FromArgb(byte, Color)

Creates a Color structure from the specified Color structure, but with the new specified alpha value. Although this method allows a 32-bit value to be passed for the alpha value, the value is limited to 8 bits.

FromArgb(byte, RGBValue)

Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values.

FromArgb(byte, byte, byte)

Creates a Color structure from the specified 8-bit color values (red, green, and blue). The alpha value is implicitly 255 (fully opaque). Although this method allows a 32-bit value to be passed for each color component, the value of each component is limited to 8 bits.

FromArgb(byte, byte, byte, byte)

Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values.

FromArgb(int)

Creates a Color structure from a 32-bit ARGB value.

FromArgb(int, int, int)

Creates a Color structure from the three RGB component (red, green, and blue) values. Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits.

FromArgb(int, int, int, int)

Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values. Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits.

FromKnownColor(KnownColor)

Creates a Color structure from the specified predefined color.

FromName(string)

Creates a Color structure from the specified name of a predefined color.

FromRgb(byte, byte, byte)

Creates an opaque Color structure from the four ARGB components (255, red, green, and blue) values.

GetArgbValues(out byte, out byte, out byte, out byte)

Returns ARGB values of the Color

GetAsPen(double)

Gets this color as Pen with the specified width.

GetAsPen(double, DashStyle)

Gets this color as Pen with the specified width and DashStyle.

GetBrightness()

Gets the hue-saturation-lightness (HSL) lightness value for this Color structure.

GetHashCode()

Serves as the default hash function.

GetHue()

Gets the hue-saturation-lightness (HSL) hue value, in degrees, for this Color structure.

GetKnownColors()

Enumerates colors defined in KnownColor.

GetKnownColors(params KnownColorCategory[])

Enumerates colors defined in KnownColor for the specified color categories.

GetLuminance()

Returns the perceived brightness of the color, with 0 for black and 1 for white.

GetRgbValues(out byte, out byte, out byte)

Returns RGB values of the Color

GetSaturation()

Gets the hue-saturation-lightness (HSL) saturation value for this Color structure.

HSVtoRGB(HSVValue)

Converts HSVValue to RGB color.

IsDark()

Gets whether color is dark.

MakeDisabled(ref RGBValue, byte)

Sets a disabled (dimmed) color for specified RGBValue.

MakeDisabled(byte)

Makes a disabled version of this color.

MakeGray(ref RGBValue)

Makes color gray using integer arithmetic.

MakeGrey(ref RGBValue, double, double, double)

Creates a grey color from rgb parameters using floating point arithmetic.

MakeMono(ref RGBValue, bool)

Assigns the same value to RGB of the color: 0 if on is false, 255 otherwise.

MinMaxRgb(out byte, out byte)

Calculates minimal and maximal values from all RGB color components.

MinMaxRgb(out byte, out byte, byte, byte, byte)

Calculates minimal and maximal values from r, g, b parameters.

Parse(ITypeDescriptorContext?, CultureInfo?, string?)

Converts string to Color.

Parse(string?)

Returns a color from the specified string.

RGBtoHSV(RGBValue)

Converts RGB color to HSVValue.

ToArgb()

Gets the 32-bit ARGB value of this Color structure.

ToDebugString()

Gets color properties for the debug purposes.

ToDisplayString()

Converts this color to display string.

ToKnownColor()

Gets the KnownColor value of this Color structure.

ToString()

Converts this Color structure to a human-readable string.

WithAlpha(byte)

Returns a new color based on this current instance, but with the new alpha channel value.

WithBlue(byte)

Returns a new color based on this current instance, but with the new blue channel value.

WithGreen(byte)

Returns a new color based on this current instance, but with the new green channel value.

WithRed(byte)

Returns a new color based on this current instance, but with the new red channel value.

Events

ColorToDisplayString

Occurs when string is converted to Color.

ColorToString

Occurs when string is converted to Color.

StringToColor

Occurs when string is converted to Color.

Operators

operator ==(Color?, Color?)

Tests whether two specified Color structures are equivalent.

operator ==(Color, Color)

Tests whether Color and Color structures are equivalent.

operator ==(Color, Color)

Tests whether Color and Color structures are equivalent.

explicit operator Brush(Color)

Converts the specified Color to a Brush.

explicit operator Pen(Color)

Converts the specified Color to a Pen.

explicit operator SolidBrush(Color)

Converts the specified RGBValue to a Color.

explicit operator Color(string)

Converts the specified string to a Color.

implicit operator RGBValue(Color)

Converts the specified Color to a RGBValue.

implicit operator SKColor(Color)

Converts the specified Color to a SKColor.

implicit operator Color(Color)

Converts the specified Color to a Color.

implicit operator Color(RGBValue)

Converts the specified RGBValue to a Color.

implicit operator Color(SKColor)

Converts the specified SKColor to a Color.

implicit operator Color(Color)

Converts the specified Color to a Color.

implicit operator Color((byte, byte, byte, byte))

Implicit operator convertion from tuple with four byte values to Color. Tuple values define ARGB of the color.

implicit operator Color((byte, byte, byte))

Implicit operator convertion from tuple with three byte values to Color. Tuple values define RGB of the color.

operator !=(Color?, Color?)

Tests whether two specified Color structures are different.

operator !=(Color, Color)

Tests whether Color and Color structures are different.

operator !=(Color, Color)

Tests whether Color and Color structures are different.