/** * Channels for the hue, saturation, lightness color model. */ type HslChannels = [hue: number, saturation: number, lightness: number]; /** * Channels for the hue, whiteness, blackness color model. */ type HwbChannels = [hue: number, whiteness: number, blackness: number]; /** * Channels for the lightness, a-axis, b-axis model in the CIELAB color space. */ type LabChannels = [lightness: number, aAxis: number, bAxis: number]; /** * Channels for the lightness, chroma, hue model in the CIELAB color space. */ type LchChannels = [lightness: number, chroma: number, hue: number]; /** * Channels for the lightness, a-axis, b-axis model in the CIELAB color space with a focus on * greater uniformity. */ type OkLabChannels = [lightness: number, aAxis: number, bAxis: number]; /** * Channels for the lightness, chroma, hue model in the CIELAB color space with a focus on * greater uniformity. */ type OkLchChannels = [lightness: number, chroma: number, hue: number]; /** * Channels for the red, green, blue model. */ type RgbChannels = [red: number, green: number, blue: number]; interface BaseColoratiOptions { /** * Whether to use an alpha channel on the resulting color value. If a number is passed, it is used directly; if * `true` is passed, then it is computed based on the value in the same way the color channels are. */ alpha?: number | boolean; /** * How many decimals to round the alpha to. Only applies to array color schemes. */ alphaPrecision?: number; /** * How many decimals to round the color channels to. Only applied to array color schemes. */ channelPrecision?: number; } interface OpaqueColoratiOptions extends BaseColoratiOptions { alpha?: false; alphaPrecision?: undefined; } interface SemiOpaqueComputedColoratiOptions extends BaseColoratiOptions { alpha: true; } interface SemiOpaqueManualColoratiOptions extends BaseColoratiOptions { alpha: number; } type AlphaType = 'computed' | 'ignored' | 'manual'; type ColoratiOptions = OpaqueColoratiOptions | SemiOpaqueComputedColoratiOptions | SemiOpaqueManualColoratiOptions; interface OpaqueColorConfig extends Required { alphaType: 'ignored'; } interface SemiOpaqueComputedColorConfig extends Required { alphaType: 'computed'; } interface SemiOpaqueManualColorConfig extends Required { alphaType: 'manual'; } type ColorConfig = OpaqueColorConfig | SemiOpaqueComputedColorConfig | SemiOpaqueManualColorConfig; type NormalizedConfig = Options['alpha'] extends number ? SemiOpaqueManualColorConfig : true extends Options['alpha'] ? SemiOpaqueComputedColorConfig : OpaqueColorConfig; type NormalizedOptions = Config extends SemiOpaqueComputedColorConfig ? SemiOpaqueComputedColoratiOptions : Config extends SemiOpaqueManualColorConfig ? SemiOpaqueManualColoratiOptions : OpaqueColoratiOptions; type AnalogousColors = Tuple, 6>; type ComplementColors = Tuple, 2>; type ClashColors = Tuple, 3>; type NeutralColors = Tuple, 6>; type SplitColors = Tuple, 3>; type TetradColors = Tuple, 4>; type TriadColors = Tuple, 3>; type Tuple = Length extends Length ? number extends Length ? Type[] : TupleOf : never; type TupleOf = Rest['length'] extends Length ? Rest : TupleOf; type Value = [...Tuple, alpha: number]; declare class BaseColor { config: ColorConfig; protected _alpha: null | number | string | undefined; protected _baseChannels: RgbChannels; protected _computedAlpha: number; protected _css: null | number | string | undefined; protected _channels: any[] | null | number | string | undefined; protected _value: any[] | number | string | undefined; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); /** * The alpha transparency for the given color value. */ get alpha(): string | number | null | undefined; /** * The color channels for the given color value. */ get channels(): string | number | any[] | null | undefined; /** * The CSS representation for the given color value. */ get css(): string | number | null | undefined; /** * The color value (channels + alpha). */ get value(): string | number | any[] | undefined; toJSON(): string | number | null | undefined; toString(): string; } declare class BaseArrayColor extends BaseColor { private _size; protected _alpha: number | undefined; protected _css: string | undefined; protected _channels: Channels | undefined; protected _value: Value | undefined; [index: number]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get alpha(): number; get channels(): Channels; get css(): string; get value(): Value; [Symbol.iterator](): Generator; toString(): string; } declare class BaseAnsiColor extends BaseColor { protected _alpha: undefined; protected _css: undefined; protected _value: number; constructor(value: number, baseChannels: RgbChannels, computedAlpha: number, config: Config); get alpha(): null; get channels(): null; get css(): null; get value(): number; toJSON(): number; toString(): string; valueOf(): number; } declare class Ansi16 extends BaseAnsiColor { constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); } declare class Ansi256 extends BaseAnsiColor { constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); } declare class Hex extends BaseColor { protected _alpha: string | null; protected _css: string | undefined; protected _channels: string; protected _value: string | undefined; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get alpha(): null | string; get channels(): string; get css(): string; get value(): string; [Symbol.iterator](): Generator; toJSON(): string; toString(): string; } declare class Hsl extends BaseArrayColor { [0]: number; [1]: number; [2]: number; [3]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get css(): string; } declare class Hwb extends BaseArrayColor { [0]: number; [1]: number; [2]: number; [3]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get css(): string; } declare class Lab extends BaseArrayColor { [0]: number; [1]: number; [2]: number; [3]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get css(): string; } declare class Lch extends BaseArrayColor { [0]: number; [1]: number; [2]: number; [3]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get css(): string; } declare class OkLab extends BaseArrayColor { [0]: number; [1]: number; [2]: number; [3]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get css(): string; } declare class OkLch extends BaseArrayColor { [0]: number; [1]: number; [2]: number; [3]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get css(): string; } declare class Rgb extends BaseArrayColor { [0]: number; [1]: number; [2]: number; [3]: number; constructor(baseChannels: RgbChannels, computedAlpha: number, config: Config); get css(): string; } declare class Colorati extends BaseColor> { private _ansi16; private _ansi256; private _darkContrast; private _harmonies; private _hex; private _hsl; private _hwb; private _lab; private _lch; private _luminance; private _oklab; private _oklch; private _rgb; constructor(baseChannels: RgbChannels, rawAlpha: number, options: Options); /** * ANSI 16-bit color code for the given color. */ get ansi16(): Ansi16>; /** * ANSI 256-bit color code for the given color. */ get ansi256(): Ansi256>; /** * Color harmonies for the given color. */ get harmonies(): ColorHarmonies; /** * Whether the contrasting color of the given color is considered dark. * * @deprecated * Use `getContrastRatio` with a specific color instead, as it provides more granular information * and allows contextual contrast. For example, the definition changes depending on text size, as * smaller text must have a higher ratio than larger text. */ get hasDarkContrast(): boolean; /** * Hexadecimal representation for the given color. */ get hex(): Hex>; /** * HSL representation for the given color. */ get hsl(): Hsl>; /** * HWB representation for the given color. */ get hwb(): Hwb>; /** * Lab representation for the given color. */ get lab(): Lab>; /** * Relative luminance value of the color, based on * [W3C standards](https://www.w3.org/TR/WCAG20/#relativeluminancedef). */ get luminance(): number; /** * Lch representation for the given color. */ get lch(): Lch>; /** * Oklab representation for the given color. */ get oklab(): OkLab>; /** * Oklch representation for the given color. */ get oklch(): OkLch>; /** * RGB representation for the given color. */ get rgb(): Rgb>; /** * Clone the `Colorati` instance, optionally providing override configuration options. */ clone(overrideOptions?: OverrideOptions): Colorati & OverrideOptions>; /** * Get the contrast ratio of this color to the color provided, based on * [W3C standards](https://www.w3.org/TR/WCAG/#contrast-minimum). */ getContrastRatio(color: Colorati): number; toJSON(): string; toString(): string; } declare class ColorHarmonies> { private _colorati; private _analogous; private _clash; private _complement; private _neutral; private _split; private _tetrad; private _triad; constructor(base: Instance); private _getBaseChannelsFromHsl; private _harmonize; /** * Analogous color harmonies for the given color. */ get analogous(): AnalogousColors; /** * Clash color harmonies for the given color. */ get clash(): ClashColors; /** * Complement color harmonies for the given color. */ get complement(): ComplementColors; /** * Neutral color harmonies for the given color. */ get neutral(): NeutralColors; /** * Split complement color harmonies for the given color. */ get splitComplement(): SplitColors; /** * Tetrad color harmonies for the given color. */ get tetriadic(): TetradColors; /** * Triad color harmonies for the given color. */ get triadic(): TriadColors; } /** * Create a `colorati` instance based on the hashed `value` provided. */ declare function colorati(value: any, options?: Options): Colorati; declare namespace colorati { var from: ([baseRed, baseGreen, baseBlue, baseAlpha]: [...RgbChannels, alpha?: number], options?: Options) => Colorati; } export { Colorati, colorati }; export type { AlphaType, AnalogousColors, ClashColors, ColorConfig, ColoratiOptions, ComplementColors, HslChannels, HwbChannels, LabChannels, LchChannels, NeutralColors, NormalizedConfig, NormalizedOptions, OkLabChannels, OkLchChannels, OpaqueColorConfig, OpaqueColoratiOptions, RgbChannels, SemiOpaqueComputedColorConfig, SemiOpaqueComputedColoratiOptions, SemiOpaqueManualColorConfig, SemiOpaqueManualColoratiOptions, SplitColors, TetradColors, TriadColors, Tuple, Value };