Description Usage Arguments Value Examples
View source: R/playingWithColours.R
Find the colours in a reference set closest to a specified set of colours (in RGB space with L1 norm).
1 2 3 4 5 |
colours |
The search colours, in any form but usually in hex |
reference |
The reference set of colours |
A set of colours in the reference set closest to those in the search set;
for colour_distance
a dist
object of pairwise distances.
1 2 3 4 5 6 7 8 9 10 11 12 13 | set.seed(1234)
rc <- random_colours(10)
cols <- as.vector(rbind(rc, closest_colours(rc)))
showColours(cols)
d <- dist_lab(cols)
ds <- cmdscale(d)/1000
plot(ds, asp = 1, type = "n", bty = "n",
xlab = "First coordinate", ylab = "Second coordinate")
text(ds, labels = cols, pos = avoid(ds), cex = 0.7,
offset = 0.35, xpd = NA)
i <- 2*(1:10)
segments(ds[i-1, ], ds[i, ])
points(ds, pch = 19, col = cols)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.