color_match: Match colors by visual distance

View source: R/utils_css_color.R

color_matchR Documentation

Match colors by visual distance

Description

Helpful for pairing colors across light/dark palettes

Usage

color_match(x, y, with_replacement = TRUE)

Arguments

x

chr Named CSS representations of colors that will be matched

y

chr Named CSS representations of colors that will be selected from as matches

with_replacement

lgl Whether colors in x should have unique matches in y, or if y can be matched with replacement. Default TRUE to match with the closest color in y, regardless if it's already been matched with a previous color in x.

Value

tbl Of matches for all of x with the associated distance

See Also

Other color: color_cycle(), color_distance(), color_luminance(), color_rgb_table(), color_separate(), color_text_by_luminance(), colors2css(), css_col2vec(), luminance_filter(), rgb2hex()

Examples

a <- list(
  light = list(
    aquamarine = "rgb(137,210,215)",
    teal = "rgb(79,194,198)",
    turquoise = "rgb(3,119,132)",
    evergreen = "rgb(0,84,92)",
    brown = "rgb(72,36,18)",
    lightbrown = "rgb(132,96,78)",
    orange = "rgb(250,173,25)",
    darkorange = "rgb(198,143,44)",
    aliceblue = "rgb(180,243,249)",
    gainsboro = "rgb(223,254,255)"
  ),
  dark = list(
    lightblue = "rgba(18,180,211,1)",
    darkblue = "rgba(2,120,170,1)",
    navyblue = "rgba(0,57,73,1)",
    brown = "rgba(72,36,18,1)",
    lightbrown = "rgb(132,96,78)",
    lighterbrown = "rgba(181,141,122, 1)",
    purple = "rgba(111,96,140,1)",
    lightpurple = "rgba(165,150,194,1)",
    darkcyan = "rgba(0,166,212,1)",
    darkturquoise = "rgba(9,119,168,1)"
  )
)
color_match(a$light, a$dark)

yogat3ch/UU documentation built on May 31, 2024, 10:14 p.m.