col2hsl: convert R color to HSL color matrix

col2hslR Documentation

convert R color to HSL color matrix

Description

convert R color to HSL color matrix

Usage

col2hsl(x, ...)

Arguments

x

character vector with R compatible colors.

...

additional arguments are ignored.

Details

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.

See Also

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()

Examples

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)
}


jmw86069/jamba documentation built on March 26, 2024, 5:26 a.m.