Get hue color warp options used to convert color wheels
Arguments
- h1
numeric
vector of color hue values which represent the "from" hue angles, also referred to as "hue warp" or "hw" values. One example of a typical operation: one may want to know the R hue for a particular red-yellow-blue hue. In this scenario theh1
"hue warp" is the red-yellow-blue hue, and the "hue" is the R typical hue used incolorspace::polarLUV()
grDevices::hcl()
, andfarver::convert_colour()
. For evenly-spaced red-yellow-blue colors, one would define a sequence of "hue warp" values from 0 to 360, then convert them to the default hue used by other R functions.- h2
numeric
vector of color hue values which represent the "to" hue angles, also referred to as "hue" or "h".- preset
character
string indicating whether to defineh1
, andh2
values based upon named presets:"custom"
uses values defined inoptions("h2hw.h1")
andoptions("h2hw.h2")
if they exist, otherwisedefault_preset
.other
character
values obtained bycolorjam_presets()
, some examples include:"dichromat"
(default) color wheel intended to be color-blind friendly by omitting much of the green color region from the color wheel, and by reviewing output bydichromat::dichromat()
"ryb"
basic red-yellow-blue color wheel"ryb1"
,"ryb2"
,"ryb3"
experimental red-yellow-blue alternative color wheels designed to emphasize various features in the red-orange-yellow-green range to varying degrees."rgb"
for the default R red-green-blue color wheel
- default_preset
character
string indicating which value inpreset
should be used as the default whenreset=FALSE
andh1
and/orh2
are not defined inoptions()
.- reset
logical whether to reset
h1
andh2
values to the default values as defined inh1default
andh2default
. Whenreset=TRUE
all otherpreset
anddefault_preset
arguments are ignored.- setOptions
character
orlogical
indicating whether to updateoptions()
for"h2hw.h1"
and"h2hw.h2"
. When"ifnull"
theoptions()
are only updated if they were previouslyNULL
.- verbose
logical whether to print verbose output
Details
This function retrieves and/or defines, the h1
and h2
hue vectors used to convert between h1
"hue warp", and
h2
"actual hue".
The "actual" hue is used by standard R #' functions such as
colorspace::polarLUV()
, grDevices::hcl()
, and
farver::convert_colour()
.
The mapping from h1
to h2
allows customization of the spacing
and order of colors, which allows emulation of a red-yellow-blue
color wheel for example.
The h1
represents the color hue in terms of a degree angle ranging
from 0 to 360 - a full circle - for the observer. It is then
transformed to h2
for use in generating actual R colors.
colorjam_presets()
lists all recognized colorjam presets.add_colorjam_preset()
will add or overwrite a colorjam preset by name.
In general, most colorjam functions with argument preset
will
follow this progression:
Argument
preset=getOption("colorjam.preset", "custom")
which usespreset
when defined, otherwise"custom"
.When this option matches a recognized preset name, the corresponding
h1
,h2
values are used.When
preset="custom"
, argumentsh1
,h2
will also pollgetOption("h2hw.h1")
andgetOption("h2hw.h2")
for default values.When neither
h1
,h2
is defined, the argumentdefault_preset="dichromat"
is used to obtainh1
,h2
values.
To disable the warped hue mechanic, set preset="rgb"
which
usess the default R color wheel with no adjustment.
Details
The h1
,h2
values are passed to approx_degrees()
to convert
hue degree angles. See adjust_hue_warp()
for detailed examples
of manipulating color warp values.
See also
Other colorjam hue warp:
add_colorjam_preset()
,
add_colorjam_step()
,
adjust_hue_warp()
,
approx_degrees()
,
colorjam_presets()
,
colorjam_steps()
,
display_degrees()
,
h2hw()
,
hcl_to_hsl_hue()
,
hsl_to_hcl_hue()
,
hw2h()
,
mean_angle()
,
plot_colorjam_preset()
,
remap_colorjam_preset()
,
validate_colorjam_preset()
Other hue warp functions:
h2hw()
Examples
h2hwOptions()
#> $h1
#> [1] 12 340 306 280 240 180 120 65
#>
#> $h2
#> [1] 120.00 185.00 192.00 210.00 330.00 357.99 357.99 357.99
#>
h2hw(60)
#> [1] 9.500377
h2hwOptions(h1=c(0, 60,120,240,300,360),
h2=c(0,120,180,240,280,360))
#> $h1
#> [1] 12 340 306 280 240 180 120 65
#>
#> $h2
#> [1] 120.00 185.00 192.00 210.00 330.00 357.99 357.99 357.99
#>
h2hw(300)
#> [1] 196.1538