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