Color with a byte per component (red, green, blue, alpha), also provides float properties.
View code on GitHub
Namespace: DeltaEngine.DatatypesAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Color type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Color(String) | Initializes a new instance of the Color class | |
Color(Color, Byte) | Initializes a new instance of the Color class | |
Color(Color, Single) | Initializes a new instance of the Color class | |
Color(Byte, Byte, Byte, Byte) | Initializes a new instance of the Color class | |
Color(Single, Single, Single, Single) | Initializes a new instance of the Color class |
Methods
Name | Description | |
---|---|---|
Equals(Object) | (Overrides ValueType Equals(Object).) | |
Equals(Color) | ||
GetHashCode | (Overrides ValueType GetHashCode .) | |
GetHeatmapColor | ||
GetRandomBrightColor | ||
GetRandomColor | ||
GetRgbaBytesFromArray | ||
Lerp | ||
ToString | (Overrides ValueType ToString .) | |
Transparent |
Operators
Name | Description | |
---|---|---|
Equality | ||
Inequality | ||
Multiply(Color, Color) | ||
Multiply(Color, Single) |
Fields
Name | Description | |
---|---|---|
Black | ||
Blue | ||
Brown | ||
CornflowerBlue | ||
Cyan | ||
DarkGray | ||
DarkGreen | ||
Gold | ||
Gray | ||
Green | ||
LightBlue | ||
LightGray | ||
Orange | ||
PaleGreen | ||
Pink | ||
Purple | ||
Red | ||
SizeInBytes | ||
Teal | ||
TransparentBlack | ||
TransparentWhite | ||
VeryLightGray | ||
White | ||
Yellow |
Properties
Name | Description | |
---|---|---|
A | ||
AlphaValue | ||
B | ||
BlueValue | ||
G | ||
GreenValue | ||
PackedRgba |
Colors are stored as RGBA byte values and this gives back the usual RGBA format as an
optimized 32 bit value. R takes the first 8 bits, G the next 8 up to A for the last 8 bits.
View code on GitHub | |
R | ||
RedValue |
Remarks
Examples
[Test] public void CreateWithBytes() { var color = new Color(1, 2, 3, 4); Assert.AreEqual(1, color.R); Assert.AreEqual(2, color.G); Assert.AreEqual(3, color.B); Assert.AreEqual(4, color.A); }
[Test] public void ChangeColor() { var color = new Color(1, 2, 3, 4) { R = 5, G = 6, B = 7, A = 8 }; Assert.AreEqual(5, color.R); Assert.AreEqual(6, color.G); Assert.AreEqual(7, color.B); Assert.AreEqual(8, color.A); }
[Test] public void CreateWithFloats() { var color = new Color(1.0f, 0.0f, 0.5f); Assert.AreEqual(255, color.R); Assert.AreEqual(0, color.G); Assert.AreEqual(127, color.B); Assert.AreEqual(255, color.A); }
See Also