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

    Function parseColor

    • Parses a color string or converts a Color object to the specified color space.

      This function handles multiple input formats with optimized paths:

      1. If input is already a Color object, it's converted to the target space
      2. Recently parsed strings are retrieved from a target-space-aware hot cache
      3. Hex strings (e.g., "#FF0000") are validated and parsed via a fast path
      4. ChromaKit's own serialization format is validated and handled efficiently
      5. CSS color strings are parsed based on registered parsers

      Note: Before parsing CSS color strings, you must register the appropriate parsers. You can either register all parsers at once:

      import { registerParsers } from './semantics/registerParsers';
      registerParsers();

      Or register only the parsers you need for better tree shaking:

      import { registerSRGBParser, registerHSLParser } from './semantics/registerParsers';
      registerSRGBParser();
      registerHSLParser();

      Type Parameters

      • T extends
            | "rgb"
            | "hwb"
            | "hsl"
            | "hsv"
            | "xyz"
            | "lab"
            | "lch"
            | "oklab"
            | "oklch"
            | "jzazbz"
            | "jzczhz"

      Parameters

      • input: string | Color

        A color string or Color object to parse/convert

      • targetSpace: T

        The destination color space

      Returns CreatedColor<T>

      A Color object in the specified target space

      If input is null, undefined, or invalid type

      If the input string format is invalid or unsupported

      If no parsers are registered when trying to parse a CSS color string