Skip to content

[minor] Simulate color vision deficiencies at any severity in Semantics.Color - #415

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/project-thread-p2h2tt
Oct 11, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/project-thread-p2h2tt

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: Semantics.Color had no way to show how a color looks to someone with a color vision deficiency, so ImageGui keeps its own copy of the Machado severity 1.0 matrices and can't simulate anything milder.

After: color.Simulate(ColorVisionDeficiency.Deutan, 0.4) returns the color as a viewer with that deficiency at that severity sees it, and ColorVision.Matrix(deficiency, severity) returns the matrix for applying to many pixels.

How: ColorVision holds the published Machado, Oliveira and Fernandes (2009) tables for protan, deutan and tritan at severities 0.0 to 1.0 in 0.1 steps (taken from the authors' supplementary data, six decimals as published), and interpolates linearly between the two nearest steps, snapping to a step when the division lands within rounding of one. ColorVisionMatrix is a 3x3 linear-RGB matrix whose Apply clamps each channel to 0..1 and keeps alpha. A severity outside 0..1 or NaN, or an undefined deficiency, throws ArgumentOutOfRangeException. Tests cover severity 0 as identity, severity 1.0 against the published matrices to 1e-6, 0.55 as the midpoint of 0.5 and 0.6, every row summing to 1 within 1e-3, clamping, and the throws. README and CLAUDE.md describe it.

Checked locally: the full test suite passes (1618 passed, 8 skipped), and the Sonar analyzers report nothing in the new files.

🤖 Generated with Claude Code

https://claude.ai/code/session_011NhxrNWomwz1U7X5GMMT1J


Generated by Claude Code

…cs.Color

Adds ColorVisionDeficiency (Protan, Deutan, Tritan), ColorVision.Matrix with the
Machado, Oliveira and Fernandes (2009) tables at severities 0.0 to 1.0 in 0.1
steps, interpolated linearly between them, ColorVisionMatrix with Apply, and
Color.Simulate, which applies the matrix to the linear channels with clamping.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011NhxrNWomwz1U7X5GMMT1J
@matt-edmondson matt-edmondson self-assigned this Oct 11, 2026
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 7fa95ff into main Oct 11, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the claude/project-thread-p2h2tt branch October 11, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants