Validate h1,h2 color hue warp data, internal function
Usage
validate_colorjam_preset(
h1 = NULL,
h2 = NULL,
direction = NULL,
default_step = NULL,
preset = NULL,
digits = 4,
...
)Arguments
- h1, h2
numericcolor hue in degrees- direction
numericwith one of two accepted values:1: (default) indicating forward (increasing, clockwise) progression around the color wheel-1: indicating reverse (decreasing, counter-clockwise) progression around the color wheel.
- digits
numericpassed toround()before comparingh2values for duplicated values.- ...
additional arguments are ignored.
Value
list with components:
h1: HCL color hue indicating the actual hue to be used when generating a color.h2: HCL color hue indicating the virtual hue assigned to each actual hue inh1.direction: with1indicating forward (increasing, clockwise) progression around the color wheel, and-1indicating reverse (decreasing, counter-clockwise) progression around the color wheel.default_step:characterstring with name matching a value returned bycolorjam_steps()
Details
Validate the h1,h2 color hue values alongside the direction
the angles should proceed. This function handles cases where
h2 contains duplicate values, which is used to remove a
section of h1 from the output h2 color wheel. Duplicated
values are not handled well by approx(), so this function
rounds values to 4 digits, then sorts data based upon direction,
then finally adjusts any duplicated h2 values by adding
1e-8.
Processing steps:
h1,h2angles are adjusted within rangec(0, 360)usingx %% 360.h1,h2values are rounded usinground(x, digits=digits)h1,h2values are sorted byh2increasing, andh1in order ofdirectionDuplicated
h2values are adjusted by addingc(0, 1, 2, ...) + 1e-8to each duplicated value, per set of duplicated values. The first duplicated value in each set is unchanged, and subsequent values in the set are increased by1e-8.
TODO:
Enforce sensible ordering of values, mainly so the R-shiny app h1,h2 edited values will permit pushing identical values. For example, two identical
h2values cause the correspondingh1values to be skipped, thus removing that range of hues. When oneh2value is increased, it should also increase subsequent 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(),
h2hwOptions(),
hcl_to_hsl_hue(),
hsl_to_hcl_hue(),
hw2h(),
mean_angle(),
plot_colorjam_preset(),
remap_colorjam_preset()