Convert standard HCL hue to warped (virtual) hue by colorjam preset
Usage
h2hw(
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.
Details
This function is intended to convert from a vector of hue values to
the warped 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 input 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(),
h2hwOptions(),
hcl_to_hsl_hue(),
hsl_to_hcl_hue(),
hw2h(),
mean_angle(),
plot_colorjam_preset(),
remap_colorjam_preset(),
validate_colorjam_preset()
Other hue warp functions:
h2hwOptions()
Examples
## Yellow when using an RGB color wheel is 60 degrees,
## but on an RYB color wheel is 120 degrees.
h2hw(60, preset="ryb");
#> [1] 120
# RGB colors are convenient, but are not ideal especially when blending
# colors. Note that blue and yellow have hues that differ by exactly 180
# degrees, meaning a hue average is as likely to be purple as green.
huesBY <- jamba::col2hcl(c("blue", "yellow"))["H",];
huesBY;
#> [1] 265.87459 85.86596
warpedHuesBY <- h2hw(huesBY, preset="ryb");
warpedHuesBY;
#> [1] 263.5224 145.8660