Struct Color3<T>
To provide type-safety between different color spaces and allow extension by users to include additional and future color spaces, colors are marked with a special phantom type parameter that indicates their color space. Typically these are four-letter abbreviations that indicate the components of the colors, such as Rgb or Hsv.
In any of these cases, letters in the color space correspond to the order of the components in the color vector. For example, color<RGB> maps as follows:
X -> R
Y -> G
Z -> B.
Implements
Inherited Members
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
public struct Color3<T> : IEquatable<Color3<T>> where T : IColorSpace3
Type Parameters
Name | Description |
---|---|
T | The color space of the given color. |
Constructors
Color3(float, float, float)
Initializes a new instance of the Color3<T> struct.
Declaration
public Color3(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The first element of the color. |
float | y | The second element of the color. |
float | z | The third element of the color. |
Fields
X
The first element of this color. This corresponds to the first letter of the color type.
Declaration
public float X
Field Value
Type | Description |
---|---|
float |
Y
The second element of this colour. This corresponds to the second letter of the colour type.
Declaration
public float Y
Field Value
Type | Description |
---|---|
float |
Z
The third element of this color. This corresponds to the second letter of the colour type.
Declaration
public float Z
Field Value
Type | Description |
---|---|
float |
Properties
this[int]
Gets or sets the nth element of this color.
Declaration
public float this[int n] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | n | The nth element to get. |
Property Value
Type | Description |
---|---|
float |
Methods
Deconstruct(out float, out float, out float)
Deconstructs this color3 and turns it into a tuple containing 3 floats.
Declaration
[Pure]
public void Deconstruct(out float x, out float y, out float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The x component of this color, defined by the color space. |
float | y | The y component of this color, defined by the color space. |
float | z | The z component of this color, defined by the color space. |
Equals(Color3<T>)
Compares whether this Color3 structure is equal to the specified Color4.
Declaration
[Pure]
public bool Equals(Color3<T> other)
Parameters
Type | Name | Description |
---|---|---|
Color3<T> | other | The Color3 structure to compare to. |
Returns
Type | Description |
---|---|
bool | True if both Color3 structures contain the same components; false otherwise. |
Equals(object)
Compares whether this Color4 structure is equal to the specified object.
Declaration
[Pure]
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | An object to compare to. |
Returns
Type | Description |
---|---|
bool | True obj is a Color4 structure with the same components as this Color4; false otherwise. |
Overrides
GetHashCode()
Calculates the hash code for this Color4 structure.
Declaration
[Pure]
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A System.Int32 containing the hashcode of this Color4 structure. |
Overrides
ToString()
Creates a string that describes this Color4 structure.
Declaration
[Pure]
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that describes this Color4 structure. |
Overrides
Operators
operator ==(in Color3<T>, in Color3<T>)
Compares the specified Color3 structures for equality.
Declaration
[Pure]
public static bool operator ==(in Color3<T> left, in Color3<T> right)
Parameters
Type | Name | Description |
---|---|---|
Color3<T> | left | The left-hand side of the comparison. |
Color3<T> | right | The right-hand side of the comparison. |
Returns
Type | Description |
---|---|
bool | True if left is equal to right; false otherwise. |
explicit operator Vector3(in Color3<T>)
Declaration
[Pure]
public static explicit operator Vector3(in Color3<T> col)
Parameters
Type | Name | Description |
---|---|---|
Color3<T> | col | The color which the instantiated vector will use the X, Y and Z from, in that order. |
Returns
Type | Description |
---|---|
Vector3 | The vector that was instantiated. |
explicit operator Color3<T>(in Vector3)
Declaration
[Pure]
public static explicit operator Color3<T>(in Vector3 vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vec | The vector which the instantiated color will use the X, Y and Z from, in that order. |
Returns
Type | Description |
---|---|
Color3<T> | The color that was instantiated. |
operator !=(in Color3<T>, in Color3<T>)
Compares the specified Color3 structures for inequality.
Declaration
[Pure]
public static bool operator !=(in Color3<T> left, in Color3<T> right)
Parameters
Type | Name | Description |
---|---|---|
Color3<T> | left | The left-hand side of the comparison. |
Color3<T> | right | The right-hand side of the comparison. |
Returns
Type | Description |
---|---|
bool | True if left is not equal to right; false otherwise. |