The contrast method currently does the following:
- Checks the
baseColor luma value to determine if it is a dark or light color
- Uses that decision to pick the
dark or light contrast colors passed in (black and white are defaults)
- Checks to see if the contrast ratio is at least
4.5 or greater
- If we don't have a valid contrast ratio, darken/lighten the contrast color by
1 and try again
Example: You call .contrast() on a polychrome object that registers as dark because of it's luma value, but when compared to white, it has a contrast ratio of 4.0. This would lead to infinite recursion if a previous PR hadn't taken care of checking to see if we are already at the outer bounds of the color spectrum (black and white).
Instead, maybe both light and dark color ratios can be compared, and we go off of the greater contrast ratio if not yet 4.5? I think this might be more reliable than checking the luma value in the first place.
The
contrastmethod currently does the following:baseColorluma value to determine if it is a dark or light colordarkorlightcontrast colors passed in (blackandwhiteare defaults)4.5or greater1and try againExample: You call
.contrast()on apolychromeobject that registers asdarkbecause of it's luma value, but when compared to white, it has a contrast ratio of4.0. This would lead to infinite recursion if a previous PR hadn't taken care of checking to see if we are already at the outer bounds of the color spectrum (blackandwhite).Instead, maybe both
lightanddarkcolor ratios can be compared, and we go off of the greater contrast ratio if not yet4.5? I think this might be more reliable than checking the luma value in the first place.