hsl {RcppColors} | R Documentation |
HSL color specification
Description
Converts a color given in HSL coordinates to a hexadecimal string.
Usage
hsl(h = 360, s = 100, l = 100, alpha = NULL)
Arguments
h |
the hue, a number between |
s |
the saturation, a number between |
l |
the lightness, a number between |
alpha |
opacity, a number between |
Value
The hsl
function returns a hexadecimal string representing
the corresponding color.
Examples
saturation <- 100
f <- Vectorize(
function(x, y){
z <- complex(real = x, imaginary = y)
modulus <- Mod(z)
if(modulus > 1){
return("#ffffff")
}
radians <- Arg(z)
if(radians < 0){
radians <- radians + 2*pi
}
degrees <- 360 * radians / 2 / pi
hsl(h = degrees, s = saturation, l = 100*modulus)
}
)
x <- y <- seq(-1, 1, length.out = 200L)
image <- outer(x, y, f)
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(-1, 1), ylim = c(-1, 1), asp = 1)
rasterImage(image, -1, -1, 1, 1)
par(opar)
[Package RcppColors version 0.6.0 Index]