col2hsl | R Documentation |
convert R color to HSL color matrix
col2hsl(x, ...)
x |
|
... |
additional arguments are ignored. |
This function takes an R color and converts to an HSL matrix, using
the farver
package farver::decode_colour()
the colorspace package, and RGB
and
polarLUV
functions. It is also used to
maintain alpha transparency, to enable interconversion via other
color manipulation functions as well.
When model="hsl"
this function uses farver::decode_colour()
and bypasses colorspace
. In future the colorspace
dependency
will likely be removed in favor of using farver
. In any event,
model="hsl"
is equivalent to using model="polarLUV"
and
fixup=TRUE
, except that it should be much faster.
Other jam color functions:
alpha2col()
,
applyCLrange()
,
col2alpha()
,
col2hcl()
,
col2hsv()
,
color2gradient()
,
fixYellowHue()
,
fixYellow()
,
getColorRamp()
,
hcl2col()
,
hsl2col()
,
hsv2col()
,
isColor()
,
kable_coloring()
,
makeColorDarker()
,
make_html_styles()
,
make_styles()
,
rgb2col()
,
setCLranges()
,
setTextContrastColor()
,
showColors()
,
unalpha()
,
warpRamp()
x <- c("#FF000044", "#FF0000", "firebrick");
names(x) <- x;
showColors(x)
xhsl <- col2hsl(x)
xhsl
xhex <- hsl2col(xhsl)
showColors(list(x=x,
xhex=xhex),
groupCellnotes=FALSE)
opar <- par("mfrow"=c(4, 4));
on.exit(par(opar));
for (H in seq(from=0, to=360, length.out=17)[-17]) {
S <- 75;
Lseq <- seq(from=15, to=95, by=10);
hsl_gradient <- hsl2col(
H=H,
S=85,
L=Lseq);
hcl_gradient <- hcl2col(
H=H,
C=85,
L=Lseq);
names(hsl_gradient) <- Lseq;
names(hcl_gradient) <- Lseq;
showColors(
list(
hsl=hsl_gradient,
hcl=hcl_gradient),
main=paste0("Hue: ", round(H),
"\nSat: ", S,
"\nLum: (as labeled)"),
groupCellnotes=FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.