Reference saturation()

saturation()

Gets the saturation value of a color.

saturation() extracts the saturation value from a p5.Color object, an array of color components, or a CSS color string.

Saturation is scaled differently in HSB and HSL. By default, saturation() returns a color's HSL saturation in the range 0 to 100. If the colorMode() is set to HSB or HSL, it returns the saturation value in the given mode.

In p5.strands shader callbacks, saturation() operates on vec4 values and returns the saturation as a normalized value in the 0–1 range. colorMode() has no effect inside shader callbacks.

Examples

Syntax

saturation(color)

Parameters

color
p5.Color|Number[]|String: p5.Color object, array of color components, or CSS color string.

Returns

Number: the saturation value

Related References