Skip to contents

Shows how a color palette appears to individuals with different types of color vision deficiency using physiologically accurate models from farver.

Usage

simulate_palette_cvd(
  colors,
  cvd_type = c("all", "protan", "deutan", "tritan"),
  severity = 1,
  plot = FALSE
)

Arguments

colors

Character vector of hex colors.

cvd_type

Character. Type of CVD: "protan", "deutan", "tritan", or "all". Default is "all".

severity

Numeric. Severity of CVD from 0 (none) to 1 (complete). Default is 1.0.

plot

Logical. Whether to plot a comparison using base R graphics. Default is FALSE.

Value

If cvd_type is "all", returns a list with simulated palettes for each type (and original). Otherwise returns a character vector of simulated hex colors. The output object also inherits from huerd_simulation_result.

Examples

palette_ex <- generate_palette(6, progress = FALSE)

# Simulate complete deuteranopia
deutan_palette <- simulate_palette_cvd(palette_ex, "deutan", severity = 1.0)
print(deutan_palette)
#> 
#> -- huerd CVD Simulation Result (Type: deutan, Severity: 1.00) --
#>   [ 1] #3B3300
#>   [ 2] #0049FC
#>   [ 3] #587CC4
#>   [ 4] #A39000
#>   [ 5] #8696C0
#>   [ 6] #C5C7CD

# See all CVD types and plot them
if (interactive() && length(palette_ex) > 0) {
  all_cvd <- simulate_palette_cvd(palette_ex, "all", plot = TRUE)
}