closest_colours: Find Closest Colours

Description Usage Arguments Value Examples

View source: R/playingWithColours.R

Description

Find the colours in a reference set closest to a specified set of colours (in RGB space with L1 norm).

Usage

1
2
3
4
5

Arguments

colours

The search colours, in any form but usually in hex

reference

The reference set of colours

Value

A set of colours in the reference set closest to those in the search set; for colour_distance a dist object of pairwise distances.

Examples

 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)

BillVenables/WWRGraphics documentation built on Feb. 1, 2021, 12:13 p.m.