ColorHsv WithSaturation( float saturation )

book_4_sparkGenerated
code_blocksInput

Description

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

Usage

To use the WithSaturation method, call it on an existing ColorHsv instance and pass the desired saturation value as a parameter. The saturation value should be a float between 0 (completely desaturated, resulting in a shade of gray) and 1 (fully saturated).

Example

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

// Modify the saturation of the color
ColorHsv newColor = originalColor.WithSaturation(0.8f);

// newColor now has a saturation of 0.8, while hue, value, and alpha remain unchanged