UNPKG

@thi.ng/color

Version:

Array-based color types, CSS parsing, conversions, transformations, declarative theme generation, gradients, presets

29 lines 1.17 kB
import type { Color, ColorMode, ParsedColor, TypedColor } from "./api.js"; /** * Takes an CSS color string or the result of {@link parseCss} or a * {@link ColorMode} and raw buffer and returns a suitable typed color wrapper * for it (potentially by first parsing the color). * * @example * ```ts tangle:../export/color.ts * import { color } from "@thi.ng/color"; * * console.log(color("springgreen")); * // $Color [srgb] { offset: 0, stride: 1, buf: [ 0, 1, 0.498, 1 ] } * * console.log(color("#ff0")); * // $Color [srgb] { offset: 0, stride: 1, buf: [ 1, 1, 0, 1 ] } * * console.log(color("oklch(60% 0.15 50)")); * // $Color [oklch] { offset: 0, stride: 1, buf: [ 0.6, 0.0015, 0.139, 1 ] } * * console.log(color("hsv", [0.5, 1, 1, 1])); * // $Color [hsv] { offset: 0, stride: 1, buf: [ 0.5, 1, 1, 1 ] } * ``` * * @param src */ export declare function color(src: string): TypedColor<any>; export declare function color(src: ParsedColor, buf?: Color, idx?: number, stride?: number): TypedColor<any>; export declare function color(mode: ColorMode, buf: Color, idx?: number, stride?: number): TypedColor<any>; //# sourceMappingURL=color.d.ts.map