rgb_to_saturation()

Converts an RGB color value to its corresponding saturation component in the HSL color space.

Syntax

saturation = rgb_to_saturation(color)

Parameters

Parameter Type Description Comment
color Number RGB color value in integer format (0xRRGGBB)

Return Value

Examples

Get the saturation of pure red (RGB: 255, 0, 0)

rgb_to_saturation(0xFF0000); // returns 100.0

Get the saturation of gray (RGB: 128, 128, 128)

rgb_to_saturation(0x808080); // returns 0.0

Get the saturation of a light blue color (RGB: 173, 216, 230)

rgb_to_saturation(0xADD8E6); // returns 53.27102804

See also

rgb_to_hue
rgb_to_saturation
rgb_to_lightness
rgb_to_name

cam_color