colorblind

v0.2.0
io.github.vince-gonzalez/colorblind Checked 2 days ago Published 3 months ago

See a color or image as a colorblind person does; recolor images and make Ishihara plates.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

simulateColor Simulate a color under colorblindness

Return how a single hex color appears to someone with a given type of color-vision deficiency (protan, deutan, or tritan). Set severity 0..1 for a partial deficiency (anomalous trichromacy); 1 is the full dichromat case.

ParameterTypeDescription
color *stringHex color, e.g. #d7191c
type *stringColor-vision deficiency type
severitynumberDeficiency strength 0..1 (default 1)

compareVision Show a color under all three deficiencies

Return how a single hex color appears under protanopia, deuteranopia and tritanopia at once, for a side-by-side comparison.

ParameterTypeDescription
color *stringHex color, e.g. #1a9641
severitynumberDeficiency strength 0..1 (default 1)

simulateImage Recolor an image as a colorblind person sees it

Recolor an image, chart, screenshot or mockup the way someone with color-vision deficiency sees it, and return the recolored image. Use this to SHOW what a design looks like through colorblindness (to check whether it stays readable, pair it with cvdsafe's checkImage). Reads PNG and JPEG — pass `path` for a local file, or a base64 `dataUri`. `type` picks the deficiency (default deutan); `severity` 0..1 sets strength.

ParameterTypeDescription
dataUristringBase64 data URI of the image, if you don't have a file path
pathstringPath to a local PNG or JPEG file, e.g. ./chart.png
severitynumberDeficiency strength 0..1 (default 1)
typestringWhich deficiency to render (default deutan)

plate Generate an Ishihara-style color-vision test plate

Generate a pseudoisochromatic (Ishihara-style) test plate: a digit hidden in a field of dots whose colors are distinct to normal vision but collapse under the chosen deficiency. Returns the plate image. Use when asked to create a colorblindness test plate or demonstrate what a plate looks like. Reproducible from a seed.

ParameterTypeDescription
number *stringThe digit(s) to hide, e.g. "7" or "29"
seedintegerSame seed -> identical plate (default 1)
typestringWhich deficiency the figure should collapse under (default deutan)