Skip to contents

Shifts each colour's HSL saturation by amount, clamped to [0, 1]. color_saturate() and color_desaturate() shift in opposite directions by the same amount, mirroring color_lighten()/ color_darken()'s own paired-verb shape.

Usage

color_saturate(color, amount = 0.1)

color_desaturate(color, amount = 0.1)

Arguments

color

A character vector of colours.

amount

A numeric vector, each in [0, 1], recycled against color: the (clamped) HSL saturation shift.

Value

A character vector of hex colour strings, the same length as the longer of color/amount.

Examples

color_saturate("slategray", amount = 0.3)
#> [1] "#4A80B6"
color_desaturate(palette_manual(index = 1), amount = 0.5)
#> [1] "#5F5F5F" "#AEAFB0" "#444444" "#BF9E64" "#B57756"
draw(effect_swatch(color = color_desaturate(palette_manual(index = 1), amount = 0.5)))