The Darken
method of the Color
struct is used to darken the color by a specified fraction. This method adjusts the brightness of the color by reducing its intensity, making it appear darker.
The Darken
method of the Color
struct is used to darken the color by a specified fraction. This method adjusts the brightness of the color by reducing its intensity, making it appear darker.
To use the Darken
method, call it on an instance of the Color
struct, passing a float
value as the fraction
parameter. The fraction
should be a value between 0 and 1, where 0 means no change and 1 means the color is completely darkened to black.
Example usage:
Color myColor = new Color(0.5f, 0.5f, 0.5f, 1.0f);
Color darkerColor = myColor.Darken(0.2f);
In this example, myColor
is darkened by 20%, resulting in a new color stored in darkerColor
.
Color myColor = new Color(0.5f, 0.5f, 0.5f, 1.0f); Color darkerColor = myColor.Darken(0.2f);