Function contrast

  • Calculate the contrast ratio between two sRGB colors. This is useful for ensuring that Web Content Accessibility Guidelines (WCAG) are met. For everything to meet WCAG 2.2 at level AAA, this value should be at least 7.

    Parameters

    • color0: Rgb

      The first sRGB color.

    • color1: Rgb

      The second sRGB color.

    Returns number

    The contrast ratio between the colors (a value v such that the contrast ratio between the colors is v to one).