color_lgl: Perform logical tests on colors in RGB and/or HSV space

View source: R/logic.R

color_lglR Documentation

Perform logical tests on colors in RGB and/or HSV space

Description

color_lgl() takes a vector of R or hex colors and performs logical tests on RGB values (r, g, and/or b) and/or HSV values (h, s, and v) supplied in the form of logial expressions (see Examples).

Usage

color_lgl(color_vec, ...)

Arguments

color_vec

A vector of hex or R colors.

test

A logical test to perform on the set of colors

Value

a logical vector indicating which members of the color vector pass the test(s)

Examples


color_vec <- c("#FF0000","dodgerblue","orange","808080","#000000")

# Which colors have an R value > 0.5 in RGB space (scaled between 0 and 1)?
color_lgl(color_vec,
          r > 0.5)

# Which colors have R or B > 0.3 in RGB space?
color_lgl(color_vec,
          r > 0.3 | g > 0.3)

# Which colors are highly saturated (S > 0.8 in HSV space)?
color_lgl(color_vec,
          s > 0.8)

# Which colors are dark (low V in HSV space)?
color_lgl(color_vec,
          v < 0.2)

# Which colors are bright, saturated red?
color_lgl(color_vec,
          r > 0.7 & s > 0.7 & v > 0.7)

hypercompetent/colorway documentation built on April 2, 2024, 1:44 a.m.