Color Color Struct

Definition

Class that represents a color and exposes it as RGBA and HSL values.

[System.Diagnostics.DebuggerDisplay("R={R}, G={G}, B={B}, A={A}, Hue={Hue}, Saturation={Saturation}, Luminosity={Luminosity}")]
[Xamarin.Forms.TypeConverter(typeof(Xamarin.Forms.ColorTypeConverter))]
public struct Color
type Color = struct
Inheritance
ColorColor
Attributes

Remarks

This type is immutable. Colors can be expressed in the RGB or HSL modes. While the Color(Double, Double, Double) constructor takes R, G, B, and A values, the Color class also calculates and makes available HSL data for the color.

In XAML, application developers can specify any property that is of type Color, for example, TextColor either as a XAML attribute or as a nested tag. The following code example shows how to specify the text color for a label by using an attribute:


<Label VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" TextColor="Green">
    <Label.Text>Hello, World!</Label.Text>
</Label>

The example below shows how to specify the text color for a label by using a nested tag:


<Label VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
    <Label.Text>Hello, World!</Label.Text>
    <Label.TextColor>Color.Blue</Label.TextColor>
</Label>

Application developers can specify colors in XAML either as a hexadecimal number or as a valid color name.

When specifying a color with a hexadecimal number, app developers can use 3, 4, or 6 digits. If the developer specifies 3 digits, they are interpreted as RGB doublet data for a fully opaque color. For example, "#123" specifies the color that is represented by "#FF112233". If the developer provides a 4-digit hexadecimal number, then the data are interpreted as above, except that the first digit specifies the alpha channel. For example, "#1234" specifies the color that is represented by "#11223344". Finally, if the developer provides a 6 digit hexadecimal number, the data are interpreted as a fully opaque color with those RGB values. For example, "#112233" specifies the color that is represented by "#FF112233".

When specifying a color with a string, app developers can use color name in isolation, or prefix it with "Color.". For example, both Purple and Color.Purple are valid ways to specify the color purple.

Constructors

Color(Double) Color(Double)

Initialize a new gray color.

Color(Double, Double, Double) Color(Double, Double, Double)

Initializes a new RGB color.

Color(Double, Double, Double, Double) Color(Double, Double, Double, Double)

Initializes a new RGB color with an alpha channel.

Fields

AliceBlue AliceBlue

AliceBlue, the color that is represented by the RGB value #FFF0F8FF.

AntiqueWhite AntiqueWhite

AntiqueWhite, the color that is represented by the RGB value #FFFAEBD7.

Aqua Aqua

Aqua, the color that is represented by the RGB value #00ffff.

Aquamarine Aquamarine

Aquamarine, the color that is represented by the RGB value #FF7FFFD4.

Azure Azure

Azure, the color that is represented by the RGB value #FFF0FFFF.

Beige Beige

Beige, the color that is represented by the RGB value #FFF5F5DC.

Bisque Bisque

Bisque, the color that is represented by the RGB value #FFFFE4C4.

Black Black

Black, the color that is represented by the RGB value #000000.

BlanchedAlmond BlanchedAlmond

BlanchedAlmond, the color that is represented by the RGB value #FFFFEBCD.

Blue Blue

Blue, the color that is represented by the RGB value #0000ff.

BlueViolet BlueViolet

BlueViolet, the color that is represented by the RGB value #FF8A2BE2.

Brown Brown

Brown, the color that is represented by the RGB value #FFA52A2A.

BurlyWood BurlyWood

BurlyWood, the color that is represented by the RGB value #FFDEB887.

CadetBlue CadetBlue

CadetBlue, the color that is represented by the RGB value #FF5F9EA0.

Chartreuse Chartreuse

Chartreuse, the color that is represented by the RGB value #FF7FFF00.

Chocolate Chocolate

Chocolate, the color that is represented by the RGB value #FFD2691E.

Coral Coral

Coral, the color that is represented by the RGB value #FFFF7F50.

CornflowerBlue CornflowerBlue

CornflowerBlue, the color that is represented by the RGB value #FF6495ED.

Cornsilk Cornsilk

Cornsilk, the color that is represented by the RGB value #FFFFF8DC.

Crimson Crimson

Crimson, the color that is represented by the RGB value #FFDC143C.

Cyan Cyan

Cyan, the color that is represented by the RGB value #FF00FFFF.

DarkBlue DarkBlue

DarkBlue, the color that is represented by the RGB value #FF00008B.

DarkCyan DarkCyan

DarkCyan, the color that is represented by the RGB value #FF008B8B.

DarkGoldenrod DarkGoldenrod

DarkGoldenrod, the color that is represented by the RGB value #FFB8860B.

DarkGray DarkGray

DarkGray, the color that is represented by the RGB value #FFA9A9A9.

DarkGreen DarkGreen

DarkGreen, the color that is represented by the RGB value #FF006400.

DarkKhaki DarkKhaki

DarkKhaki, the color that is represented by the RGB value #FFBDB76B.

DarkMagenta DarkMagenta

DarkMagenta, the color that is represented by the RGB value #FF8B008B.

DarkOliveGreen DarkOliveGreen

DarkOliveGreen, the color that is represented by the RGB value #FF556B2F.

DarkOrange DarkOrange

DarkOrange, the color that is represented by the RGB value #FFFF8C00.

DarkOrchid DarkOrchid

DarkOrchid, the color that is represented by the RGB value #FF9932CC.

DarkRed DarkRed

DarkRed, the color that is represented by the RGB value #FF8B0000.

DarkSalmon DarkSalmon

DarkSalmon, the color that is represented by the RGB value #FFE9967A.

DarkSeaGreen DarkSeaGreen

DarkSeaGreen, the color that is represented by the RGB value #FF8FBC8F.

DarkSlateBlue DarkSlateBlue

DarkSlateBlue, the color that is represented by the RGB value #FF483D8B.

DarkSlateGray DarkSlateGray

DarkSlateGray, the color that is represented by the RGB value #FF2F4F4F.

DarkTurquoise DarkTurquoise

DarkTurquoise, the color that is represented by the RGB value #FF00CED1.

DarkViolet DarkViolet

DarkViolet, the color that is represented by the RGB value #FF9400D3.

DeepPink DeepPink

DeepPink, the color that is represented by the RGB value #FFFF1493.

DeepSkyBlue DeepSkyBlue

DeepSkyBlue, the color that is represented by the RGB value #FF00BFFF.

DimGray DimGray

DimGray, the color that is represented by the RGB value #FF696969.

DodgerBlue DodgerBlue

DodgerBlue, the color that is represented by the RGB value #FF1E90FF.

Firebrick Firebrick

Firebrick, the color that is represented by the RGB value #FFB22222.

FloralWhite FloralWhite

FloralWhite, the color that is represented by the RGB value #FFFFFAF0.

ForestGreen ForestGreen

ForestGreen, the color that is represented by the RGB value #FF228B22.

Fuchsia Fuchsia

Fucshia, the color that is represented by the RGB value #ff00ff.

Fuschia Fuschia

Fucshia, the color that is represented by the RGB value #ff00ff. Deprecated. See Remarks.

Gainsboro Gainsboro

Gainsboro, the color that is represented by the RGB value #FFDCDCDC.

GhostWhite GhostWhite

GhostWhite, the color that is represented by the RGB value #FFF8F8FF.

Gold Gold

Gold, the color that is represented by the RGB value #FFFFD700.

Goldenrod Goldenrod

Goldenrod, the color that is represented by the RGB value #FFDAA520.

Gray Gray

Gray, the color that is represented by the RGB value #808080.

Green Green

Green, the color that is represented by the RGB value #008000.

GreenYellow GreenYellow

GreenYellow, the color that is represented by the RGB value #FFADFF2F.

Honeydew Honeydew

Honeydew, the color that is represented by the RGB value #FFF0FFF0.

HotPink HotPink

HotPink, the color that is represented by the RGB value #FFFF69B4.

IndianRed IndianRed

IndianRed, the color that is represented by the RGB value #FFCD5C5C.

Indigo Indigo

Indigo, the color that is represented by the RGB value #FF4B0082.

Ivory Ivory

Ivory, the color that is represented by the RGB value #FFFFFFF0.

Khaki Khaki

Khaki, the color that is represented by the RGB value #FFF0E68C.

Lavender Lavender

Lavender, the color that is represented by the RGB value #FFE6E6FA.

LavenderBlush LavenderBlush

LavenderBlush, the color that is represented by the RGB value #FFFFF0F5.

LawnGreen LawnGreen

LawnGreen, the color that is represented by the RGB value #FF7CFC00.

LemonChiffon LemonChiffon

LemonChiffon, the color that is represented by the RGB value #FFFFFACD.

LightBlue LightBlue

LightBlue, the color that is represented by the RGB value #FFADD8E6.

LightCoral LightCoral

LightCoral, the color that is represented by the RGB value #FFF08080.

LightCyan LightCyan

LightCyan, the color that is represented by the RGB value #FFE0FFFF.

LightGoldenrodYellow LightGoldenrodYellow

LightGoldenrodYellow, the color that is represented by the RGB value #FFFAFAD2.

LightGray LightGray

LightGray, the color that is represented by the RGB value #FFD3D3D3.

LightGreen LightGreen

LightGreen, the color that is represented by the RGB value #FF90EE90.

LightPink LightPink

LightPink, the color that is represented by the RGB value #FFFFB6C1.

LightSalmon LightSalmon

LightSalmon, the color that is represented by the RGB value #FFFFA07A.

LightSeaGreen LightSeaGreen

LightSeaGreen, the color that is represented by the RGB value #FF20B2AA.

LightSkyBlue LightSkyBlue

LightSkyBlue, the color that is represented by the RGB value #FF87CEFA.

LightSlateGray LightSlateGray

LightSlateGray, the color that is represented by the RGB value #FF778899.

LightSteelBlue LightSteelBlue

LightSteelBlue, the color that is represented by the RGB value #FFB0C4DE.

LightYellow LightYellow

LightYellow, the color that is represented by the RGB value #FFFFFFE0.

Lime Lime

Lime, the color that is represented by the RGB value #00ff00.

LimeGreen LimeGreen

LimeGreen, the color that is represented by the RGB value #FF32CD32.

Linen Linen

Linen, the color that is represented by the RGB value #FFFAF0E6.

Magenta Magenta

Magenta, the color that is represented by the RGB value #FFFF00FF.

Maroon Maroon

Maroon, the color that is represented by the RGB value #800000.

MediumAquamarine MediumAquamarine

MediumAquamarine, the color that is represented by the RGB value #FF66CDAA.

MediumBlue MediumBlue

MediumBlue, the color that is represented by the RGB value #FF0000CD.

MediumOrchid MediumOrchid

MediumOrchid, the color that is represented by the RGB value #FFBA55D3.

MediumPurple MediumPurple

MediumPurple, the color that is represented by the RGB value #FF9370DB.

MediumSeaGreen MediumSeaGreen

MediumSeaGreen, the color that is represented by the RGB value #FF3CB371.

MediumSlateBlue MediumSlateBlue

MediumSlateBlue, the color that is represented by the RGB value #FF7B68EE.

MediumSpringGreen MediumSpringGreen

MediumSpringGreen, the color that is represented by the RGB value #FF00FA9A.

MediumTurquoise MediumTurquoise

MediumTurquoise, the color that is represented by the RGB value #FF48D1CC.

MediumVioletRed MediumVioletRed

MediumVioletRed, the color that is represented by the RGB value #FFC71585.

MidnightBlue MidnightBlue

MidnightBlue, the color that is represented by the RGB value #FF191970.

MintCream MintCream

MintCream, the color that is represented by the RGB value #FFF5FFFA.

MistyRose MistyRose

MistyRose, the color that is represented by the RGB value #FFFFE4E1.

Moccasin Moccasin

Moccasin, the color that is represented by the RGB value #FFFFE4B5.

NavajoWhite NavajoWhite

NavajoWhite, the color that is represented by the RGB value #FFFFDEAD.

Navy Navy

Navy, the color that is represented by the RGB value #000080.

OldLace OldLace

OldLace, the color that is represented by the RGB value #FFFDF5E6.

Olive Olive

Olive, the color that is represented by the RGB value #808000.

OliveDrab OliveDrab

OliveDrab, the color that is represented by the RGB value #FF6B8E23.

Orange Orange

Orange, the color that is represented by the RGB value #ffa500.

OrangeRed OrangeRed

OrangeRed, the color that is represented by the RGB value #FFFF4500.

Orchid Orchid

Orchid, the color that is represented by the RGB value #FFDA70D6.

PaleGoldenrod PaleGoldenrod

PaleGoldenrod, the color that is represented by the RGB value #FFEEE8AA.

PaleGreen PaleGreen

PaleGreen, the color that is represented by the RGB value #FF98FB98.

PaleTurquoise PaleTurquoise

PaleTurquoise, the color that is represented by the RGB value #FFAFEEEE.

PaleVioletRed PaleVioletRed

PaleVioletRed, the color that is represented by the RGB value #FFDB7093.

PapayaWhip PapayaWhip

PapayaWhip, the color that is represented by the RGB value #FFFFEFD5.

PeachPuff PeachPuff

PeachPuff, the color that is represented by the RGB value #FFFFDAB9.

Peru Peru

Peru, the color that is represented by the RGB value #FFCD853F.

Pink Pink

Pink, the color that is represented by the RGB value #ff66ff.

Plum Plum

Plum, the color that is represented by the RGB value #FFDDA0DD.

PowderBlue PowderBlue

PowderBlue, the color that is represented by the RGB value #FFB0E0E6.

Purple Purple

Purple, the color that is represented by the RGB value #800080.

Red Red

Red, the color that is represented by the RGB value #ff0000.

RosyBrown RosyBrown

RosyBrown, the color that is represented by the RGB value #FFBC8F8F.

RoyalBlue RoyalBlue

RoyalBlue, the color that is represented by the RGB value #FF4169E1.

SaddleBrown SaddleBrown

SaddleBrown, the color that is represented by the RGB value #FF8B4513.

Salmon Salmon

Salmon, the color that is represented by the RGB value #FFFA8072.

SandyBrown SandyBrown

SandyBrown, the color that is represented by the RGB value #FFF4A460.

SeaGreen SeaGreen

SeaGreen, the color that is represented by the RGB value #FF2E8B57.

SeaShell SeaShell

SeaShell, the color that is represented by the RGB value #FFFFF5EE.

Sienna Sienna

Sienna, the color that is represented by the RGB value #FFA0522D.

Silver Silver

Silver, the color that is represented by the RGB value #c0c0c0.

SkyBlue SkyBlue

SkyBlue, the color that is represented by the RGB value #FF87CEEB.

SlateBlue SlateBlue

SlateBlue, the color that is represented by the RGB value #FF6A5ACD.

SlateGray SlateGray

SlateGray, the color that is represented by the RGB value #FF708090.

Snow Snow

Snow, the color that is represented by the RGB value #FFFFFAFA.

SpringGreen SpringGreen

SpringGreen, the color that is represented by the RGB value #FF00FF7F.

SteelBlue SteelBlue

SteelBlue, the color that is represented by the RGB value #FF4682B4.

Tan Tan

Tan, the color that is represented by the RGB value #FFD2B48C.

Teal Teal

Teal, the color that is represented by the RGB value #008080.

Thistle Thistle

Thistle, the color that is represented by the RGB value #FFD8BFD8.

Tomato Tomato

Tomato, the color that is represented by the RGB value #FFFF6347.

Transparent Transparent

The transparent color, represented by the RGB value #ffffff00.

Turquoise Turquoise

Turquoise, the color that is represented by the RGB value #FF40E0D0.

Violet Violet

Violet, the color that is represented by the RGB value #FFEE82EE.

Wheat Wheat

Wheat, the color that is represented by the RGB value #FFF5DEB3.

White White

White, the color that is represented by the RGB value #ffffff.

WhiteSmoke WhiteSmoke

WhiteSmoke, the color that is represented by the RGB value #FFF5F5F5.

Yellow Yellow

Yellow, the color that is represented by the RGB value #ffff00..

YellowGreen YellowGreen

YellowGreen, the color that is represented by the RGB value #FF9ACD32.

Properties

A A

Gets the alpha component of the color.

Accent Accent

Gets the accent or tint color from the application.

B B

Gets the blue component of the color.

Default Default

Returns the default color.

G G

Gets the Green component of the color.

Hue Hue

Gets the Hue of the color.

IsDefault IsDefault

For internal use by the Xamarin.Forms platform.

Luminosity Luminosity

Gets the Luminosity fo the color.

R R

Gets the Red component of the color.

Saturation Saturation

Gets the Saturation of the color

Methods

AddLuminosity(Double) AddLuminosity(Double)

Returns a new Color with a modified luminosity channel.

Equals(Object) Equals(Object)

Determine if the provided Object is equivalent to the current Color.

FromHex(String) FromHex(String)

Returns a new RGB Color instance with the requested Red, Green, and Blue channels. The Alpha channel is set if hex contains one.

FromHsla(Double, Double, Double, Double) FromHsla(Double, Double, Double, Double)

Returns a new HSL Color with an alpha channel

FromRgb(Double, Double, Double) FromRgb(Double, Double, Double)

Returns a new rgb color instance.

FromRgb(Int32, Int32, Int32) FromRgb(Int32, Int32, Int32)

Returns a new rgb color instance.

FromRgba(Double, Double, Double, Double) FromRgba(Double, Double, Double, Double)

Returns a new RGBA color instance.

FromRgba(Int32, Int32, Int32, Int32) FromRgba(Int32, Int32, Int32, Int32)

Returns a new RGBA color instance.

FromUint(UInt32) FromUint(UInt32)

Returns a new Color with the requested RGBA value.

GetHashCode() GetHashCode()

Returns the Hashcode for this Object.

MultiplyAlpha(Double) MultiplyAlpha(Double)

Returns a new color with the alpha channel multiplied by alpha, clamped to the inclusive range [0-1].

SetAccent(Color) SetAccent(Color)

For internal use by the Xamarin.Forms platform.

ToString() ToString()

Returns a string representation of the Color.

WithHue(Double) WithHue(Double)

Returns a color with modified Hue, but keeping the same Saturation and Luminosity.

WithLuminosity(Double) WithLuminosity(Double)

Returns a color with modified Luminosity.

WithSaturation(Double) WithSaturation(Double)

Returns a new color with modified Saturation.

Operators

Equality(Color, Color) Equality(Color, Color)

Returns true if color1 represents the same color as color1.

Implicit(Color to Color) Implicit(Color to Color)

Converts the provided color to a Color.

Implicit(Color to Color) Implicit(Color to Color)

Converts the provided color to a Color.

Inequality(Color, Color) Inequality(Color, Color)

Returns true if color1 does not represent the same color as color1.

Applies to