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

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?

Value

A numeric vector with the maximum chroma coordinates.

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.

See also

Examples

max_chroma(h = 0:36 * 10, l = 50)
#>  [1] 137.96 161.61 121.85  91.86  75.55  65.86  59.99  56.66  55.28  55.61
#> [11]  57.70  61.92  69.06  72.78  58.06  49.54  44.38  41.33  39.81  39.55
#> [21]  40.52  42.87  47.04  53.90  65.45  86.65 124.44 123.87 127.15 131.17
#> [31] 119.54 112.95 110.23 110.93 115.15 123.62 137.96
max_chroma(h = 120, l = 0:10 * 10)
#>  [1]   0.00  14.44  28.04  41.67  55.35  69.06  82.79  96.53 110.28 122.90
#> [11]   0.00