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 the desired brightness value as a parameter. The value should be a float between 0 (black) and 1 (full brightness).

Example

// Create a ColorHsv instance with specific hue, saturation, and value
ColorHsv color = new ColorHsv(120, 0.5f, 0.5f);

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

// The brighterColor now has the same hue and saturation as the original color,
// but with a higher brightness value.