Struct Color
Represents an RGBA color within Ritchie's Toolbox. The red, green, blue, and alpha channels are stored as floating-point numbers.
Inherited Members
Namespace: Ritchie.Toolbox
Assembly: Ritchie.Toolbox.dll
Syntax
public struct ColorConstructors
Color(byte, byte, byte, byte)
Creates a new Color value using bytes for the red, green, blue and alpha channels.
Declaration
public Color(byte red, byte green, byte blue, byte alpha = 255)Parameters
| Type | Name | Description | 
|---|---|---|
| byte | red | The value of the red channel. | 
| byte | green | The value of the green channel. | 
| byte | blue | The value of the blue channel. | 
| byte | alpha | The value of the alpha channel. | 
Remarks
This constructor is defined for programmer convenience. The values passed for each channel are divided by MaxValue before being stored. This will result in the values being converted to floating-point numbers between 0 and 1.
Color(float, float, float, float)
Creates a new Color value using floating-point values for red, green, blue, and alpha - where all ones mean white.
Declaration
public Color(float red, float green, float blue, float alpha = 1)Parameters
| Type | Name | Description | 
|---|---|---|
| float | red | The value of the red channel. | 
| float | green | The value of the green channel | 
| float | blue | The value of the blue channel | 
| float | alpha | The value of the alpha channel. Default is 1.0 for full opacity. | 
Color(uint)
Declaration
public Color(uint packedValue)Parameters
| Type | Name | Description | 
|---|---|---|
| uint | packedValue | The value of the color. | 
Remarks
    The value passed to packedValue will be interpreted in the format R8G8B8A8. This means that 8 bits, or one byte, is dedicated to each
    color channel. Red comes first, then green, then blue, then alpha. Transparent black would have a value of 0, while fully opaque white would have a value of MaxValue.
For a fully-opaque red, pass 0xff0000ff. For a 50% transparent green, pass 0x00ff007f.
Fields
Alpha
Stores a value representing how opaque the color is.
Declaration
public float AlphaField Value
| Type | Description | 
|---|---|
| float | 
Blue
Stores a value representing a color's blue-ness.
Declaration
public float BlueField Value
| Type | Description | 
|---|---|
| float | 
Green
Stores a value indicating a color's green-ness.
Declaration
public float GreenField Value
| Type | Description | 
|---|---|
| float | 
Red
Stores a value representing the color's red-ness.
Declaration
public float RedField Value
| Type | Description | 
|---|---|
| float | 
Operators
implicit operator Color(Color)
Implicit conversion from Microsoft.Xna.Framework.Color to a Color value.
Declaration
public static implicit operator Color(Color xnaColor)Parameters
| Type | Name | Description | 
|---|---|---|
| Color | xnaColor | The original color | 
Returns
| Type | Description | 
|---|---|
| Color | An identical color expressed as a Color value. | 
implicit operator Color(Color)
Declaration
public static implicit operator Color(Color legacyColor)Parameters
| Type | Name | Description | 
|---|---|---|
| Color | legacyColor | The original color. | 
Returns
| Type | Description | 
|---|---|
| Color | An identical color, but not using an ancient and crappy graphics API. | 
implicit operator Color(uint)
Implicit conversion operator for converting packed color representations to Color values.
Declaration
public static implicit operator Color(uint packedValue)Parameters
| Type | Name | Description | 
|---|---|---|
| uint | packedValue | A 4-byte color value arranged as 0xRRGGBBAA. | 
Returns
| Type | Description | 
|---|---|
| Color | A Color value representing the packed color. |