Repository navigation
[minor] Simulate color vision deficiencies at any severity in Semantics.Color - #415
Merged
Merged
Conversation
…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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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, andColorVision.Matrix(deficiency, severity)returns the matrix for applying to many pixels.How:
ColorVisionholds 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.ColorVisionMatrixis a 3x3 linear-RGB matrix whoseApplyclamps each channel to 0..1 and keeps alpha. A severity outside 0..1 or NaN, or an undefined deficiency, throwsArgumentOutOfRangeException. 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