best_contrast: Find highest contrast color

View source: R/contrast_ratio.R

best_contrastR Documentation

Find highest contrast color

Description

best_contrast() finds the color in y with the highest contrast to the color x.

Usage

best_contrast(x, y = c("#010101", "#FFFFFF"))

Arguments

x

A vector of colors as described in col of color(). Must not contain any NA.

y

A vector of colors as described in col of color(). Must not contain any NA.

Value

A vector of the same length as x with, for each element of x, the element of y that has the highest contrast to x.

Examples

best_contrast("red")
best_contrast("grey20")
best_contrast("white")

best_contrast(rainbow(10), rainbow(3))

EmilHvitfeldt/prismatic documentation built on Nov. 23, 2024, 10:41 a.m.