contrastrast
Version:
A lightweight tool that parses color strings and recommends text contrast based on WCAG Standards
16 lines • 813 B
TypeScript
import type { RGBValues } from "../types/Colors.types.js";
/**
* Parse a color string and extract RGB values
* Supports hex ("#abc", "#abcdef"), rgb ("rgb(r,g,b)"), and hsl ("hsl(h,s%,l%)") format strings
* @param colorString Color string in supported format
* @returns RGB values object with r, g, b properties (0-255)
* @throws {Error} When the color string format is not supported or invalid
* @example
* ```typescript
* const rgb1 = getRGBFromColorString("#ff0000"); // { r: 255, g: 0, b: 0 }
* const rgb2 = getRGBFromColorString("rgb(255, 0, 0)"); // { r: 255, g: 0, b: 0 }
* const rgb3 = getRGBFromColorString("hsl(0, 100%, 50%)"); // { r: 255, g: 0, b: 0 }
* ```
*/
export declare const getRGBFromColorString: (colorString: string) => RGBValues;
//# sourceMappingURL=colorStringParsers.d.ts.map