|
| 1 | +import type convert from 'color-convert'; |
| 2 | + |
| 3 | +export type ColorLike = ColorInstance | string | ArrayLike<number> | number | Record<string, any>; |
| 4 | +export type ColorJson = {model: string; color: number[]; valpha: number}; |
| 5 | +export type ColorObject = {alpha?: number | undefined} & Record<string, number>; |
| 6 | + |
| 7 | +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions |
| 8 | +export interface ColorInstance { |
| 9 | + toString(): string; |
| 10 | + // eslint-disable-next-line @typescript-eslint/naming-convention |
| 11 | + toJSON(): ColorJson; |
| 12 | + string(places?: number): string; |
| 13 | + percentString(places?: number): string; |
| 14 | + array(): number[]; |
| 15 | + object(): ColorObject; |
| 16 | + unitArray(): number[]; |
| 17 | + unitObject(): {r: number; g: number; b: number; alpha?: number | undefined}; |
| 18 | + round(places?: number): ColorInstance; |
| 19 | + alpha(): number; |
| 20 | + alpha(value: number): ColorInstance; |
| 21 | + red(): number; |
| 22 | + red(value: number): ColorInstance; |
| 23 | + green(): number; |
| 24 | + green(value: number): ColorInstance; |
| 25 | + blue(): number; |
| 26 | + blue(value: number): ColorInstance; |
| 27 | + hue(): number; |
| 28 | + hue(value: number): ColorInstance; |
| 29 | + saturationl(): number; |
| 30 | + saturationl(value: number): ColorInstance; |
| 31 | + lightness(): number; |
| 32 | + lightness(value: number): ColorInstance; |
| 33 | + saturationv(): number; |
| 34 | + saturationv(value: number): ColorInstance; |
| 35 | + value(): number; |
| 36 | + value(value: number): ColorInstance; |
| 37 | + chroma(): number; |
| 38 | + chroma(value: number): ColorInstance; |
| 39 | + gray(): number; |
| 40 | + gray(value: number): ColorInstance; |
| 41 | + white(): number; |
| 42 | + white(value: number): ColorInstance; |
| 43 | + wblack(): number; |
| 44 | + wblack(value: number): ColorInstance; |
| 45 | + cyan(): number; |
| 46 | + cyan(value: number): ColorInstance; |
| 47 | + magenta(): number; |
| 48 | + magenta(value: number): ColorInstance; |
| 49 | + yellow(): number; |
| 50 | + yellow(value: number): ColorInstance; |
| 51 | + black(): number; |
| 52 | + black(value: number): ColorInstance; |
| 53 | + x(): number; |
| 54 | + x(value: number): ColorInstance; |
| 55 | + y(): number; |
| 56 | + y(value: number): ColorInstance; |
| 57 | + z(): number; |
| 58 | + z(value: number): ColorInstance; |
| 59 | + l(): number; |
| 60 | + l(value: number): ColorInstance; |
| 61 | + a(): number; |
| 62 | + a(value: number): ColorInstance; |
| 63 | + b(): number; |
| 64 | + b(value: number): ColorInstance; |
| 65 | + keyword(): string; |
| 66 | + keyword<V extends string>(value: V): ColorInstance; |
| 67 | + hex(): string; |
| 68 | + hex<V extends string>(value: V): ColorInstance; |
| 69 | + hexa(): string; |
| 70 | + hexa<V extends string>(value: V): ColorInstance; |
| 71 | + rgbNumber(): number; |
| 72 | + luminosity(): number; |
| 73 | + contrast(color2: ColorInstance): number; |
| 74 | + level(color2: ColorInstance): 'AAA' | 'AA' | ''; |
| 75 | + isDark(): boolean; |
| 76 | + isLight(): boolean; |
| 77 | + negate(): ColorInstance; |
| 78 | + lighten(ratio: number): ColorInstance; |
| 79 | + darken(ratio: number): ColorInstance; |
| 80 | + saturate(ratio: number): ColorInstance; |
| 81 | + desaturate(ratio: number): ColorInstance; |
| 82 | + whiten(ratio: number): ColorInstance; |
| 83 | + blacken(ratio: number): ColorInstance; |
| 84 | + grayscale(): ColorInstance; |
| 85 | + fade(ratio: number): ColorInstance; |
| 86 | + opaquer(ratio: number): ColorInstance; |
| 87 | + rotate(degrees: number): ColorInstance; |
| 88 | + mix(mixinColor: ColorInstance, weight?: number): ColorInstance; |
| 89 | + rgb(...arguments_: number[]): ColorInstance; |
| 90 | + hsl(...arguments_: number[]): ColorInstance; |
| 91 | + hsv(...arguments_: number[]): ColorInstance; |
| 92 | + hwb(...arguments_: number[]): ColorInstance; |
| 93 | + cmyk(...arguments_: number[]): ColorInstance; |
| 94 | + xyz(...arguments_: number[]): ColorInstance; |
| 95 | + lab(...arguments_: number[]): ColorInstance; |
| 96 | + lch(...arguments_: number[]): ColorInstance; |
| 97 | + ansi16(...arguments_: number[]): ColorInstance; |
| 98 | + ansi256(...arguments_: number[]): ColorInstance; |
| 99 | + hcg(...arguments_: number[]): ColorInstance; |
| 100 | + apple(...arguments_: number[]): ColorInstance; |
| 101 | +} |
| 102 | + |
| 103 | +export type ColorConstructor = { |
| 104 | + (object?: ColorLike, model?: keyof (typeof convert)): ColorInstance; |
| 105 | + new(object?: ColorLike, model?: keyof (typeof convert)): ColorInstance; |
| 106 | + rgb(...value: number[]): ColorInstance; |
| 107 | + rgb(color: ColorLike): ColorInstance; |
| 108 | + hsl(...value: number[]): ColorInstance; |
| 109 | + hsl(color: ColorLike): ColorInstance; |
| 110 | + hsv(...value: number[]): ColorInstance; |
| 111 | + hsv(color: ColorLike): ColorInstance; |
| 112 | + hwb(...value: number[]): ColorInstance; |
| 113 | + hwb(color: ColorLike): ColorInstance; |
| 114 | + cmyk(...value: number[]): ColorInstance; |
| 115 | + cmyk(color: ColorLike): ColorInstance; |
| 116 | + xyz(...value: number[]): ColorInstance; |
| 117 | + xyz(color: ColorLike): ColorInstance; |
| 118 | + lab(...value: number[]): ColorInstance; |
| 119 | + lab(color: ColorLike): ColorInstance; |
| 120 | + lch(...value: number[]): ColorInstance; |
| 121 | + lch(color: ColorLike): ColorInstance; |
| 122 | + ansi16(...value: number[]): ColorInstance; |
| 123 | + ansi16(color: ColorLike): ColorInstance; |
| 124 | + ansi256(...value: number[]): ColorInstance; |
| 125 | + ansi256(color: ColorLike): ColorInstance; |
| 126 | + hcg(...value: number[]): ColorInstance; |
| 127 | + hcg(color: ColorLike): ColorInstance; |
| 128 | + apple(...value: number[]): ColorInstance; |
| 129 | + apple(color: ColorLike): ColorInstance; |
| 130 | +}; |
| 131 | + |
| 132 | +// eslint-disable-next-line @typescript-eslint/naming-convention |
| 133 | +declare const Color: ColorConstructor; |
| 134 | + |
| 135 | +export default Color; |
0 commit comments