import { wcagIsReadable } from "https://deno.land/x/a11y_color_contrast@v0.2.0/mod.ts";
This function determines whether two colors used together are readable based on WCAG readability criteria. The first color is the foreground color and the second the background color (defaulting to pure white, "#fff" / [255, 255, 255]).
The readability criteria defaults to the 'AAA' level for normal text as defined in WCAG 2.2.
import { wcagIsReadable } from "./wcag.ts";
wcagIsReadable([0, 255, 0], [0, 0, 0]) // green on black
// true
wcagIsReadable([169, 169, 169], [0, 0, 0]) // dark gray on black
// false
See https://www.w3.org/WAI/WCAG22/Techniques/general/G17.html for concrete details for WCAG 2.2.