Skip to content

Rework the contrast method  #27

Description

@cdonohue

The contrast method currently does the following:

  1. Checks the baseColor luma value to determine if it is a dark or light color
  2. Uses that decision to pick the dark or light contrast colors passed in (black and white are defaults)
  3. Checks to see if the contrast ratio is at least 4.5 or greater
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions