Convert warped (virtual) hue to standard HCL hue by colorjam preset
Usage
hw2h(
h,
h1 = NULL,
h2 = NULL,
direction = 1,
preset = getOption("colorjam.preset", "custom"),
...
)Arguments
- h
numericvector of color hues between 0 and 360. These hues do not need to be in sequential order.- h1, h2
numericvector of color hues, which by default are defined inh2hwOptions(), but allowed here in cases where the global options should be overridden but not modified.- direction
numericindicating the direction ofh1HCL hue relative toh2virtual hue:1indicates both are increasing-1indicatesh1andh2differ in direction
- preset
characterstring with a named preset fromcolorjam_presets(), for which theh1,h2,directionvalues will be obtained. Whenpreset="custom"thenh1andh2must be provided.
Value
numeric vector of color hues after applying the transformation
from h2 to h1 for the given preset.
numeric vector of hue values after applying the hue warp
operation.
Details
This function is intended to convert from a vector of warped hue values to
the hues defined by colorjam_presets() for the given preset.
Each preset defines a custom set of color hues, for example:
converting RGB to RYB color wheel
converting RGB to the customized dichromat color wheel
reversing a color wheel
Note the output hue uses the standard HCL color hue as defined
by colorspace::polarLUV(), with values ranging between 0 and 360.
By this standard, 12.2 is defined as red, 120 is defined as green, and
245 is defined as blue.
See also
Other colorjam hue warp:
add_colorjam_preset(),
add_colorjam_step(),
adjust_hue_warp(),
approx_degrees(),
colorjam_presets(),
colorjam_steps(),
display_degrees(),
h2hw(),
h2hwOptions(),
hcl_to_hsl_hue(),
hsl_to_hcl_hue(),
mean_angle(),
plot_colorjam_preset(),
remap_colorjam_preset(),
validate_colorjam_preset()
Other colorjam hue warp:
add_colorjam_preset(),
add_colorjam_step(),
adjust_hue_warp(),
approx_degrees(),
colorjam_presets(),
colorjam_steps(),
display_degrees(),
h2hw(),
h2hwOptions(),
hcl_to_hsl_hue(),
hsl_to_hcl_hue(),
mean_angle(),
plot_colorjam_preset(),
remap_colorjam_preset(),
validate_colorjam_preset()
Examples
# It can be useful to create a uniform sequence of angles in warped
# hues, which are visually more uniform than those using an RGB color wheel,
# then convert those hues to standard color hues.
warpedHues <- seq(from=0, to=330, length.out=12);
warpedHues;
#> [1] 0 30 60 90 120 150 180 210 240 270 300 330
# rgb imposes no change
hues <- hw2h(warpedHues, preset="rgb");
hues;
#> [1] 0 30 60 90 120 150 180 210 240 270 300 330
# ryb imposes changes
hues <- hw2h(warpedHues, preset="ryb");
hues;
#> [1] 12 24 36 48 60 90 120 180 240 273 306 339