float Item { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Item property of the Color struct provides access to the color components using an indexer. This property allows you to get or set the red, green, blue, or alpha component of the color by specifying an index. The index values are typically 0 for red, 1 for green, 2 for blue, and 3 for alpha.

Usage

Use the Item property to access or modify individual color components of a Color instance. This can be useful when you need to perform operations on specific components without directly accessing the fields.

Example

Color color = new Color(0.5f, 0.4f, 0.3f, 1.0f);

// Access the red component
float red = color[0];

// Modify the green component
color[1] = 0.6f;

// Access the blue component
float blue = color[2];

// Modify the alpha component
color[3] = 0.8f;