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

ColorHsv originalColor = new ColorHsv(120, 0.5f, 0.75f, 1.0f);
ColorHsv newColor = originalColor.WithSaturation(0.8f);

// originalColor remains unchanged
// newColor has the same hue, value, and alpha as originalColor, but with a saturation of 0.8