@dragonspark/chroma-kit
    Preparing search index...

    Function hexToRGB

    • Converts a hex color string representation into an RGBColor object.

      The input can be in the formats:

      • #RGB or #RGBA where the single hex digit is expanded (e.g., #F0A becomes #FF00AA).
      • #RRGGBB or #RRGGBBAA where each two-digit pair represents a color channel.

      The output object contains the red, green, blue color channels and optionally the alpha channel (transparency) in normalized format.

      Parameters

      • hex: string

        The hexadecimal color code string. This can optionally start with a # and must be in one of the valid formats (#RGB, #RGBA, #RRGGBB, #RRGGBBAA).

      Returns RGBColor

      An object representing the RGB color with properties for red, green, blue, and optionally alpha transparency (normalized between 0 and 1).

      If the provided hex string has an invalid format or length.