validate_colorjam_preset: Validate h1,h2 color hue warp data

validate_colorjam_presetR Documentation

Validate h1,h2 color hue warp data

Description

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

numeric color hue in degrees

direction

numeric with 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

numeric passed to round() before comparing h2 values for duplicated values.

...

additional arguments are ignored.

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,h2 angles are adjusted within range c(0, 360) using x %% 360.

  • h1,h2 values are rounded using round(x, digits=digits)

  • h1,h2 values are sorted by h2 increasing, and h1 in order of direction

  • Duplicated h2 values are adjusted by adding c(0, 1, 2, ...) + 1e-8 to 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 by 1e-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 h2 values cause the corresponding h1 values to be skipped, thus removing that range of hues. When one h2 value is increased, it should also increase subsequent values.

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 in h1.

  • direction: with 1 indicating forward (increasing, clockwise) progression around the color wheel, and -1 indicating reverse (decreasing, counter-clockwise) progression around the color wheel.

  • default_step: character string with name matching a value returned by colorjam_steps()

See Also

Other colorjam hue warp: add_colorjam_preset(), add_colorjam_step(), adjust_hue_warp(), approx_degrees(), colorjam_presets(), colorjam_steps(), display_degrees(), h2hwOptions(), h2hw(), hcl_to_hsl_hue(), hsl_to_hcl_hue(), hw2h(), mean_angle(), plot_colorjam_preset(), remap_colorjam_preset()


jmw86069/colorjam documentation built on March 18, 2024, 3:32 a.m.