Improve Consistency of Color Blindness Support
Building up on #118 (closed), I wanted propose making it easier to enable various color vision deficiency-options.
The current state of CVD-accesibility is limited to a few critical options (color vision deficiency
, modus-themes-success-deuteranopia
, ...) that have to be manually enabled.
In the issue mentioned above, you commented:
Yes, it does make sense and I already have it on my to-do list for a potential version
2.0.0
of the themes. This is because I thought it could be a "breaking change". There are parts of the code that need to be refactored and for the whole implementation to be simplified.
It might be that I am wrong, but if the necessary accessibility can be implemented using a series of linear transformations through a few colour spaces, it might be possible to fix everything in modus-themes--palette
, by applying some function to modus-themes-operandi-colors
and modus-themes-vivendi-colors
before they are passed on:
(defun modus-themes--palette (theme)
"Return color palette for Modus theme THEME.
THEME is a symbol, either `modus-operandi' or `modus-vivendi'."
(pcase theme
('modus-operandi
(append modus-themes-operandi-color-overrides
(funcall modus-theme--handle-cvd modus-themes-operandi-colors)))
('modus-vivendi
(append modus-themes-vivendi-color-overrides
(funcall modus-theme--handle-cvd modus-themes-vivendi-colors)))
(_theme
(error "'%s' is not a Modus theme" theme))))
The function modus-theme--handle-cvd
would be set to identity
by default. Depending on what kind of colour blindness is being accounted for, the function would be replaced with something else.
There seems to be research on the mathematics behind this, and assuming it is sound, this could be implemented and tuned quite easily. If this process is too slow, the transformations could also be calculated at compile-time, with modus-theme--handle-cvd
just selecting the right variable with the precomputed value.
I would suggest providing a single options like modus-themes-colour-blindness
or modus-themes-color-vision-deficiency-support
(or anything in-between) that would be set to a symbol designating the users needs (deuteranopia
, tritanopia
, achromatopsia
, ...).
As a result, the current deuteranopia should be deprecated, because they would essentially conflict/over correct.
I should clarify that I personally am not affected by colour vision deficiency, so I cannot evaluate the results on my own, nor am I in any way an expert on this topic. I just took a linear algebra course at university, so I understand what is necessary to implement this.