Struct Color
Describes a 32-bit packed color.
[DataContract]
public struct Color : IEquatable<Color>
- Implements
- Inherited Members
Constructors
Color(Color, int)
Constructs an RGBA color from a Color and an alpha value.
public Color(Color color, int alpha)
Parameters
Color(Color, float)
Constructs an RGBA color from color and alpha value.
public Color(Color color, float alpha)
Parameters
Color(Vector3)
Constructs an RGBA color from the XYZ unit length components of a vector. Alpha value will be opaque.
public Color(Vector3 color)
Parameters
Color(Vector4)
Constructs an RGBA color from the XYZW unit length components of a vector.
public Color(Vector4 color)
Parameters
Color(byte, byte, byte, byte)
Constructs an RGBA color from scalars representing red, green, blue and alpha values.
public Color(byte r, byte g, byte b, byte alpha)
Parameters
Remarks
This overload sets the values directly without clamping, and may therefore be faster than the other overloads.
Color(int, int, int)
Constructs an RGBA color from scalars representing red, green and blue values. Alpha value will be opaque.
public Color(int r, int g, int b)
Parameters
r
intRed component value from 0 to 255.
g
intGreen component value from 0 to 255.
b
intBlue component value from 0 to 255.
Color(int, int, int, int)
Constructs an RGBA color from scalars representing red, green, blue and alpha values.
public Color(int r, int g, int b, int alpha)
Parameters
r
intRed component value from 0 to 255.
g
intGreen component value from 0 to 255.
b
intBlue component value from 0 to 255.
alpha
intAlpha component value from 0 to 255.
Color(float, float, float)
Constructs an RGBA color from scalars representing red, green and blue values. Alpha value will be opaque.
public Color(float r, float g, float b)
Parameters
r
floatRed component value from 0.0f to 1.0f.
g
floatGreen component value from 0.0f to 1.0f.
b
floatBlue component value from 0.0f to 1.0f.
Color(float, float, float, float)
Constructs an RGBA color from scalars representing red, green, blue and alpha values.
public Color(float r, float g, float b, float alpha)
Parameters
r
floatRed component value from 0.0f to 1.0f.
g
floatGreen component value from 0.0f to 1.0f.
b
floatBlue component value from 0.0f to 1.0f.
alpha
floatAlpha component value from 0.0f to 1.0f.
Color(uint)
Constructs an RGBA color from a packed value. The value is a 32-bit unsigned integer, with R in the least significant octet.
public Color(uint packedValue)
Parameters
packedValue
uintThe packed value.
Properties
A
Gets or sets the alpha component.
[DataMember]
public byte A { get; set; }
Property Value
AliceBlue
AliceBlue color (R:240,G:248,B:255,A:255).
public static Color AliceBlue { get; }
Property Value
AntiqueWhite
AntiqueWhite color (R:250,G:235,B:215,A:255).
public static Color AntiqueWhite { get; }
Property Value
Aqua
Aqua color (R:0,G:255,B:255,A:255).
public static Color Aqua { get; }
Property Value
Aquamarine
Aquamarine color (R:127,G:255,B:212,A:255).
public static Color Aquamarine { get; }
Property Value
Azure
Azure color (R:240,G:255,B:255,A:255).
public static Color Azure { get; }
Property Value
B
Gets or sets the blue component.
[DataMember]
public byte B { get; set; }
Property Value
Beige
Beige color (R:245,G:245,B:220,A:255).
public static Color Beige { get; }
Property Value
Bisque
Bisque color (R:255,G:228,B:196,A:255).
public static Color Bisque { get; }
Property Value
Black
Black color (R:0,G:0,B:0,A:255).
public static Color Black { get; }
Property Value
BlanchedAlmond
BlanchedAlmond color (R:255,G:235,B:205,A:255).
public static Color BlanchedAlmond { get; }
Property Value
Blue
Blue color (R:0,G:0,B:255,A:255).
public static Color Blue { get; }
Property Value
BlueViolet
BlueViolet color (R:138,G:43,B:226,A:255).
public static Color BlueViolet { get; }
Property Value
Brown
Brown color (R:165,G:42,B:42,A:255).
public static Color Brown { get; }
Property Value
BurlyWood
BurlyWood color (R:222,G:184,B:135,A:255).
public static Color BurlyWood { get; }
Property Value
CadetBlue
CadetBlue color (R:95,G:158,B:160,A:255).
public static Color CadetBlue { get; }
Property Value
Chartreuse
Chartreuse color (R:127,G:255,B:0,A:255).
public static Color Chartreuse { get; }
Property Value
Chocolate
Chocolate color (R:210,G:105,B:30,A:255).
public static Color Chocolate { get; }
Property Value
Coral
Coral color (R:255,G:127,B:80,A:255).
public static Color Coral { get; }
Property Value
CornflowerBlue
CornflowerBlue color (R:100,G:149,B:237,A:255).
public static Color CornflowerBlue { get; }
Property Value
Cornsilk
Cornsilk color (R:255,G:248,B:220,A:255).
public static Color Cornsilk { get; }
Property Value
Crimson
Crimson color (R:220,G:20,B:60,A:255).
public static Color Crimson { get; }
Property Value
Cyan
Cyan color (R:0,G:255,B:255,A:255).
public static Color Cyan { get; }
Property Value
DarkBlue
DarkBlue color (R:0,G:0,B:139,A:255).
public static Color DarkBlue { get; }
Property Value
DarkCyan
DarkCyan color (R:0,G:139,B:139,A:255).
public static Color DarkCyan { get; }
Property Value
DarkGoldenrod
DarkGoldenrod color (R:184,G:134,B:11,A:255).
public static Color DarkGoldenrod { get; }
Property Value
DarkGray
DarkGray color (R:169,G:169,B:169,A:255).
public static Color DarkGray { get; }
Property Value
DarkGreen
DarkGreen color (R:0,G:100,B:0,A:255).
public static Color DarkGreen { get; }
Property Value
DarkKhaki
DarkKhaki color (R:189,G:183,B:107,A:255).
public static Color DarkKhaki { get; }
Property Value
DarkMagenta
DarkMagenta color (R:139,G:0,B:139,A:255).
public static Color DarkMagenta { get; }
Property Value
DarkOliveGreen
DarkOliveGreen color (R:85,G:107,B:47,A:255).
public static Color DarkOliveGreen { get; }
Property Value
DarkOrange
DarkOrange color (R:255,G:140,B:0,A:255).
public static Color DarkOrange { get; }
Property Value
DarkOrchid
DarkOrchid color (R:153,G:50,B:204,A:255).
public static Color DarkOrchid { get; }
Property Value
DarkRed
DarkRed color (R:139,G:0,B:0,A:255).
public static Color DarkRed { get; }
Property Value
DarkSalmon
DarkSalmon color (R:233,G:150,B:122,A:255).
public static Color DarkSalmon { get; }
Property Value
DarkSeaGreen
DarkSeaGreen color (R:143,G:188,B:139,A:255).
public static Color DarkSeaGreen { get; }
Property Value
DarkSlateBlue
DarkSlateBlue color (R:72,G:61,B:139,A:255).
public static Color DarkSlateBlue { get; }
Property Value
DarkSlateGray
DarkSlateGray color (R:47,G:79,B:79,A:255).
public static Color DarkSlateGray { get; }
Property Value
DarkTurquoise
DarkTurquoise color (R:0,G:206,B:209,A:255).
public static Color DarkTurquoise { get; }
Property Value
DarkViolet
DarkViolet color (R:148,G:0,B:211,A:255).
public static Color DarkViolet { get; }
Property Value
DeepPink
DeepPink color (R:255,G:20,B:147,A:255).
public static Color DeepPink { get; }
Property Value
DeepSkyBlue
DeepSkyBlue color (R:0,G:191,B:255,A:255).
public static Color DeepSkyBlue { get; }
Property Value
DimGray
DimGray color (R:105,G:105,B:105,A:255).
public static Color DimGray { get; }
Property Value
DodgerBlue
DodgerBlue color (R:30,G:144,B:255,A:255).
public static Color DodgerBlue { get; }
Property Value
Firebrick
Firebrick color (R:178,G:34,B:34,A:255).
public static Color Firebrick { get; }
Property Value
FloralWhite
FloralWhite color (R:255,G:250,B:240,A:255).
public static Color FloralWhite { get; }
Property Value
ForestGreen
ForestGreen color (R:34,G:139,B:34,A:255).
public static Color ForestGreen { get; }
Property Value
Fuchsia
Fuchsia color (R:255,G:0,B:255,A:255).
public static Color Fuchsia { get; }
Property Value
G
Gets or sets the green component.
[DataMember]
public byte G { get; set; }
Property Value
Gainsboro
Gainsboro color (R:220,G:220,B:220,A:255).
public static Color Gainsboro { get; }
Property Value
GhostWhite
GhostWhite color (R:248,G:248,B:255,A:255).
public static Color GhostWhite { get; }
Property Value
Gold
Gold color (R:255,G:215,B:0,A:255).
public static Color Gold { get; }
Property Value
Goldenrod
Goldenrod color (R:218,G:165,B:32,A:255).
public static Color Goldenrod { get; }
Property Value
Gray
Gray color (R:128,G:128,B:128,A:255).
public static Color Gray { get; }
Property Value
Green
Green color (R:0,G:128,B:0,A:255).
public static Color Green { get; }
Property Value
GreenYellow
GreenYellow color (R:173,G:255,B:47,A:255).
public static Color GreenYellow { get; }
Property Value
Honeydew
Honeydew color (R:240,G:255,B:240,A:255).
public static Color Honeydew { get; }
Property Value
HotPink
HotPink color (R:255,G:105,B:180,A:255).
public static Color HotPink { get; }
Property Value
IndianRed
IndianRed color (R:205,G:92,B:92,A:255).
public static Color IndianRed { get; }
Property Value
Indigo
Indigo color (R:75,G:0,B:130,A:255).
public static Color Indigo { get; }
Property Value
Ivory
Ivory color (R:255,G:255,B:240,A:255).
public static Color Ivory { get; }
Property Value
Khaki
Khaki color (R:240,G:230,B:140,A:255).
public static Color Khaki { get; }
Property Value
Lavender
Lavender color (R:230,G:230,B:250,A:255).
public static Color Lavender { get; }
Property Value
LavenderBlush
LavenderBlush color (R:255,G:240,B:245,A:255).
public static Color LavenderBlush { get; }
Property Value
LawnGreen
LawnGreen color (R:124,G:252,B:0,A:255).
public static Color LawnGreen { get; }
Property Value
LemonChiffon
LemonChiffon color (R:255,G:250,B:205,A:255).
public static Color LemonChiffon { get; }
Property Value
LightBlue
LightBlue color (R:173,G:216,B:230,A:255).
public static Color LightBlue { get; }
Property Value
LightCoral
LightCoral color (R:240,G:128,B:128,A:255).
public static Color LightCoral { get; }
Property Value
LightCyan
LightCyan color (R:224,G:255,B:255,A:255).
public static Color LightCyan { get; }
Property Value
LightGoldenrodYellow
LightGoldenrodYellow color (R:250,G:250,B:210,A:255).
public static Color LightGoldenrodYellow { get; }
Property Value
LightGray
LightGray color (R:211,G:211,B:211,A:255).
public static Color LightGray { get; }
Property Value
LightGreen
LightGreen color (R:144,G:238,B:144,A:255).
public static Color LightGreen { get; }
Property Value
LightPink
LightPink color (R:255,G:182,B:193,A:255).
public static Color LightPink { get; }
Property Value
LightSalmon
LightSalmon color (R:255,G:160,B:122,A:255).
public static Color LightSalmon { get; }
Property Value
LightSeaGreen
LightSeaGreen color (R:32,G:178,B:170,A:255).
public static Color LightSeaGreen { get; }
Property Value
LightSkyBlue
LightSkyBlue color (R:135,G:206,B:250,A:255).
public static Color LightSkyBlue { get; }
Property Value
LightSlateGray
LightSlateGray color (R:119,G:136,B:153,A:255).
public static Color LightSlateGray { get; }
Property Value
LightSteelBlue
LightSteelBlue color (R:176,G:196,B:222,A:255).
public static Color LightSteelBlue { get; }
Property Value
LightYellow
LightYellow color (R:255,G:255,B:224,A:255).
public static Color LightYellow { get; }
Property Value
Lime
Lime color (R:0,G:255,B:0,A:255).
public static Color Lime { get; }
Property Value
LimeGreen
LimeGreen color (R:50,G:205,B:50,A:255).
public static Color LimeGreen { get; }
Property Value
Linen
Linen color (R:250,G:240,B:230,A:255).
public static Color Linen { get; }
Property Value
Magenta
Magenta color (R:255,G:0,B:255,A:255).
public static Color Magenta { get; }
Property Value
Maroon
Maroon color (R:128,G:0,B:0,A:255).
public static Color Maroon { get; }
Property Value
MediumAquamarine
MediumAquamarine color (R:102,G:205,B:170,A:255).
public static Color MediumAquamarine { get; }
Property Value
MediumBlue
MediumBlue color (R:0,G:0,B:205,A:255).
public static Color MediumBlue { get; }
Property Value
MediumOrchid
MediumOrchid color (R:186,G:85,B:211,A:255).
public static Color MediumOrchid { get; }
Property Value
MediumPurple
MediumPurple color (R:147,G:112,B:219,A:255).
public static Color MediumPurple { get; }
Property Value
MediumSeaGreen
MediumSeaGreen color (R:60,G:179,B:113,A:255).
public static Color MediumSeaGreen { get; }
Property Value
MediumSlateBlue
MediumSlateBlue color (R:123,G:104,B:238,A:255).
public static Color MediumSlateBlue { get; }
Property Value
MediumSpringGreen
MediumSpringGreen color (R:0,G:250,B:154,A:255).
public static Color MediumSpringGreen { get; }
Property Value
MediumTurquoise
MediumTurquoise color (R:72,G:209,B:204,A:255).
public static Color MediumTurquoise { get; }
Property Value
MediumVioletRed
MediumVioletRed color (R:199,G:21,B:133,A:255).
public static Color MediumVioletRed { get; }
Property Value
MidnightBlue
MidnightBlue color (R:25,G:25,B:112,A:255).
public static Color MidnightBlue { get; }
Property Value
MintCream
MintCream color (R:245,G:255,B:250,A:255).
public static Color MintCream { get; }
Property Value
MistyRose
MistyRose color (R:255,G:228,B:225,A:255).
public static Color MistyRose { get; }
Property Value
Moccasin
Moccasin color (R:255,G:228,B:181,A:255).
public static Color Moccasin { get; }
Property Value
MonoGameOrange
MonoGame orange theme color (R:231,G:60,B:0,A:255).
public static Color MonoGameOrange { get; }
Property Value
NavajoWhite
NavajoWhite color (R:255,G:222,B:173,A:255).
public static Color NavajoWhite { get; }
Property Value
Navy
Navy color (R:0,G:0,B:128,A:255).
public static Color Navy { get; }
Property Value
OldLace
OldLace color (R:253,G:245,B:230,A:255).
public static Color OldLace { get; }
Property Value
Olive
Olive color (R:128,G:128,B:0,A:255).
public static Color Olive { get; }
Property Value
OliveDrab
OliveDrab color (R:107,G:142,B:35,A:255).
public static Color OliveDrab { get; }
Property Value
Orange
Orange color (R:255,G:165,B:0,A:255).
public static Color Orange { get; }
Property Value
OrangeRed
OrangeRed color (R:255,G:69,B:0,A:255).
public static Color OrangeRed { get; }
Property Value
Orchid
Orchid color (R:218,G:112,B:214,A:255).
public static Color Orchid { get; }
Property Value
PackedValue
Gets or sets packed value of this Color.
public uint PackedValue { get; set; }
Property Value
PaleGoldenrod
PaleGoldenrod color (R:238,G:232,B:170,A:255).
public static Color PaleGoldenrod { get; }
Property Value
PaleGreen
PaleGreen color (R:152,G:251,B:152,A:255).
public static Color PaleGreen { get; }
Property Value
PaleTurquoise
PaleTurquoise color (R:175,G:238,B:238,A:255).
public static Color PaleTurquoise { get; }
Property Value
PaleVioletRed
PaleVioletRed color (R:219,G:112,B:147,A:255).
public static Color PaleVioletRed { get; }
Property Value
PapayaWhip
PapayaWhip color (R:255,G:239,B:213,A:255).
public static Color PapayaWhip { get; }
Property Value
PeachPuff
PeachPuff color (R:255,G:218,B:185,A:255).
public static Color PeachPuff { get; }
Property Value
Peru
Peru color (R:205,G:133,B:63,A:255).
public static Color Peru { get; }
Property Value
Pink
Pink color (R:255,G:192,B:203,A:255).
public static Color Pink { get; }
Property Value
Plum
Plum color (R:221,G:160,B:221,A:255).
public static Color Plum { get; }
Property Value
PowderBlue
PowderBlue color (R:176,G:224,B:230,A:255).
public static Color PowderBlue { get; }
Property Value
Purple
Purple color (R:128,G:0,B:128,A:255).
public static Color Purple { get; }
Property Value
R
Gets or sets the red component.
[DataMember]
public byte R { get; set; }
Property Value
Red
Red color (R:255,G:0,B:0,A:255).
public static Color Red { get; }
Property Value
RosyBrown
RosyBrown color (R:188,G:143,B:143,A:255).
public static Color RosyBrown { get; }
Property Value
RoyalBlue
RoyalBlue color (R:65,G:105,B:225,A:255).
public static Color RoyalBlue { get; }
Property Value
SaddleBrown
SaddleBrown color (R:139,G:69,B:19,A:255).
public static Color SaddleBrown { get; }
Property Value
Salmon
Salmon color (R:250,G:128,B:114,A:255).
public static Color Salmon { get; }
Property Value
SandyBrown
SandyBrown color (R:244,G:164,B:96,A:255).
public static Color SandyBrown { get; }
Property Value
SeaGreen
SeaGreen color (R:46,G:139,B:87,A:255).
public static Color SeaGreen { get; }
Property Value
SeaShell
SeaShell color (R:255,G:245,B:238,A:255).
public static Color SeaShell { get; }
Property Value
Sienna
Sienna color (R:160,G:82,B:45,A:255).
public static Color Sienna { get; }
Property Value
Silver
Silver color (R:192,G:192,B:192,A:255).
public static Color Silver { get; }
Property Value
SkyBlue
SkyBlue color (R:135,G:206,B:235,A:255).
public static Color SkyBlue { get; }
Property Value
SlateBlue
SlateBlue color (R:106,G:90,B:205,A:255).
public static Color SlateBlue { get; }
Property Value
SlateGray
SlateGray color (R:112,G:128,B:144,A:255).
public static Color SlateGray { get; }
Property Value
Snow
Snow color (R:255,G:250,B:250,A:255).
public static Color Snow { get; }
Property Value
SpringGreen
SpringGreen color (R:0,G:255,B:127,A:255).
public static Color SpringGreen { get; }
Property Value
SteelBlue
SteelBlue color (R:70,G:130,B:180,A:255).
public static Color SteelBlue { get; }
Property Value
Tan
Tan color (R:210,G:180,B:140,A:255).
public static Color Tan { get; }
Property Value
Teal
Teal color (R:0,G:128,B:128,A:255).
public static Color Teal { get; }
Property Value
Thistle
Thistle color (R:216,G:191,B:216,A:255).
public static Color Thistle { get; }
Property Value
Tomato
Tomato color (R:255,G:99,B:71,A:255).
public static Color Tomato { get; }
Property Value
Transparent
Transparent color (R:0,G:0,B:0,A:0).
public static Color Transparent { get; }
Property Value
Turquoise
Turquoise color (R:64,G:224,B:208,A:255).
public static Color Turquoise { get; }
Property Value
Violet
Violet color (R:238,G:130,B:238,A:255).
public static Color Violet { get; }
Property Value
Wheat
Wheat color (R:245,G:222,B:179,A:255).
public static Color Wheat { get; }
Property Value
White
White color (R:255,G:255,B:255,A:255).
public static Color White { get; }
Property Value
WhiteSmoke
WhiteSmoke color (R:245,G:245,B:245,A:255).
public static Color WhiteSmoke { get; }
Property Value
Yellow
Yellow color (R:255,G:255,B:0,A:255).
public static Color Yellow { get; }
Property Value
YellowGreen
YellowGreen color (R:154,G:205,B:50,A:255).
public static Color YellowGreen { get; }
Property Value
Methods
Deconstruct(out byte, out byte, out byte)
Deconstruction method for Color.
public void Deconstruct(out byte r, out byte g, out byte b)
Parameters
r
byteRed component value from 0 to 255.
g
byteGreen component value from 0 to 255.
b
byteBlue component value from 0 to 255.
Deconstruct(out byte, out byte, out byte, out byte)
Deconstruction method for Color with Alpha.
public void Deconstruct(out byte r, out byte g, out byte b, out byte a)
Parameters
r
byteRed component value from 0 to 255.
g
byteGreen component value from 0 to 255.
b
byteBlue component value from 0 to 255.
a
byteAlpha component value from 0 to 255.
Deconstruct(out float, out float, out float)
Deconstruction method for Color.
public void Deconstruct(out float r, out float g, out float b)
Parameters
r
floatRed component value from 0.0f to 1.0f.
g
floatGreen component value from 0.0f to 1.0f.
b
floatBlue component value from 0.0f to 1.0f.
Deconstruct(out float, out float, out float, out float)
Deconstruction method for Color with Alpha.
public void Deconstruct(out float r, out float g, out float b, out float a)
Parameters
r
floatRed component value from 0.0f to 1.0f.
g
floatGreen component value from 0.0f to 1.0f.
b
floatBlue component value from 0.0f to 1.0f.
a
floatAlpha component value from 0.0f to 1.0f.
Equals(Color)
Compares whether current instance is equal to specified Color.
public bool Equals(Color other)
Parameters
Returns
- bool
true
if the instances are equal;false
otherwise.
Equals(object)
Compares whether current instance is equal to specified object.
public override bool Equals(object obj)
Parameters
Returns
- bool
true
if the instances are equal;false
otherwise.
FromNonPremultiplied(Vector4)
public static Color FromNonPremultiplied(Vector4 vector)
Parameters
Returns
FromNonPremultiplied(int, int, int, int)
public static Color FromNonPremultiplied(int r, int g, int b, int a)
Parameters
r
intRed component value.
g
intGreen component value.
b
intBlue component value.
a
intAlpha component value.
Returns
GetHashCode()
Gets the hash code of this Color.
public override int GetHashCode()
Returns
Lerp(Color, Color, float)
Performs linear interpolation of Color.
public static Color Lerp(Color value1, Color value2, float amount)
Parameters
Returns
LerpPrecise(Color, Color, float)
Lerp(Color, Color, float) should be used instead of this function.
[Obsolete("Color.Lerp should be used instead of this function.")]
public static Color LerpPrecise(Color value1, Color value2, float amount)
Parameters
Returns
Multiply(Color, float)
Multiplies the RGBA component values of a color by the specified value.
public static Color Multiply(Color value, float scale)
Parameters
value
ColorThe source color value to multiply.
scale
floatThe value to multiply the RGBA component values by.
Returns
- Color
The new color value created as a result of the multiplication.
ToString()
public override string ToString()
Returns
ToVector3()
Gets a Vector3 representation for this object.
public Vector3 ToVector3()
Returns
ToVector4()
Gets a Vector4 representation for this object.
public Vector4 ToVector4()
Returns
Operators
operator ==(Color, Color)
Compares whether two Color instances are equal.
public static bool operator ==(Color a, Color b)
Parameters
a
ColorColor instance on the left of the equal sign.
b
ColorColor instance on the right of the equal sign.
Returns
- bool
true
if the instances are equal;false
otherwise.
operator !=(Color, Color)
Compares whether two Color instances are not equal.
public static bool operator !=(Color a, Color b)
Parameters
a
ColorColor instance on the left of the not equal sign.
b
ColorColor instance on the right of the not equal sign.
Returns
- bool
true
if the instances are not equal;false
otherwise.
operator *(Color, float)
Multiplies the RGBA component values of a color by the specified value.
public static Color operator *(Color value, float scale)
Parameters
value
ColorThe source color value to multiply.
scale
floatThe value to multiply the RGBA component values by.
Returns
- Color
The new color value created as a result of the multiplication.
operator *(float, Color)
Multiplies the RGBA component values of a color by the specified value.
public static Color operator *(float scale, Color value)
Parameters
scale
floatThe value to multiply the RGBA component values by.
value
ColorThe source color value to multiply.
Returns
- Color
The new color value created as a result of the multiplication.