Convert colors to data.frame of color attributes
colors_to_df(x, ..., alpha = TRUE, byCols = NULL)
character
vector of R colors
any valid criteria to subset the color data.frame
.
logical
indicating whether to retain alpha
transparency in intermediate operations. When alpha=FALSE
then
all color transparency is ignored, and colors will be returned
with no transparency.
character
vector of colnames to sort after the subset
operation.
data.frame
with color attributes as columns.
When byCols
is defined, the data.frame
is sorted using
jamba::mixedSortDF()
.
When ...
is supplied, subset()
is applied to subset colors.
This function takes a vector of colors and returns a data.frame
with relevant color attributes:
"num"
contains the integer index of the input vector x
.
"hex"
contains character
values with hexadecimal colors
including alpha. If the input x
is "red"
then the hex value
will be converted to "#FF0000FF"
.
"name"
if names(x)
is not empty
jamba::col2hcl()
"H"
contains color hue as values from 0
to 360
.
"C"
contains color chroma (aka saturation) ranging from 0
up to 200
,
where typical "full saturation" is represented as values above 100.
"L"
contains color luminance (brightness/lightness) ranging from
0
to 100
.
"alpha"
the alpha transparency, ranging from 0
(fully transparent)
to 1
(fully opaque, not transparent).
grDevices::col2rgb()
"red"
contains the red color channel, values range from 0
to 255
.
"green"
contains the green color channel, values range from 0
to 255
.
"blue"
contains the blue color channel, values range from 0
to 255
.
jamba::col2hsv()
"h"
contains color hue as values from 0
to 1
. Note these values
may not map directly to color hue obtained from jamba::col2hcl()
.
"s"
contains color saturation with values from 0
to 1
.
"v"
contains color vibrance (brightness/lightness) with values
from 0
to 1
.
jamba::col2hsl()
"hsl_h"
contains color hue as values from 0
to 1
. Note these values
may not map directly to color hue obtained from jamba::col2hcl()
.
"hsl_s"
contains color saturation with values from 0
to 100
.
"hsl_l"
contains color luminance (brightness/lightness) with values
from 0
to 100
.
Other colorjam sort:
sort_colors()
,
subset_colors()
Other colorjam core:
blend_colors()
,
closestRcolor()
,
closest_named_color()
,
color_complement()
,
group2colors()
,
rainbowJam()
,
sort_colors()
,
subset_colors()