Class Color
Represents an RGB color.
Namespace: Colore.Data
Assembly: Colore.dll
Syntax
public sealed class Color : ValueType, IEquatable<Color>, IEquatable<uint>
Constructors
Color(Byte, Byte, Byte)
Initializes a new instance of the Color struct using three distinct R, G, and B byte values.
Declaration
public Color(byte red, byte green, byte blue)
Parameters
Type | Name | Description |
---|---|---|
Byte | red | The red component. |
Byte | green | The green component. |
Byte | blue | The blue component. |
Color(Double, Double, Double)
Initializes a new instance of the Color struct using three Double values for the R, G, and B channels.
Declaration
public Color(double red, double green, double blue)
Parameters
Type | Name | Description |
---|---|---|
Double | red | The red component ( |
Double | green | The green component ( |
Double | blue | The blue component ( |
Remarks
Each parameter value must be between 0.0
and 1.0
(inclusive).
Color(Single, Single, Single)
Initializes a new instance of the Color struct using three Single values for the R, G, and B channels.
Declaration
public Color(float red, float green, float blue)
Parameters
Type | Name | Description |
---|---|---|
Single | red | The red component ( |
Single | green | The green component ( |
Single | blue | The blue component ( |
Remarks
Each parameter value must be between 0.0f
and 1.0f
(inclusive).
Color(UInt32)
Initializes a new instance of the Color struct using an integer
color value in the format 0xKKBBGGRR
.
Declaration
public Color(uint value)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | value | Value to create the color from. |
Fields
Black
Black color.
Declaration
public static readonly Color Black
Field Value
Type | Description |
---|---|
Color |
Blue
(Dark) blue color.
Declaration
public static readonly Color Blue
Field Value
Type | Description |
---|---|
Color |
Green
(Neon/bright) green color.
Declaration
public static readonly Color Green
Field Value
Type | Description |
---|---|
Color |
HotPink
Hot pink color.
Declaration
public static readonly Color HotPink
Field Value
Type | Description |
---|---|
Color |
Orange
Orange color.
Declaration
public static readonly Color Orange
Field Value
Type | Description |
---|---|
Color |
Pink
Pink color.
Declaration
public static readonly Color Pink
Field Value
Type | Description |
---|---|
Color |
Purple
Purple color.
Declaration
public static readonly Color Purple
Field Value
Type | Description |
---|---|
Color |
Red
Red color.
Declaration
public static readonly Color Red
Field Value
Type | Description |
---|---|
Color |
White
White color.
Declaration
public static readonly Color White
Field Value
Type | Description |
---|---|
Color |
Yellow
Yellow color.
Declaration
public static readonly Color Yellow
Field Value
Type | Description |
---|---|
Color |
Properties
AsKeyColor
Gets a version of this color with the key bit set.
Declaration
public Color AsKeyColor { get; }
Property Value
Type | Description |
---|---|
Color |
AsRegularColor
Gets a version of this color without the key bit set.
Declaration
public Color AsRegularColor { get; }
Property Value
Type | Description |
---|---|
Color |
B
Gets the blue component of the color as a byte.
Declaration
public byte B { get; }
Property Value
Type | Description |
---|---|
Byte |
G
Gets the green component of the color as a byte.
Declaration
public byte G { get; }
Property Value
Type | Description |
---|---|
Byte |
R
Gets the red component of the color as a byte.
Declaration
public byte R { get; }
Property Value
Type | Description |
---|---|
Byte |
Value
Gets the unsigned integer representing
the color. On the form 0xKKBBGGRR
.
Declaration
public uint Value { get; }
Property Value
Type | Description |
---|---|
UInt32 |
Methods
Equals(Color)
Declaration
public bool Equals(Color other)
Parameters
Type | Name | Description |
---|---|---|
Color | other | The Color to check equality against. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
Only compares the lower 32 bits of each color value, in order to be able to compare a keymode color to a non-keymode color.
Equals(Object)
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | The Object to check equality against. |
Returns
Type | Description |
---|---|
Boolean |
|
Equals(UInt32)
Declaration
public bool Equals(uint other)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | other | The UInt32 to check equality against. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
Only compares the lower 32 bits of each value, in order to be able to compare a keymode color to a non-keymode color.
FromRgb(UInt32)
Creates a new Color from an RGB integer value
in the format of 0xRRGGBB
.
Declaration
public static Color FromRgb(uint value)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | value | The RGB value to convert from. |
Returns
Type | Description |
---|---|
Color | A new instance of the Color struct. |
GetHashCode()
Gets the unique hash code for this Color.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A unique has code. |
ToColor(UInt32)
Converts an unsigned integer value to a Color object.
Declaration
public static Color ToColor(uint value)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | value | The value to convert. |
Returns
Type | Description |
---|---|
Color | Color representation of the value. |
Remarks
This is an alias for FromRgb(UInt32).
See Also
ToString()
Returns a string representation of this color's red, green, and blue values.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A String containing a string representation of this color. |
ToUInt32()
Converts this instance of Color to an unsigned integer value.
Declaration
public uint ToUInt32()
Returns
Type | Description |
---|---|
UInt32 | The unsigned integer value of this Color. |
Operators
Equality(Color, Object)
Checks left
and right
for equality.
Declaration
public static bool operator ==(Color left, object right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | Left operand, an instance of the Color struct. |
Object | right | Right operand, an Object. |
Returns
Type | Description |
---|---|
Boolean |
|
Implicit(Color to UInt32)
Declaration
public static implicit operator uint (Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The Color to convert. |
Returns
Type | Description |
---|---|
UInt32 | A UInt32 representing the value of the |
Remarks
The returned UInt32 has a format of 0xAABBGGRR
.
Implicit(UInt32 to Color)
Converts a uint
value
in the format of 0xAABBGGRR
to a new instance of the Color struct.
Declaration
public static implicit operator Color(uint value)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | value | The UInt32 to convert, on the form |
Returns
Type | Description |
---|---|
Color | An instance of Color representing the color value of |
Inequality(Color, Object)
Checks left
and right
for inequality.
Declaration
public static bool operator !=(Color left, object right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | Left operand, an instance of the Color struct. |
Object | right | Right operand, an Object. |
Returns
Type | Description |
---|---|
Boolean |
|