Skip to contents

Nudges each colour's HSL hue/saturation/lightness by independent Gaussian noise – hue by amount * 360 degrees (wrapped, %% 360), saturation/lightness by amount (reflected back into [0, 1] at the boundary via the same triangle-wave technique palette_walk() uses for its own random steps) – giving each colour an independent, organic variation rather than palette_walk()'s own correlated sequence of colours.

Usage

color_jitter(color, amount = 0.05, seed = 1L)

Arguments

color

A character vector of colours.

amount

A single non-negative number: the standard deviation of the saturation/lightness noise (and amount * 360, of the hue noise, in degrees).

seed

A single whole number seeding the noise, so the same seed always produces the same perturbation.

Value

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

Examples

color_jitter(palette_manual(index = 1), amount = 0.05, seed = 8241)
#> [1] "#32757B" "#6B6CD2" "#1F3239" "#F5C93B" "#F05629"
draw(effect_swatch(color = color_jitter(rep("steelblue", 8), amount = 0.1, seed = 8241)))