color_dither: Make dithered color pattern light-dark

color_ditherR Documentation

Make dithered color pattern light-dark

Description

Make dithered color pattern light-dark

Usage

color_dither(
  x,
  L_diff = 4,
  L_max = 90,
  L_min = 30,
  min_contrast = 1.25,
  direction = 1,
  returnType = c("vector", "list", "matrix"),
  debug = FALSE,
  ...
)

Arguments

x

character vector of R colors

L_diff

numeric value added or subtracted from the L in HSL color space for each color, until contrast is at least min_contrast.

min_contrast

numeric minimum contrast as defined by colorspace::contrast_ratio() for the input and potential output color.

direction

numeric that defines the initial direction, where values >= 0 start by making colors lighter, and values < 0 make colors darker.

returnType

character string that defines the output of this function:

  • vector: two colors for every input color in x

  • matrix: two rows, input colors on first row, output colors on second row

  • list: a list with two colors in each element, with input and output colors together in each vector.

debug

logical indicating whether to plot the color iterations using showColors().

...

additional arguments are ignored.

Lmax, L_min

numeric values that define the permitted range of L values in HSL color space, which ranges from 0 to 100.

Details

This function serves a very simple purpose, mainly for printDebug() to use subtle alternating light/dark colors for vector output. It takes a color and returns two colors which are slightly lighter and darker than each other, to a minimum contrast defined by colorspace::contrast_ratio().

Value

format defined by argument returnType:

  • vector: two colors for every input color in x

  • matrix: two rows, input colors on first row, output colors on second row

  • list: a list with two colors in each element, with input and output colors together in each vector.

See Also

Other jam practical functions: breakDensity(), checkLightMode(), check_pkg_installed(), colNum2excelName(), diff_functions(), exp2signed(), fileInfo(), fixYellow(), getAxisLabel(), handleArgsText(), heads(), isFALSEV(), isTRUEV(), jamba, jargs(), kable_coloring(), lldf(), log2signed(), make_html_styles(), make_styles(), match_unique(), mergeAllXY(), middle(), minorLogTicks(), newestFile(), printDebug(), renameColumn(), rmInfinite(), rmNAs(), rmNA(), rmNULL(), sclass(), sdim(), setPrompt()

Examples

x <- "firebrick1";
showColors(color_dither(x))

showColors(color_dither(x, direction=-1))

x <- vigrep("^green[0-9]", colors())
showColors(color_dither(x))
showColors(color_dither(x, direction=-1, returnType="list"))

x <- c("green1", "cyan", "blue", "red", "gold", "yellow", "pink")
showColors(color_dither(x))

color_dither(x, debug=TRUE)

#printDebug(1:4, 5:10, 6:9, 3:6, letters[1:5], LETTERS[1:5], 1:5,
#   collapse=" ",
#   fgText=color_dither(x, returnType="list", min_contrast=1.4))


jmw86069/jamba documentation built on March 26, 2024, 5:26 a.m.