MAIDR Documentation - v3.39.0
    Preparing search index...

    Class ColorAbstract

    Abstract utility class for color parsing, manipulation, and contrast calculations.

    Index

    Methods

    • Parses a color string in hex or rgb(a) format and returns RGB values.

      Parameters

      • color: string

        Color string in hex (#fff, #ffffff) or rgb/rgba format

      Returns Rgb | null

      RGB object with r, g, b properties, or null if parsing fails

    • Inverts an RGB color by subtracting each channel from 255.

      Parameters

      • rgb: Rgb

        The RGB color to invert

      Returns Rgb

      The inverted RGB color

    • Calculates the WCAG contrast ratio between two RGB colors.

      Parameters

      • rgb1: Rgb

        The first RGB color

      • rgb2: Rgb

        The second RGB color

      Returns number

      The contrast ratio between the two colors (1 to 21)

    • Converts an RGB object to a CSS rgb() string format.

      Parameters

      • rgb: Rgb

        The RGB color to convert

      Returns string

      CSS rgb() string representation

    • Parameters

      • color1: string
      • color2: string

      Returns boolean