Extract the hue, saturation, or lightness color components from a vector of colors.
Usage
clr_extract_hue(col, space = c("HSL", "HCL"))
clr_extract_saturation(col)
clr_extract_lightness(col)
clr_extract_luminance(col)
Arguments
- col
A
colors
object (seecolor()
) or a vector of any of the three kinds of R color specifications, i.e., either a color name (as listed bygrDevices::colors()
), a hexadecimal string (seecol2rgb()
), or a positive integeri
meaninggrDevices::palette()
[i]
.- space
A character string specifying the color space where hue is extracted from. Can be either "HCL" or "HSL" (default).
Details
The range of the value are:
From 0 to 360 for hue. This in a circular fashion such that 0 and 360 are near identical. 0 is red.
From 0 to 100 for saturation where 100 is full saturation and 0 is no saturation.
From 0 to 100 for lightness where 100 is full lightness and 0 is no lightness.
Use clr_extract()
if you are planning to extraction multiple components.
See also
Other Extraction:
clr_extract()
,
clr_extract_chroma()
,
extract_rgba()
Examples
clr_extract_hue(rainbow(100), "HSL")
#> [1] 0.000000 3.529412 7.294118 10.823529 14.352941 18.117647
#> [7] 21.647059 25.176471 28.705882 32.470588 36.000000 39.529412
#> [13] 43.294118 46.823529 50.352941 53.882353 57.647059 61.176471
#> [19] 64.705882 68.470588 72.000000 75.529412 79.294118 82.823529
#> [25] 86.352941 89.882353 93.647059 97.176471 100.705882 104.470588
#> [31] 108.000000 111.529412 115.294118 118.823529 122.352941 126.117647
#> [37] 129.647059 133.176471 136.705882 140.470588 144.000000 147.529412
#> [43] 151.294118 154.823529 158.352941 162.117647 165.647059 169.176471
#> [49] 172.705882 176.470588 180.000000 183.529412 187.294118 190.823529
#> [55] 194.352941 198.117647 201.647059 205.176471 208.705882 212.470588
#> [61] 216.000000 219.529412 223.294118 226.823529 230.352941 234.117647
#> [67] 237.647059 241.176471 244.705882 248.470588 252.000000 255.529412
#> [73] 259.294118 262.823529 266.352941 270.117647 273.647059 277.176471
#> [79] 280.705882 284.470588 288.000000 291.529412 295.294118 298.823529
#> [85] 302.352941 305.882353 309.647059 313.176471 316.705882 320.470588
#> [91] 324.000000 327.529412 331.294118 334.823529 338.352941 342.117647
#> [97] 345.647059 349.176471 352.705882 356.470588
clr_extract_saturation(rainbow(100))
#> [1] 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
#> [19] 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
#> [37] 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
#> [55] 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
#> [73] 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
#> [91] 100 100 100 100 100 100 100 100 100 100
clr_extract_lightness(rainbow(100))
#> [1] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
#> [26] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
#> [51] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
#> [76] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50