Color Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a four-component color using red, green, blue, and alpha data.

Namespace:  Microsoft.Xna.Framework
Assembly:  Microsoft.Xna.Framework (in Microsoft.Xna.Framework.dll)

Syntax

'Declaration
Public Structure Color
public struct Color

The Color type exposes the following members.

Constructors

  Name Description
Public method Color(Int32, Int32, Int32) Initializes a new instance of the Color structure using integer values.
Public method Color(Single, Single, Single) Initializes a new instance of the Color structure using floating point values.
Public method Color(Int32, Int32, Int32, Int32) Initializes a new instance of the Color structure using integer values.
Public method Color(Single, Single, Single, Single) Initializes a new instance of the Color structure using floating point values.

Top

Properties

  Name Description
Public property A Gets or sets the alpha component value.
Public property B Gets or sets the blue component value.
Public propertyStatic member Black Gets a system-defined color with the value R:0 G:0 B:0 A:255.
Public property G Gets or sets the green component value
Public property PackedValue Gets the current color as a packed value.
Public property R Gets or sets the red component value.
Public propertyStatic member Transparent Gets a system-defined color with the value R:0 G:0 B:0 A:0.
Public propertyStatic member White Gets a system-defined color with the value R:255 G:255 B:255 A:255.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified color object equals this object. (Overrides ValueType.Equals(Object).)
Public method Equals(Color) Determines whether the specified color equals this object.
Public methodStatic member FromNonPremultiplied Converts a non-premultipled alpha color to a color that contains premultiplied alpha.
Public method GetHashCode Gets the hash code for this object. (Overrides ValueType.GetHashCode().)
Public methodStatic member Lerp Linearly interpolate a color.
Public methodStatic member Multiply Multiply each color component by the scale factor.
Public method ToString Gets a string representation of this object. (Overrides ValueType.ToString().)

Top

Operators

  Name Description
Public operatorStatic member Equality Determines whether the specified colors are equal.
Public operatorStatic member Inequality Determines whether the specified colors are not equal.
Public operatorStatic member Multiply Multiplies the specified color and a scale factor.

Top

Extension Methods

  Name Description
Public Extension Method ToVector3 Converts the specified color into a Vector3. (Defined by ColorExtensions.)
Public Extension Method ToVector4 Converts the specified color into a Vector4. (Defined by ColorExtensions.)

Top

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.