| Title: | Generation of Random Colors | 
| Version: | 1.0.0 | 
| Description: | Generation of random colors, possibly with a given hue or a given luminosity. This is a port of the JavaScript library 'randomColor' https://randomcolor.lllllllllllllllll.com/. | 
| License: | CC0 | 
| URL: | https://github.com/stla/colorsGen | 
| BugReports: | https://github.com/stla/colorsGen/issues | 
| Depends: | R (≥ 2.10) | 
| Imports: | colorspace, grDevices, methods, stats | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.2.3 | 
| NeedsCompilation: | no | 
| Packaged: | 2023-10-28 08:19:44 UTC; SDL96354 | 
| Author: | Stéphane Laurent [aut, cre], David Merfield [cph] ('randomColor' JavaScript library) | 
| Maintainer: | Stéphane Laurent <laurent_step@outlook.fr> | 
| Repository: | CRAN | 
| Date/Publication: | 2023-10-28 15:30:02 UTC | 
Random colors
Description
Generate random colors.
Usage
randomColor(n, hue = "random", luminosity = "random")
Arguments
| n | number of colors to be generated | 
| hue | the desired hue; it can be a number between 0 and 360, a hexadecimal color code, or a string taken among the possibilities "random", "red", "orange", "yellow", "green", "blue", "purple", "pink", or "monochrome" | 
| luminosity | the desired luminosity, a string taken among the possible choices "random", "light", "bright", or "dark" | 
Value
A character vector of hexadecimal color codes.
Examples
# pie chart ####
n <- 20
clrs <- randomColor(n, hue = "red", luminosity = "dark")
opar <- par(mar = c(0, 0, 0, 0))
pie(rep(1, n), col = clrs)
par(opar)
# Fermat spiral ####
n <- 400
theta <- seq(0, n/3, length.out = n)
x <- sqrt(theta) * cos(theta)
y <- sqrt(theta) * sin(theta)
pts <- cbind(x, y)
clrs <- randomColor(n, hue = "random", luminosity = "bright")
opar <- par(mar = c(0, 0, 0, 0), bg = "black")
plot(
  pts, asp = 1, xlab = NA, ylab = NA,
  axes = FALSE, pch = 19, col = clrs
)
par(opar)