Description
The WithRed
method allows you to create a new Color
instance with a modified red component, while keeping the other components (green, blue, and alpha) unchanged. This method is useful when you want to adjust the red intensity of a color without affecting its other components.
Usage
To use the WithRed
method, call it on an existing Color
instance and pass the desired red component value as a float
between 0 and 1. The method returns a new Color
instance with the updated red component.
Example
// Example of using the WithRed method
Color originalColor = new Color(0.5f, 0.4f, 0.3f, 1.0f);
Color newColor = originalColor.WithRed(0.8f);
// originalColor remains unchanged
// newColor has a red component of 0.8, green of 0.4, blue of 0.3, and alpha of 1.0