Extract the red, green, or blue color components from a vector of colors.
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]
.
Details
The values of the output will range between 0 and 255.
Use clr_extract()
if you are planning to extract multiple components.
See also
Other Extraction:
clr_extract()
,
clr_extract_chroma()
,
clr_extract_hue()
Examples
clr_extract_red(rainbow(100))
#> [1] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 250
#> [19] 235 219 204 189 173 158 143 128 112 97 82 66 51 36 20 5 0 0
#> [37] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [55] 0 0 0 0 0 0 0 0 0 0 0 0 0 5 20 36 51 66
#> [73] 82 97 112 128 143 158 173 189 204 219 235 250 255 255 255 255 255 255
#> [91] 255 255 255 255 255 255 255 255 255 255
clr_extract_green(rainbow(100))
#> [1] 0 15 31 46 61 77 92 107 122 138 153 168 184 199 214 229 245 255
#> [19] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
#> [37] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 240 224 209
#> [55] 194 178 163 148 133 117 102 87 71 56 41 25 10 0 0 0 0 0
#> [73] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [91] 0 0 0 0 0 0 0 0 0 0
clr_extract_blue(rainbow(100))
#> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [19] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 26
#> [37] 41 56 71 87 102 117 133 148 163 179 194 209 224 240 255 255 255 255
#> [55] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
#> [73] 255 255 255 255 255 255 255 255 255 255 255 255 245 230 214 199 184 168
#> [91] 153 138 122 107 92 76 61 46 31 15
clr_extract_alpha(rainbow(100))
#> [1] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
#> [19] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
#> [37] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
#> [55] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
#> [73] 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
#> [91] 255 255 255 255 255 255 255 255 255 255