vectorized make_styles for crayon output
Usage
make_styles(
style = NULL,
text,
bg = FALSE,
bg_style = NULL,
grey = FALSE,
colors = NULL,
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
charactervector of one or more styles. WhenNULLorNA, no style is applied, except whenbg_styleis supplied and is neitherNAnorNULL, in which case entries with abg_styleand nostylewill usesetTextContrastColor()to define a contrastingstyle.- text
charactervector (or coerced tocharacter) of one or more values,.- bg
logicalindicating whether thestyleshould be applied to the background instead of foreground. This argument is ignored whenbg_styleis supplied.- bg_style
NULLor acharactervector of one or more background styles. When this argument is not NULL, it applies both the foregroundstyleand backgroundbg_styletogether, and therefore ignoresCrangeandLrangesettings.- grey
logical, default FALSE, whether to use greyscale.- colors
integer, default NULL, number of colors for console output, when NULL it callscrayon::num_colors()to detect console capabilities.- Cgrey
numericchroma (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, setCgrey=-1.- lightMode
logicalindicating whether the background color is light (TRUE is bright), or dark (FALSE is dark.) By default it callscheckLightMode()which queriesgetOption("lightMode").- Crange
numericrange of chroma values, ranging between 0 and 100. When NULL, default values will be assigned to Crange. When supplied, range(Crange) is used.- Lrange
numericrange of luminance values, ranging between 0 and 100. When NULL, default values will be assigned to Lrange. When supplied, range(Lrange) is used.- adjustRgb
numericvalue adjustment used during the conversion of RGB colors to ANSI colors, which is inherently lossy. If not defined, it uses the default returned bysetCLranges()which itself usesgetOption("jam.adjustRgb")with default=0. In order to boost color contrast, an alternate value of -0.1 is suggested.- adjustPower
numericadjustment power factor- fixYellow
logicalindicating 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 toapplyCLrange().- colorTransparent
charactercolor used to substitute for "transparent" which a valid R color, but not a valid color for the crayon package.- alphaPower
numericvalue, 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
characterorlogicalwhether to updateCrangeandLrangeoptions during the subsequent call tosetCLranges(). By default,"ifnull"will update only options which were previouslyNULL;"FALSE"prevents modifying the global options;"TRUE"will update these options with the current values.
- verbose
logicalindicating whether to print verbose output- ...
additional parameters are ignored
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.
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.
See also
Other jam internal functions:
handleArgsText(),
jamCalcDensity(),
make_html_styles(),
smoothScatterJam()