Skip to contents

Extract the hue, chroma, or luminance color components from a vector of colors.

Usage

clr_extract_chroma(col)

Arguments

col

a color object or vector of any of the three kinds of R color specifications, i.e., either a color name (as listed by colors()), a hexadecimal string of the form "#rrggbb" or "#rrggbbaa" (see rgb), or a positive integer i meaning palette()[i].

Value

Numeric vector of values.

Details

The range of the value are

- hue ranges from 0 to 360 - luminance ranges from 0 to 100 - chroma while depended on hue and luminance will roughly be within 0 and 180

Use [clr_extract()] if you are planning to extraction multiple components.

See also

Other Extraction: clr_extract_hue(), clr_extract_red(), clr_extract()

Examples

clr_extract_hue(rainbow(100), "HCL")
#>   [1]  12.1739887  12.5302714  13.2015510  14.2398051  15.7430157  17.9396131
#>   [7]  20.6365802  24.0326600  28.2023541  33.5599592  39.4350206  46.0478802
#>  [13]  53.6962691  61.1173959  68.4407007  75.3665525  82.0828750  87.6791099
#>  [19]  92.9689318  98.2979618 102.9073258 107.0867164 111.0442987 114.2859046
#>  [25] 117.0913507 119.4873528 121.6270620 123.2773659 124.6159577 125.7341620
#>  [31] 126.5222227 127.0862641 127.4716524 127.6689913 127.8328513 128.0974390
#>  [37] 128.5328540 129.1847482 130.0908944 131.3881900 132.9730189 134.9860723
#>  [43] 137.7057734 140.9107610 144.8906287 150.1694652 156.2577745 163.5669106
#>  [49] 172.0822452 182.2187787 192.1739732 202.4573445 213.6002604 223.4232217
#>  [55] 232.0965424 239.8491817 245.7571236 250.5155082 254.3158818 257.5112435
#>  [61] 259.8556823 261.6876518 263.1776038 264.2129297 264.9549319 265.4743361
#>  [67] 265.7490012 265.9344726 266.1576311 266.5927854 267.2280801 268.1125028
#>  [73] 269.3609434 270.8452148 272.6594477 274.9853679 277.5539377 280.5125708
#>  [79] 283.8653651 287.8641378 291.9775396 296.3905510 301.3439416 306.1207588
#>  [85] 311.0448333 316.4386201 322.6497933 328.7508750 334.9226504 341.3394204
#>  [91] 346.9863209 352.1179165 356.9182244   0.7482111   3.9356361   6.6650495
#>  [97]   8.6457004  10.1218986  11.1498351  11.8181167
clr_extract_chroma(rainbow(100))
#>   [1] 179.04136 177.10609 173.60539 168.53740 161.86347 153.31108 144.39941
#>   [8] 135.13358 126.03721 117.09277 109.90318 104.25925 100.24107  98.47797
#>  [15]  98.61770 100.48938 104.10576 106.86166 106.89691 107.88662 109.54895
#>  [22] 111.75326 114.51391 117.31905 120.18912 123.00195 125.82580 128.22427
#>  [29] 130.32270 132.18812 133.56783 134.58982 135.30520 135.67699 135.36075
#>  [36] 134.35760 132.74518 130.41678 127.34084 123.23593 118.64967 113.41841
#>  [43] 107.24793 101.06907  94.71606  88.04609  82.24719  77.30391  73.67307
#>  [50]  71.74450  72.09871  70.92201  72.32633  76.07360  81.82223  89.56720
#>  [57]  97.71003 106.08767 114.11365 121.67286 127.33057 131.28117 133.51608
#>  [64] 133.96851 133.32146 132.14134 131.19480 130.75437 131.00934 131.46659
#>  [71] 132.04755 132.70697 133.39322 133.91845 134.24759 134.33337 134.17043
#>  [78] 133.83221 133.42875 133.09715 133.06693 133.49874 134.66528 136.57380
#>  [85] 134.22408 130.40195 127.79108 126.89761 127.60038 130.08257 133.87695
#>  [92] 138.82331 144.97852 151.16036 157.33546 163.50269 168.56695 172.70592
#>  [99] 175.79016 177.89068
clr_extract_luminance(rainbow(100))
#>   [1] 53.24079 53.60957 54.28831 55.29940 56.68807 58.57857 60.71191 63.16228
#>   [9] 65.89278 69.07098 72.26072 75.61941 79.35472 82.97263 86.68063 90.46051
#>  [17] 94.55457 96.75739 95.65703 94.55998 93.60533 92.72372 91.86516 91.13774
#>  [25] 90.48561 89.90853 89.37479 88.94964 88.59520 88.29194 88.07403 87.91582
#>  [33] 87.80661 87.75033 87.74531 87.77076 87.81205 87.87254 87.95415 88.06626
#>  [41] 88.19634 88.35183 88.54686 88.75804 88.99741 89.28457 89.58419 89.91367
#>  [49] 90.27335 90.69053 91.11322 86.76756 82.12286 77.76587 73.41459 68.79193
#>  [57] 64.49163 60.24473 56.07922 51.76843 47.90478 44.28084 40.77353 37.92425
#>  [65] 35.60273 33.80044 32.77642 32.36890 32.62660 33.11981 33.81896 34.75429
#>  [73] 36.00730 37.40776 39.00771 40.90976 42.85222 44.92634 47.11166 49.54462
#>  [81] 51.90416 54.32571 56.96391 59.47859 59.75985 58.95441 58.15139 57.45286
#>  [89] 56.80824 56.18125 55.65103 55.17687 54.73281 54.37378 54.06913 53.80232
#>  [97] 53.60440 53.45413 53.34795 53.27819