1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export as namespace ContrastColors;
|
14 | export = ContrastColors;
|
15 |
|
16 | declare namespace ContrastColors {
|
17 | type InterpolationColorspace = 'CAM02' | 'CAM02p' | 'LCH' | 'LAB' | 'HSL' | 'HSLuv' | 'RGB' | 'HSV';
|
18 | type Colorspace = 'CAM02' | 'CAM02p' | 'LCH' | 'LAB' | 'HSL' | 'HSLuv' | 'RGB' | 'HSV' | 'HEX';
|
19 |
|
20 | type RGBArray = number[];
|
21 |
|
22 | type AdaptiveTheme = (brightness: number, constrast?: number) => AdaptiveTheme | ({
|
23 | background: string
|
24 | } | {
|
25 | name: string,
|
26 | values: {
|
27 | name: string,
|
28 | contrast: number,
|
29 | value: string
|
30 | }[]
|
31 | })[];
|
32 |
|
33 | interface ColorScale {
|
34 | colorKeys: string[],
|
35 | colorspace: Colorspace,
|
36 | shift: number,
|
37 | colors: string[],
|
38 | scale: ((d: any) => string) | d3.ScaleLinear<number, number>,
|
39 | colorsHex: string[]
|
40 | }
|
41 |
|
42 | interface NamedColorScale {
|
43 | name: string,
|
44 | colorKeys: string[],
|
45 | colorspace: InterpolationColorspace,
|
46 | ratios: number[] | { [key: string]: number },
|
47 | smooth?: boolean
|
48 | }
|
49 |
|
50 | function createScale({
|
51 | swatches,
|
52 | colorKeys,
|
53 | colorspace,
|
54 | shift,
|
55 | fullScale,
|
56 | smooth
|
57 | }: {
|
58 | swatches: number,
|
59 | colorKeys: string[],
|
60 | colorspace?: InterpolationColorspace,
|
61 | shift?: number,
|
62 | fullScale?: boolean,
|
63 | smooth?: boolean
|
64 | }): ColorScale | never;
|
65 |
|
66 | function luminance(r: number, g: number, b: number): number;
|
67 |
|
68 | function contrast(color: RGBArray, base: RGBArray, baseV: number): number;
|
69 |
|
70 | function binarySearch(list: number[], value: number, baseLum: number): number;
|
71 |
|
72 | function generateBaseScale({
|
73 | colorKeys,
|
74 | colorspace,
|
75 | smooth
|
76 | }: {
|
77 | colorKeys: string[],
|
78 | colorspace?: Colorspace,
|
79 | smooth?: boolean
|
80 | }): string[];
|
81 |
|
82 | function generateContrastColors({
|
83 | colorKeys,
|
84 | base,
|
85 | ratios,
|
86 | colorspace,
|
87 | smooth,
|
88 | output
|
89 | }: {
|
90 | colorKeys: string[],
|
91 | base: string,
|
92 | ratios: number[],
|
93 | colorspace?: InterpolationColorspace,
|
94 | smooth?: boolean,
|
95 | output?: Colorspace
|
96 | }): string[] | never;
|
97 |
|
98 | function minPositive(r: number[]): number | never;
|
99 |
|
100 | function ratioName(r: number[]): number[] | never;
|
101 |
|
102 | function generateAdaptiveTheme({
|
103 | colorScales,
|
104 | baseScale,
|
105 | brightness,
|
106 | contrast,
|
107 | output
|
108 | }: {
|
109 | colorScales: NamedColorScale[],
|
110 | baseScale: string,
|
111 | brightness?: number,
|
112 | contrast?: number,
|
113 | output?: Colorspace,
|
114 | }): AdaptiveTheme | never;
|
115 |
|
116 | function fixColorValue(
|
117 | color: string,
|
118 | format: Colorspace,
|
119 | object?: boolean
|
120 | ): string | { [key: string]: number };
|
121 | } |
\ | No newline at end of file |