Raxol.UI.Accessibility.HighContrast (Raxol v2.0.1)
View SourceHigh contrast mode system for improved visual accessibility in Raxol terminals.
This module provides comprehensive high contrast support including:
- Multiple high contrast themes (black/white, white/black, custom)
- WCAG 2.1 AA and AAA contrast ratio compliance
- Automatic contrast adjustment for different lighting conditions
- Color blindness accommodation (Deuteranopia, Protanopia, Tritanopia)
- Large text mode with scalable fonts
- Custom user-defined contrast schemes
- System integration with OS accessibility settings
- Dynamic contrast adjustment based on ambient light
- Color palette optimization for terminal interfaces
Features
Contrast Modes
- High Contrast Black (white text on black background)
- High Contrast White (black text on white background)
- High Contrast Custom (user-defined color schemes)
- Inverted Colors mode
- Grayscale mode with enhanced contrast
- Adaptive contrast based on content type
Accessibility Compliance
- WCAG 2.1 Level AA (4.5:1 contrast ratio)
- WCAG 2.1 Level AAA (7:1 contrast ratio)
- Color blindness simulation and correction
- Focus indicator enhancement
- Text shadow and outline options for improved readability
Usage
# Initialize high contrast system
{:ok, hc} = HighContrast.start_link(
default_theme: :high_contrast_black,
compliance_level: :wcag_aa,
auto_detect_system: true,
color_blind_support: true
)
# Apply high contrast theme
HighContrast.apply_theme(hc, :high_contrast_white)
# Create custom theme with WCAG compliance
custom_theme = %{
name: "custom_blue",
background: {0, 0, 51}, # Dark blue
foreground: {255, 255, 204}, # Light yellow
accent: {255, 102, 0}, # Orange
compliance_level: :wcag_aaa
}
HighContrast.register_theme(hc, custom_theme)
# Enable color blindness accommodation
HighContrast.configure_color_blindness(hc, :deuteranopia, %{
strength: 0.8,
enable_patterns: true,
alternative_indicators: [:shapes, :textures]
})
Summary
Functions
Applies a high contrast theme.
Returns a specification to start this module under a supervisor.
Configures color blindness accommodation.
Creates a custom theme builder with WCAG validation.
Gets accessibility information for the current theme.
Gets the current active theme.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.
Lists all available themes.
Registers a custom high contrast theme.
Enables or disables large text mode.
Suggests improved colors for better contrast.
Toggles color inversion.
Validates contrast ratio compliance for a color pair.
Types
@type color_blindness_type() ::
:deuteranopia | :protanopia | :tritanopia | :achromatopsia
@type compliance_level() :: :wcag_a | :wcag_aa | :wcag_aaa
@type config() :: %{ default_theme: theme_name(), compliance_level: compliance_level(), auto_detect_system: boolean(), color_blind_support: boolean(), large_text_mode: boolean(), adaptive_contrast: boolean(), ambient_light_adjustment: boolean(), focus_enhancement: boolean(), text_shadow: boolean(), invert_colors: boolean() }
@type contrast_ratio() :: float()
@type rgb_color() :: {0..255, 0..255, 0..255}
@type theme() :: %{ name: theme_name(), background: rgb_color(), foreground: rgb_color(), accent: rgb_color(), secondary: rgb_color(), success: rgb_color(), warning: rgb_color(), error: rgb_color(), info: rgb_color(), border: rgb_color(), shadow: rgb_color(), compliance_level: compliance_level(), large_text_optimized: boolean() }
@type theme_name() :: atom()
Functions
Applies a high contrast theme.
Returns a specification to start this module under a supervisor.
See Supervisor.
Configures color blindness accommodation.
Creates a custom theme builder with WCAG validation.
Gets accessibility information for the current theme.
Gets the current active theme.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.
Lists all available themes.
Registers a custom high contrast theme.
Enables or disables large text mode.
Suggests improved colors for better contrast.
Toggles color inversion.
Validates contrast ratio compliance for a color pair.