Skip to contents

Shifts each colour's HSL lightness by amount, clamped to [0, 1]. color_lighten() and color_darken() shift in opposite directions by the same amount – there is no single signed-amount function, since separate verbs read more clearly at a call site.

Usage

color_lighten(color, amount = 0.1)

color_darken(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 lightness shift.

Value

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

Examples

color_lighten("steelblue", amount = 0.2)
#> [1] "#8DB3D3"
color_darken(palette_manual(index = 1), amount = 0.15)
#> [1] "#1E3C52" "#4C9AC5" "#141F26" "#CE8709" "#B4450A"
draw(effect_swatch(color = color_lighten("steelblue", amount = seq(0, 0.4, 0.1))))