ColorHsv WithValue( float value )

book_4_sparkGenerated
code_blocksInput

Description

The WithValue method of the ColorHsv struct allows you to create a new ColorHsv instance with a modified value (brightness) component, while keeping the hue, saturation, and alpha components unchanged. This method is useful when you want to adjust the brightness of a color without affecting its hue or saturation.

Usage

To use the WithValue method, call it on an existing ColorHsv instance and pass a new value for the brightness component. The method returns a new ColorHsv instance with the updated value.

The value parameter should be a float between 0 (black) and 1 (full brightness).

Example

// Create an initial ColorHsv instance
ColorHsv originalColor = new ColorHsv(120, 0.5f, 0.5f, 1.0f);

// Adjust the value (brightness) of the color
ColorHsv brighterColor = originalColor.WithValue(0.8f);

// The brighterColor now has a value of 0.8, while hue, saturation, and alpha remain the same