import { ChacaUtils } from "../../core/utils"; import { DatatypeModule } from "../datatype"; import { CSSSpace } from "./constants"; import { Casing, ColorFormat } from "./helpers"; export declare type RgbProps = { prefix?: string; casing?: Casing; format?: "hex" | ColorFormat; includeAlpha?: boolean; }; export declare type CmykProps = { format?: ColorFormat; }; export declare type HslProps = { format?: ColorFormat; includeAlpha?: boolean; }; export declare type HwbProps = { format?: ColorFormat; }; export declare type LchProps = { format?: ColorFormat; }; export declare type ColorByCSSColorSpaceProps = { format?: ColorFormat; space?: CSSSpace; }; export declare class ColorModule { private readonly utils; private readonly datatypeModule; constructor(utils: ChacaUtils, datatypeModule: DatatypeModule); readonly constants: { cssFunctions: readonly ["rgb", "rgba", "hsl", "hsla", "hwb", "cmyk", "lab", "lch", "color"]; cssSpaces: readonly ["sRGB", "display-p3", "rec2020", "a98-rgb", "prophoto-rgb", "rec2020"]; human: string[]; }; /** * Returns a random human-readable color name. * * @example * modules.color.human() // 'blue' */ human(): string; /** * Returns a random css supported color function name. * * @example * modules.color.cssSupportedFunction() // 'rgb' */ cssSupportedFunction(): "color" | "lab" | "rgb" | "rgba" | "hsl" | "hsla" | "hwb" | "cmyk" | "lch"; /** * Returns a random css supported color space name. * * @example * modules.color.cssSupportedSpace() // 'display-p3' */ cssSupportedSpace(): "sRGB" | "display-p3" | "rec2020" | "a98-rgb" | "prophoto-rgb"; /** * Returns an RGB color. * * @param options.prefix Prefix of the generated hex color. Only applied when `'hex'` format is used. Defaults to `'0x'`. * @param options.casing Letter type case of the generated hex color. Only applied when `'hex'` format is used. Defaults to `'mixed'`. * @param options.format Format of generated RGB color. Defaults to `'hex'`. * @param options.includeAlpha Adds an alpha value to the color (RGBA). Defaults to `false`. * * @example * modules.color.rgb({ prefix: '#' }) // '#ffffFF' * modules.color.rgb({ casing: 'upper' }) // '0xFFFFFF' * modules.color.rgb({ casing: 'lower' }) // '0xffffff' * modules.color.rgb({ prefix: '#', casing: 'lower' }) // '#ffffff' * modules.color.rgb({ format: 'hex', casing: 'lower' }) // '#ffffff' * modules.color.rgb({ format: 'css' }) // 'rgb(255, 0, 0)' * modules.color.rgb({ format: 'binary' }) // '10000000 00000000 11111111' */ rgb({ format, includeAlpha, casing, prefix, }?: RgbProps): string; /** * Returns a CMYK color. * * @param options.format Format of generated CMYK color. Defaults to `'css'`. * * @example * modules.color.cmyk() // cmyk(100%, 0%, 0%, 0%) * modules.color.cmyk({ format: 'css' }) // cmyk(100%, 0%, 0%, 0%) * modules.color.cmyk({ format: 'binary' }) // (8-32 bits) x 4 */ cmyk({ format }?: CmykProps): string; /** * Returns an HSL color. * * @param options.format Format of generated HSL color. Defaults to `'css'`. * @param options.includeAlpha Adds an alpha value to the color (RGBA). Defaults to `false`. * * @example * modules.color.hsl({ format: 'css' }) // hsl(0deg, 100%, 80%) * modules.color.hsl({ format: 'css', includeAlpha: true }) // hsl(0deg 100% 50% / 0.5) * modules.color.hsl({ format: 'binary' }) // (8-32 bits) x 3 * modules.color.hsl({ format: 'binary', includeAlpha: true }) // (8-32 bits) x 4 */ hsl({ format, includeAlpha }?: HslProps): string; /** * Returns an HWB color. * * @param options.format Format of generated HWB color. Defaults to `'css'`. * * @example * modules.color.hwb({ format: 'css' }) // hwb(194 0% 0%) * modules.color.hwb({ format: 'binary' }) // (8-32 bits x 3) */ hwb({ format }?: HwbProps): string; /** * Returns an LCH color. Even though upper bound of * chroma in LCH color space is theoretically unbounded, * it is bounded to 230 as anything above will not * make a noticeable difference in the browser. * * @param options.format Format of generated LCH color. Defaults to `'decimal'`. * * @example * modules.color.lch({ format: 'css' }) // lch(52.2345% 72.2 56.2) * modules.color.lch({ format: 'binary' }) // (8-32 bits x 3) */ lch({ format }?: LchProps): string; /** * Returns a random color based on CSS color space specified. * * @param options.format Format of generated color. Defaults to `'css'`. * @param options.space Color space to generate the color for. Defaults to `'sRGB'`. * * @example * modules.color.colorByCSSColorSpace({ format: 'css', space: 'display-p3' }) // color(display-p3 0.12 1 0.23) * modules.color.colorByCSSColorSpace({ format: 'binary' }) // (8-32 bits x 3) */ colorByCSSColorSpace({ format, space, }?: ColorByCSSColorSpaceProps): string; }