-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
406 lines (338 loc) · 10.9 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
// Type definitions for tinycolor v1.4.1
// Project: https://github.com/bgrins/TinyColor
// Definitions by: Mordechai Zuber <https://github.com/M-Zuber>, Geert Jansen <https://github.com/geertjansen>, Niels van Hoorn <https://github.com/nvh>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var tinycolor: tinycolor;
interface tinycolor {
/**
* Create a tinycolor instance of the color named.
*
* @param color - the color as a string to create an instance for.
*/
(color: string): tinycolorInstance;
/**
* Create a tinycolor instance with the given RGB values.
*
* @param color - the rgb values to apply to the new instance.
*/
(color: ColorFormats.RGB): tinycolorInstance;
/**
* Create a tinycolor instance with the given RGBA values.
*
* @param color - the rgba values to apply to the new instance.
*/
(color: ColorFormats.RGBA): tinycolorInstance;
/**
* Create a tinycolor instance with the given HSL values.
*
* @param color - the hsl values to apply to the new instance.
*/
(color: ColorFormats.HSL): tinycolorInstance;
/**
* Create a tinycolor instance with the given HSLA values.
*
* @param color - the hsla values to apply to the new instance.
*/
(color: ColorFormats.HSLA): tinycolorInstance;
/**
* Create a tinycolor instance with the given HSV values.
*
* @param color - the hsv values to apply to the new instance.
*/
(color: ColorFormats.HSV): tinycolorInstance;
/**
* Create a tinycolor instance with the given HSVA values.
*
* @param color - the hsva values to apply to the new instance.
*/
(color: ColorFormats.HSVA): tinycolorInstance;
/**
* Create a tinycolor instance based off the relative values.
* Works with any color formats
*
* @param ratio - the relative color/hue values to apply to the new instance.
*/
fromRatio(ratio: any): tinycolorInstance; // any of the interfaces defined in the ColorFormats module.
/**
* Compares the two colors and returns the difference between their brightness and color/hue
*
* @param firstColor - the first color to be used in the comparison.
* @param secondColor - the second color to be used in the comparison.
*/
readability(firstColor: ColorInput, secondColor: ColorInput): Readable.Readable;
/**
* Ensure that foreground and background color combinations meet WCAG2 guidelines.
*
* @param foreColor - the fore color wanted.
* @param backColor - the back color wanted.
* @param wcag2 - The 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA'; the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'. If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
*/
isReadable(foreColor: ColorInput, backColor: ColorInput, wcag2?: { level?: string, size?: string }): boolean;
/**
* Given a base color and a list of possible foreground or background colors for that base,
* returns the most readable color. Optionally returns Black or White if the most readable color is unreadable.
*
* @param color - the base color.
* @param colorsToCompare - array of colors to pick the most readable one from.
* @param args - and object with extra arguments
*/
mostReadable(color: ColorInput, colorsToCompare: ColorInput[], args?: { includeFallbackColors?: boolean, level?: string, size?: string }): tinycolorInstance;
/**/
mix(color1: ColorInput, color2: ColorInput, amount?: number): tinycolorInstance;
/**
* Can be called with any tinycolor input
*/
equals(color1: ColorInput, color2: ColorInput): boolean;
/**
* Returns a random color
*/
random(): tinycolorInstance;
/**
* key: hex value
* value: string name ex. hexnames["f00"] --> "red"
*/
hexNames: { [key: string]: string };
/**
* key: 'real' color name
* value: hex value ex. names["red"] --> "f00"
*/
names: { [key: string]: string };
}
interface tinycolorInstance {
/**
* Return an indication whether the color was successfully parsed.
*/
isValid(): boolean;
/**
* Return an indication whether the color's perceived brightness is light.
*/
isLight(): boolean;
/**
* Return an indication whether the color's perceived brightness is dark.
*/
isDark(): boolean;
/**
* Returns the format used to create the tinycolor instance.
*/
getFormat(): string;
/**
* Returns the input passed into the constructer used to create the tinycolor instance.
*/
getOriginalInput(): any; // any of the interfaces in ColorFormats or a string
/**
* Returns the alpha value of the color
*/
getAlpha(): number;
/**
* Returns the perceived brightness of the color, from 0-255.
*/
getBrightness(): number;
/**
* Returns the perceived luminance of a color, from 0-1.
*/
getLuminance(): number;
/**
* Sets the alpha value on the current color.
*
* @param alpha - The new alpha value. The accepted range is 0-1.
*/
setAlpha(alpha: number): tinycolorInstance;
/**
* Returns the object as a HSVA object.
*/
toHsv(): ColorFormats.HSVA;
/**
* Returns the hsva values interpolated into a string with the following format:
* "hsva(xxx, xxx, xxx, xx)".
*/
toHsvString(): string;
/**
* Returns the object as a HSLA object.
*/
toHsl(): ColorFormats.HSLA;
/**
* Returns the hsla values interpolated into a string with the following format:
* "hsla(xxx, xxx, xxx, xx)".
*/
toHslString(): string;
/**
* Returns the hex value of the color.
*/
toHex(): string;
/**
* Returns the hex value of the color -with a # appened.
*/
toHexString(): string;
/**
* Returns the hex 8 value of the color.
*/
toHex8(): string;
/**
* Returns the hex 8 value of the color -with a # appened.
*/
toHex8String(): string;
/**
* Returns the object as a RGBA object.
*/
toRgb(): ColorFormats.RGBA;
/**
* Returns the RGBA values interpolated into a string with the following format:
* "RGBA(xxx, xxx, xxx, xx)".
*/
toRgbString(): string;
/**
* Returns the object as a RGBA object.
*/
toPercentageRgb(): ColorFormats.RGBA;
/**
* Returns the RGBA relative values interpolated into a string with the following format:
* "RGBA(xxx, xxx, xxx, xx)".
*/
toPercentageRgbString(): string;
/**
* The 'real' name of the color -if there is one.
*/
toName(): string;
/**
* Returns the color represented as a Microsoft filter for use in old versions of IE.
*/
toFilter(): string;
/**
* String representation of the color.
*
* @param format - The format to be used when displaying the string representation.
* The accepted values are: "rgb", "prgb", "hex6", "hex3", "hex8", "name", "hsl", "hsv".
*/
toString(format?: string): string;
/**
* Lighten the color a given amount. Providing 100 will always return white.
*
* @param amount - The amount to lighten by. The valid range is 0 to 100.
* Default value: 10.
*/
lighten(amount?: number): tinycolorInstance;
/**
* Brighten the color a given amount.
*
* @param amount - The amount to brighten by. The valid range is 0 to 100.
* Default value: 10.
*/
brighten(amount?: number): tinycolorInstance;
/**
* Darken the color a given amount.
* Providing 100 will always return black.
*
* @param amount - The amount to darken by. The valid range is 0 to 100.
* Default value: 10.
*/
darken(amount?: number): tinycolorInstance;
/**
* Desaturate the color a given amount.
* Providing 100 will is the same as calling greyscale.
*
* @param amount - The amount to desaturate by. The valid range is 0 to 100.
* Default value: 10.
*/
desaturate(amount?: number): tinycolorInstance;
/**
* Saturate the color a given amount.
*
* @param amount - The amount to saturate by. The valid range is 0 to 100.
* Default value: 10.
*/
saturate(amount?: number): tinycolorInstance;
/**
* Completely desaturates a color into greyscale.
* Same as calling desaturate(100).
*/
greyscale(): tinycolorInstance;
/**
* Spin the hue a given amount. Calling with 0, 360, or -360 will do nothing.
*
* @param amount - The amount to spin by. The valid range is -360 to 360.
* Default value: 0.
*/
spin(amount?: number): tinycolorInstance;
/**
* Gets an analogous color scheme based off of the current color.
*
* @param results - The amount of results to return.
* Default value: 6.
* @param slices - The amount to slice the input color by.
* Default value: 30.
*/
analogous(results?: number, slices?: number): tinycolorInstance[];
/**
* Gets a monochromatic color scheme based off of the current color.
*
* @param results - The amount of results to return.
* Default value: 6.
*/
monochromatic(results?: number): tinycolorInstance[];
/**
* Gets a split complement color scheme based off of the current color.
*/
splitcomplement(): tinycolorInstance[];
/**
* Gets a triad based off of the current color.
*/
triad(): tinycolorInstance[];
/**
* Gets a tetrad based off of the current color.
*/
tetrad(): tinycolorInstance[];
/**
* Gets the complement of the current color
*/
complement(): tinycolorInstance;
/**
* Gets a new instance with the current color
*/
clone(): tinycolorInstance;
}
declare namespace Readable {
interface Readable {
brightness: number;
color: number;
}
}
declare namespace ColorFormats {
interface RGB {
r: number;
g: number;
b: number;
}
interface RGBA extends RGB {
a: number
}
interface HSL {
h: number;
s: number;
l: number;
}
interface HSLA extends HSL {
a: number;
}
interface HSV {
h: number;
s: number;
v: number;
}
interface HSVA extends HSV {
a: number;
}
}
type ColorInput = string | ColorFormats.RGB | ColorFormats.RGBA | ColorFormats.HSL | ColorFormats.HSLA | ColorFormats.HSV | ColorFormats.HSVA | tinycolorInstance
declare module 'tinycolor2' {
export = tinycolor;
}
declare var wx: any;
declare class WxWorker {
postMessage(obj: Object): void;
onMessage(callback: (obj: any) => void): void;
terminate(): void;
}
declare namespace worker {
function postMessage(obj: Object): void;
function onMessage(callback: (obj: any) => void): void;
}