Learn R Programming

SC3 (version 1.1.4)

iwanthue: Generate a colour palette by k-means clustering of LAB colour space.

Description

Generate a palette of distinct colours through k-means clustering of LAB colour space.

Usage

iwanthue(n, hmin = 0, hmax = 360, cmin = 0, cmax = 180, lmin = 0, lmax = 100, plot = FALSE, random = FALSE)

Arguments

n
Numeric. The number of colours to generate.
hmin
Numeric, in the range [0, 360]. The lower limit of the hue range to be clustered.
hmax
Numeric, in the range [0, 360]. The upper limit of the hue range to be clustered.
cmin
Numeric, in the range [0, 180]. The lower limit of the chroma range to be clustered.
cmax
Numeric, in the range [0, 180]. The upper limit of the chroma range to be clustered.
lmin
Numeric, in the range [0, 100]. The lower limit of the luminance range to be clustered.
lmax
Numeric, in the range [0, 100]. The upper limit of the luminance range to be clustered.
plot
Logical. Should the colour swatches be plotted (using swatch)?
random
Logical. If TRUE, clustering will be determined by the existing RNG state. If FALSE, the seed will be set to 1 for clustering, and on exit, the function will restore the pre-existing RNG state.

Value

A vector of n colours (as hexadecimal strings), representing centers of clusters determined through k-means clustering of the LAB colour space delimited by hmin, hmax, cmin, cmax, lmin and lmax.

Details

Note that iwanthue currently doesn't support hmin greater than hmax (which should be allowed, since hue is circular).

References

See Also

swatch