# Color table list
# Michael Minn
# 27 June 2021
col = as.data.frame(t(col2rgb(colors())))
rownames(col) = colors()
print.colors = function(x) {
# x = x[order(sapply(1:nrow(x), function(z) max(x[z,]))), ]
v = rgb2hsv(x$red, x$green, x$blue)
x = x[order(v[2,], v[3,]),]
cat("
\n")
for (z in 1:nrow(x)) {
text.color = ifelse(sum(x[z,]) > 384, "black", "white")
hex = sprintf("#%02x%02x%02x", x$red[z], x$green[z], x$blue[z])
cat(sprintf("
%s (%s)
\n",
hex, text.color, rownames(x)[z], hex))
}
cat("
\n")
}
cat("Grays (R == G == B)
\n")
print.colors(col[(col$red == col$blue) & (col$blue == col$green),])
cat("Reds (R > G & R > B)
\n")
print.colors(col[(col$red > col$green) & (col$red > col$blue),])
cat("Blues (B > R & B > G)
\n")
print.colors(col[(col$blue > col$red) & (col$blue > col$green),])
cat("Greens (G > R & G > B)
\n")
print.colors(col[(col$green > col$red) & (col$green > col$blue),])
cat("Yellows (R == G & R > B)
\n")
print.colors(col[(col$red == col$green) & (col$red > col$blue),])
cat("Cyans (G == B & G > R)
\n")
print.colors(col[(col$green == col$blue) & (col$green > col$red),])
cat("Magentas (R == B & R > G)
\n")
print.colors(col[(col$red == col$blue) & (col$red > col$green),])