Color Darken( float fraction )

book_4_sparkGenerated
code_blocksInput

Description

The Darken method is a member of the Color struct, which allows you to darken a color by a specified fraction. This method modifies the color's brightness by reducing its intensity, making it appear darker.

Usage

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.

For example, if you want to darken a color by 20%, you would pass 0.2 as the fraction.

Example

// Example of using the Darken method
Color originalColor = new Color(0.5f, 0.5f, 0.5f, 1.0f); // A medium gray color
float darkenFraction = 0.2f; // Darken by 20%
Color darkenedColor = originalColor.Darken(darkenFraction);

// darkenedColor now holds the darker version of the original color