The Color Pro package includes a few functions for testing accessibility requirements. The requirements themselves are defined by WCAG guidelines.
- Enhanced: The visual presentation of text has a contrast ratio of at least 7:1 (Level AAA)
- Enhanced Large Text: The visual presentation of large text has a contrast ratio of at least 4.5:1 (Level AAA)
- Minimum: The visual presentation of text has a contrast ratio of at least 4.5:1 (Level AA)
- Minimum Large Text: The visual presentation of large text has a contrast ratio of at least 3:1 (Level AA)
🧪 Testing Compliance
Accessibility functions are defined as extension methods in the static class Accessibility and utilize the enum Accessibility.Requirement. Compliance is determined by the contrast ratio between a foreground color and a background color. See the Contrast manual for more information on how contrast is calculated.
Accessibility.Requirement requirement = Accessibility.Requirement.Enhanced; bool compliant = requirement.IsCompliant(foregroundColor, backgroundColor); bool compliant = foregroundColor.IsCompliant(backgroundColor, requirement);