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

    Function rgbFromCSSString

    • Parses a CSS RGB color string into an RGBColor object.

      Supports both comma and space syntax, as well as both rgb() and rgba() formats:

      • rgb(255, 128, 0)
      • rgba(255, 128, 0, 0.5)
      • rgb(255 128 0)
      • rgb(255 128 0 / 0.5)
      • rgb(100%, 50%, 0%)
      • rgb(100% 50% 0% / 0.5)

      The function handles:

      • RGB values as either integers (0-255) or percentages (0-100%)
      • Optional alpha value (0-1 or 0-100%)
      • Both comma-separated and space-separated formats
      • Whitespace flexibility according to CSS specifications

      Parameters

      • src: string

        The CSS RGB color string to parse

      Returns RGBColor

      The parsed RGB color object, with values normalized to 0-1 range

      If the string format is invalid