cvdsafe
v0.2.0Check if a palette or image is colorblind-safe, generate safe palettes, check WCAG contrast.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
checkPalette Check a color palette for colorblind-safety
Check whether a set of colors stays distinguishable for people with color-vision deficiency (colorblindness). Simulates protanopia, deuteranopia and tritanopia and flags the pairs whose perceptual difference collapses under simulation. A screening aid, not a legal accessibility (ADA/WCAG) audit.
| Parameter | Type | Description |
|---|---|---|
colors * | array | Hex colors to check together, e.g. ["#d7191c","#1a9641","#2166ac"] |
simulateColor Simulate a color under colorblindness
Return how a single hex color appears to someone with a given type of color blindness (protan, deutan, or tritan).
| Parameter | Type | Description |
|---|---|---|
color * | string | Hex color, e.g. #d7191c |
type * | string | Color-vision deficiency type |
fixPalette Fix a palette to be colorblind-safe
Take a set of colors that fails the colorblind-safety check and return an adjusted set that passes, staying as close to the originals as possible. Conflicting colors are separated in lightness (the axis color-vision deficiency preserves). Returns the new colors, how far each moved, and whether it fully passes.
| Parameter | Type | Description |
|---|---|---|
colors * | array | Hex colors to fix, e.g. ["#d7191c","#1a9641"] |
checkContrast Check text/background contrast against WCAG
Check whether a foreground color is legible on a background color per WCAG 2.x contrast ratios. Returns the ratio (1-21) and whether it passes AA and AAA. Set large=true for text >=18pt (or 14pt bold). This is the legibility axis, separate from color-blindness.
| Parameter | Type | Description |
|---|---|---|
background * | string | Background hex color, e.g. #ffffff |
foreground * | string | Text/foreground hex color, e.g. #767676 |
large | boolean | True if text is >=18pt or 14pt bold (default false) |
checkImage Check an image for colorblind-safety
Check whether the colors in an image, chart, screenshot or mockup stay distinguishable for people with color-vision deficiency. Extracts the image's dominant colors, simulates protanopia, deuteranopia and tritanopia, and flags the color pairs that collapse into each other — each with how much of the image's area those colors cover, so a conflict between two large regions ranks above one between two specks. Reads PNG and JPEG. Pass `path` for a local file, or a base64 `dataUri`. Set returnSimulated=true to also get back the image as a deuteranope sees it. A screening aid, not a legal (ADA/WCA…
| Parameter | Type | Description |
|---|---|---|
dataUri | string | Base64 data URI of the image, if you don't have a file path |
maxColors | integer | How many dominant colors to extract and test (default 12) |
path | string | Path to a local PNG or JPEG file, e.g. ./dashboard.png |
returnSimulated | boolean | Also return the image recolored as a deuteranope sees it (default false) |
simulateType | string | Which deficiency to render when returnSimulated is set (default deutan) |
generateSafePalette Generate a colorblind-safe palette
Return N colorblind-safe hex colors — distinct to each other under protanopia, deuteranopia and tritanopia. Seeded with the Okabe-Ito palette and safely extended above eight. Use when asked for accessible / colorblind-safe / colorblind-friendly colors for a chart, plot, map or UI. Never returns an unsafe color.
| Parameter | Type | Description |
|---|---|---|
count * | integer | How many colorblind-safe colors to return |