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

Description Usage Arguments Details Value See Also Examples

View source: R/max_chroma.R

Description

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

Usage

1
2
3

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

1
2
max_chroma(0:36 * 10, 50)
max_chroma(120, 0:10 * 10)

Example output

 [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
 [1]   0.00  14.44  28.04  41.67  55.35  69.06  82.79  96.53 110.28 122.90
[11]   0.00

colorspace documentation built on May 2, 2019, 12:49 p.m.