make_styles: vectorized make_styles for crayon output

make_stylesR Documentation

vectorized make_styles for crayon output

Description

vectorized make_styles for crayon output

Usage

make_styles(
  style = NULL,
  text,
  bg = FALSE,
  bg_style = NULL,
  grey = FALSE,
  colors = num_colors(),
  Cgrey = getOption("jam.Cgrey", 5),
  lightMode = NULL,
  Crange = getOption("jam.Crange"),
  Lrange = getOption("jam.Lrange"),
  adjustRgb = getOption("jam.adjustRgb"),
  adjustPower = 1.5,
  fixYellow = TRUE,
  colorTransparent = "grey45",
  alphaPower = 2,
  setOptions = c("ifnull", "FALSE", "TRUE"),
  verbose = FALSE,
  ...
)

Arguments

style

character vector of one or more styles. When NULL or NA, no style is applied, except when bg_style is supplied and is neither NA nor NULL, in which case entries with a bg_style and no style will use setTextContrastColor() to define a contrasting style.

text

character vector (or coerced to character) of one or more values,.

bg

logical indicating whether the style should be applied to the background instead of foreground. This argument is ignored when bg_style is supplied.

bg_style

NULL or a character vector of one or more background styles. When this argument is not NULL, it applies both the foreground style and background bg_style together, and therefore ignores Crange and Lrange settings.

colors

integer number of colors allowed for console output.

Cgrey

numeric chroma (C) value, which defines grey colors at or below this chroma. Any colors at or below the grey cutoff will have use ANSI greyscale coloring. To disable, set Cgrey=-1.

lightMode

logical indicating whether the background color is light (TRUE is bright), or dark (FALSE is dark.) By default it calls checkLightMode() which queries getOption("lightMode").

Crange

numeric range of chroma values, ranging between 0 and 100. When NULL, default values will be assigned to Crange. When supplied, range(Crange) is used.

Lrange

numeric range of luminance values, ranging between 0 and 100. When NULL, default values will be assigned to Lrange. When supplied, range(Lrange) is used.

adjustRgb

numeric value adjustment used during the conversion of RGB colors to ANSI colors, which is inherently lossy. If not defined, it uses the default returned by setCLranges() which itself uses getOption("jam.adjustRgb") with default=0. In order to boost color contrast, an alternate value of -0.1 is suggested.

adjustPower

numeric adjustment power factor

fixYellow

logical indicating whether to "fix" the darkening of yellow, which otherwise turns to green. Instead, since JAM can, JAM will make the yellow slightly more golden before darkening. This change only affects color hues between 80 and 90. This argument is passed to applyCLrange().

colorTransparent

character color used to substitute for "transparent" which a valid R color, but not a valid color for the crayon package.

alphaPower

numeric value, used to adjust the RGB values for alpha values less than 255, by raising the ratio to 1/alphaPower, which takes the ratio of square roots. alphaPower=100 for minimal adjustment.

setOptions

character or logical whether to update Crange and Lrange options during the subsequent call to setCLranges(). By default,

  • "ifnull" will update only options which were previously NULL;

  • "FALSE" prevents modifying the global options;

  • "TRUE" will update these options with the current values.

verbose

logical indicating whether to print verbose output

...

additional parameters are ignored

satCutoff

numeric cutoff for color saturation, below which a color is considered grey and the ANSI greyscale color set is used.

Details

This function is essentially a vectorized version of crayon::make_style() in order to style a vector of character strings with a vector of foreground and background styles.

Value

character vector with the same length as text input vector, where entries are surrounded by the relevant encoding consistent with the style defined at input. In short, a character vector as input, a colorized character vector as output.

See Also

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

Other jam color functions: alpha2col(), applyCLrange(), col2alpha(), col2hcl(), col2hsl(), col2hsv(), color2gradient(), fixYellowHue(), fixYellow(), getColorRamp(), hcl2col(), hsl2col(), hsv2col(), isColor(), kable_coloring(), makeColorDarker(), make_html_styles(), rgb2col(), setCLranges(), setTextContrastColor(), showColors(), unalpha(), warpRamp()


jmw86069/jamba documentation built on Oct. 9, 2024, 10:52 a.m.