Parses a color string or converts a Color object to the specified color space.
This function handles multiple input formats with optimized paths:
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(); Copy
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(); Copy
import { registerSRGBParser, registerHSLParser } from './semantics/registerParsers';registerSRGBParser();registerHSLParser();
A color string or Color object to parse/convert
The destination color space
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
Parses a color string or converts a Color object to the specified color space.
This function handles multiple input formats with optimized paths:
Note: Before parsing CSS color strings, you must register the appropriate parsers. You can either register all parsers at once:
Or register only the parsers you need for better tree shaking: