max_chroma: Compute Maximum Chroma for Given Hue and Luminance in HCL

View source: R/max_chroma.R

max_chromaR Documentation

Compute Maximum Chroma for Given Hue and Luminance in HCL

Description

Compute approximately the maximum chroma possible for a given hue and luminance combination in the HCL color space.

Usage

max_chroma(h, l, floor = FALSE)

max_chroma_table

Arguments

h

hue value in the HCL color description, has to be in [0, 360].

l

luminance value in the HCL color description, has to be in [0, 100].

floor

logical. Should the chroma value be rounded down to the next lower integer?

Details

As the possible combinations of chroma and luminance depend on hue, it is not obvious which maximum chroma can be used for a given combination of hue and luminance prior to calling polarLUV. To avoid having to fixup the color upon conversion to RGB hex codes, the max_chroma function computes (approximately) the maximum chroma possible. The computations are based on interpolations of pre-computed maxima in max_chroma_table, containing the maximum chroma for a given hue-luminance combination (both in integers). Hence, the result may sometimes still be very slightly larger than the actual maximum which can be avoided by taking the floor of the approximate value.

Value

A numeric vector with the maximum chroma coordinates.

See Also

polarLUV, hex

Examples

max_chroma(h = 0:36 * 10, l = 50)
max_chroma(h = 120, l = 0:10 * 10)

colorspace documentation built on Jan. 25, 2023, 3:12 p.m.