Description
The Item
property of the Color
struct provides access to the individual color components (red, green, blue, and alpha) as a float
value. This property is indexed, allowing you to retrieve or set the value of a specific component by its index.
Note that this property is marked with the JsonIgnore
attribute, which means it will be ignored during JSON serialization and deserialization processes.
Usage
Use the Item
property to access or modify the individual components of a Color
instance. The index values are as follows:
0
- Red component
1
- Green component
2
- Blue component
3
- Alpha component
Example usage:
Color color = new Color(0.5f, 0.4f, 0.3f, 1.0f);
float redComponent = color[0]; // Access the red component
color[1] = 0.6f; // Modify the green component
Example
Color color = new Color(0.5f, 0.4f, 0.3f, 1.0f);
float redComponent = color[0]; // Access the red component
color[1] = 0.6f; // Modify the green component