Return Crange, Lrange, Cgrey, adjustRgb values for the given lightMode, intended to provide ranges suitable for contrasting text displayed on a light or dark background.
Arguments
- lightMode
logicalindicating whether the background color is light (TRUE is bright), or dark (FALSE is dark.)When TRUE or FALSE, it will set default values for Crange and Lrange.
When NULL, it will use one or both of Crange,Lrange when supplied, and uses
getOption("jam.Crange")andgetOption("jam.Lrange")by default when not explicitly provided.If lightMode is NULL and one or both of Crange, Lrange are NULL, it calls
checkLightMode()then assigns appropriate default values.To detect lightMode again, use
lightMode=checkLightMode().
- Crange
numericrange of chroma values, ranging between 0 and 100. By default,getOptions("Crange")is used, otherwise defaults will be assigned based uponlightMode.- Lrange
numericrange of luminance values, ranging between 0 and 100. By default,getOptions("Crange")is used, otherwise defaults will be assigned based uponlightMode.- Cgrey
numericchroma (C) value, which defines grey colors at or below this chroma. Any colors at or below the grey cutoff will have their C values unchanged. This threshold prevents colorizing greyscale colors via Crange. To disable the effect, setCgrey=-1.- adjustRgb
numericcolor adjustment factor, used during the conversion of RGB colors to the ANSI-compatible colors used by thecrayonpacakge. The ANSI color range does not include a full RGB palette, and the conversion is somewhat lossy. By default,getOptions("jam.adjustRgb")is used to store a globally re-usable value.- setOptions
characterorlogicalwhether to updateoptions()"jam.Crange"and"jam.Lrange", with default 'FALSE'. It has the following behavior:FALSEor"FALSE"does not update options.TRUEor"TRUE"will update options 'jam.Crange' and 'jam.Lrange'."ifnull"will update onlyoptions()which were previously blank.
- verbose
logicalindicating whether to print verbose output.- ...
additional arguments are ignored.
Value
list, invisibly, with elements:
- Crange
Numeric vector of length 2, defining the HCL chroma (C) range.
- Lrange
Numeric vector of length 2, defining the HCL luminance (L) range.
- adjustRgb
Numeric vector of length 1, defining the adjustment to apply during RGB-to-ANSI color conversion.
- Cgrey
Numeric vector of length 1, defining the HCL chroma (C) value below which colors are considered greyscale, and are converted to ANSI greyscale colors. HCL chroma ranges from 0 to 100. Set value
Cgrey=-1orCgrey=FALSEto disable this logic, causing colors to be matched using all available ANSI color values.
Details
This function is intended mainly for internal use by jamba
such as printDebug(), and make_styles(), which is also mainly
intended for console text or other printed text output.
The utility of this function is to store the logic of determining
sensible default ranges.
Companion functions:
applyCLranges()is used to apply the ranges to a vector of R colors.checkLightMode()is used to detect whether console output is expected to have a light or dark background.
See also
Other jam color functions:
alpha2col(),
applyCLrange(),
col2alpha(),
col2hcl(),
col2hsl(),
col2hsv(),
color2gradient(),
fixYellow(),
fixYellowHue(),
getColorRamp(),
hcl2col(),
hsl2col(),
hsv2col(),
isColor(),
kable_coloring(),
makeColorDarker(),
rainbow2(),
rgb2col(),
setTextContrastColor(),
showColors(),
unalpha(),
warpRamp()