Usage
opposite_color(
col,
method = c("complement", "complement_maxcontrast", "bw_maxcontrast"),
degrees = 180
)Details
This function takes a color input (name or hex) and returns an opposite color using one of three methods:
"complement": strict 180 degrees hue complement
"complement_maxcontrast": 180 degrees hue complement adjusted for maximum contrast
"bw_maxcontrast": black or white, whichever has higher contrast The function uses the WCAG relative luminance and contrast ratio formulas to determine contrast.