@flyncx/mcutil 0.0.0-stage → 26.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/dist/index.d.mts +2297 -0
- package/dist/index.mjs +8057 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/package.json +35 -4
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Functions for blending in HCT and CAM16.
|
|
19
|
+
*/
|
|
20
|
+
declare class Blend {
|
|
21
|
+
/**
|
|
22
|
+
* Blend the design color's HCT hue towards the key color's HCT
|
|
23
|
+
* hue, in a way that leaves the original color recognizable and
|
|
24
|
+
* recognizably shifted towards the key color.
|
|
25
|
+
*
|
|
26
|
+
* @param designColor ARGB representation of an arbitrary color.
|
|
27
|
+
* @param sourceColor ARGB representation of the main theme color.
|
|
28
|
+
* @return The design color with a hue shifted towards the
|
|
29
|
+
* system's color, a slightly warmer/cooler variant of the design
|
|
30
|
+
* color's hue.
|
|
31
|
+
*/
|
|
32
|
+
static harmonize(designColor: number, sourceColor: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Blends hue from one color into another. The chroma and tone of
|
|
35
|
+
* the original color are maintained.
|
|
36
|
+
*
|
|
37
|
+
* @param from ARGB representation of color
|
|
38
|
+
* @param to ARGB representation of color
|
|
39
|
+
* @param amount how much blending to perform; 0.0 >= and <= 1.0
|
|
40
|
+
* @return from, with a hue blended towards to. Chroma and tone
|
|
41
|
+
* are constant.
|
|
42
|
+
*/
|
|
43
|
+
static hctHue(from: number, to: number, amount: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Blend in CAM16-UCS space.
|
|
46
|
+
*
|
|
47
|
+
* @param from ARGB representation of color
|
|
48
|
+
* @param to ARGB representation of color
|
|
49
|
+
* @param amount how much blending to perform; 0.0 >= and <= 1.0
|
|
50
|
+
* @return from, blended towards to. Hue, chroma, and tone will
|
|
51
|
+
* change.
|
|
52
|
+
*/
|
|
53
|
+
static cam16Ucs(from: number, to: number, amount: number): number;
|
|
54
|
+
}
|
|
55
|
+
declare namespace index_d_exports {
|
|
56
|
+
export { Blend };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @license
|
|
60
|
+
* Copyright 2022 Google LLC
|
|
61
|
+
*
|
|
62
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
63
|
+
* you may not use this file except in compliance with the License.
|
|
64
|
+
* You may obtain a copy of the License at
|
|
65
|
+
*
|
|
66
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
67
|
+
*
|
|
68
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
69
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
70
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
71
|
+
* See the License for the specific language governing permissions and
|
|
72
|
+
* limitations under the License.
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* Utility methods for calculating contrast given two colors, or calculating a
|
|
76
|
+
* color given one color and a contrast ratio.
|
|
77
|
+
*
|
|
78
|
+
* Contrast ratio is calculated using XYZ's Y. When linearized to match human
|
|
79
|
+
* perception, Y becomes HCT's tone and L*a*b*'s' L*. Informally, this is the
|
|
80
|
+
* lightness of a color.
|
|
81
|
+
*
|
|
82
|
+
* Methods refer to tone, T in the the HCT color space.
|
|
83
|
+
* Tone is equivalent to L* in the L*a*b* color space, or L in the LCH color
|
|
84
|
+
* space.
|
|
85
|
+
*/
|
|
86
|
+
declare class Contrast {
|
|
87
|
+
/**
|
|
88
|
+
* Returns a contrast ratio, which ranges from 1 to 21.
|
|
89
|
+
*
|
|
90
|
+
* @param toneA Tone between 0 and 100. Values outside will be clamped.
|
|
91
|
+
* @param toneB Tone between 0 and 100. Values outside will be clamped.
|
|
92
|
+
*/
|
|
93
|
+
static ratioOfTones(toneA: number, toneB: number): number;
|
|
94
|
+
static ratioOfYs(y1: number, y2: number): number;
|
|
95
|
+
/**
|
|
96
|
+
* Returns a tone >= tone parameter that ensures ratio parameter.
|
|
97
|
+
* Return value is between 0 and 100.
|
|
98
|
+
* Returns -1 if ratio cannot be achieved with tone parameter.
|
|
99
|
+
*
|
|
100
|
+
* @param tone Tone return value must contrast with.
|
|
101
|
+
* Range is 0 to 100. Invalid values will result in -1 being returned.
|
|
102
|
+
* @param ratio Contrast ratio of return value and tone.
|
|
103
|
+
* Range is 1 to 21, invalid values have undefined behavior.
|
|
104
|
+
*/
|
|
105
|
+
static lighter(tone: number, ratio: number): number;
|
|
106
|
+
/**
|
|
107
|
+
* Returns a tone <= tone parameter that ensures ratio parameter.
|
|
108
|
+
* Return value is between 0 and 100.
|
|
109
|
+
* Returns -1 if ratio cannot be achieved with tone parameter.
|
|
110
|
+
*
|
|
111
|
+
* @param tone Tone return value must contrast with.
|
|
112
|
+
* Range is 0 to 100. Invalid values will result in -1 being returned.
|
|
113
|
+
* @param ratio Contrast ratio of return value and tone.
|
|
114
|
+
* Range is 1 to 21, invalid values have undefined behavior.
|
|
115
|
+
*/
|
|
116
|
+
static darker(tone: number, ratio: number): number;
|
|
117
|
+
/**
|
|
118
|
+
* Returns a tone >= tone parameter that ensures ratio parameter.
|
|
119
|
+
* Return value is between 0 and 100.
|
|
120
|
+
* Returns 100 if ratio cannot be achieved with tone parameter.
|
|
121
|
+
*
|
|
122
|
+
* This method is unsafe because the returned value is guaranteed to be in
|
|
123
|
+
* bounds for tone, i.e. between 0 and 100. However, that value may not reach
|
|
124
|
+
* the ratio with tone. For example, there is no color lighter than T100.
|
|
125
|
+
*
|
|
126
|
+
* @param tone Tone return value must contrast with.
|
|
127
|
+
* Range is 0 to 100. Invalid values will result in 100 being returned.
|
|
128
|
+
* @param ratio Desired contrast ratio of return value and tone parameter.
|
|
129
|
+
* Range is 1 to 21, invalid values have undefined behavior.
|
|
130
|
+
*/
|
|
131
|
+
static lighterUnsafe(tone: number, ratio: number): number;
|
|
132
|
+
/**
|
|
133
|
+
* Returns a tone >= tone parameter that ensures ratio parameter.
|
|
134
|
+
* Return value is between 0 and 100.
|
|
135
|
+
* Returns 100 if ratio cannot be achieved with tone parameter.
|
|
136
|
+
*
|
|
137
|
+
* This method is unsafe because the returned value is guaranteed to be in
|
|
138
|
+
* bounds for tone, i.e. between 0 and 100. However, that value may not reach
|
|
139
|
+
* the [ratio with [tone]. For example, there is no color darker than T0.
|
|
140
|
+
*
|
|
141
|
+
* @param tone Tone return value must contrast with.
|
|
142
|
+
* Range is 0 to 100. Invalid values will result in 0 being returned.
|
|
143
|
+
* @param ratio Desired contrast ratio of return value and tone parameter.
|
|
144
|
+
* Range is 1 to 21, invalid values have undefined behavior.
|
|
145
|
+
*/
|
|
146
|
+
static darkerUnsafe(tone: number, ratio: number): number;
|
|
147
|
+
}
|
|
148
|
+
declare namespace index_d_exports$1 {
|
|
149
|
+
export { Contrast };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @license
|
|
153
|
+
* Copyright 2021 Google LLC
|
|
154
|
+
*
|
|
155
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
156
|
+
* you may not use this file except in compliance with the License.
|
|
157
|
+
* You may obtain a copy of the License at
|
|
158
|
+
*
|
|
159
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
160
|
+
*
|
|
161
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
162
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
163
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
164
|
+
* See the License for the specific language governing permissions and
|
|
165
|
+
* limitations under the License.
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* In traditional color spaces, a color can be identified solely by the
|
|
169
|
+
* observer's measurement of the color. Color appearance models such as CAM16
|
|
170
|
+
* also use information about the environment where the color was
|
|
171
|
+
* observed, known as the viewing conditions.
|
|
172
|
+
*
|
|
173
|
+
* For example, white under the traditional assumption of a midday sun white
|
|
174
|
+
* point is accurately measured as a slightly chromatic blue by CAM16. (roughly,
|
|
175
|
+
* hue 203, chroma 3, lightness 100)
|
|
176
|
+
*
|
|
177
|
+
* This class caches intermediate values of the CAM16 conversion process that
|
|
178
|
+
* depend only on viewing conditions, enabling speed ups.
|
|
179
|
+
*/
|
|
180
|
+
declare class ViewingConditions {
|
|
181
|
+
n: number;
|
|
182
|
+
aw: number;
|
|
183
|
+
nbb: number;
|
|
184
|
+
ncb: number;
|
|
185
|
+
c: number;
|
|
186
|
+
nc: number;
|
|
187
|
+
rgbD: number[];
|
|
188
|
+
fl: number;
|
|
189
|
+
fLRoot: number;
|
|
190
|
+
z: number;
|
|
191
|
+
/** sRGB-like viewing conditions. */
|
|
192
|
+
static DEFAULT: ViewingConditions;
|
|
193
|
+
/**
|
|
194
|
+
* Create ViewingConditions from a simple, physically relevant, set of
|
|
195
|
+
* parameters.
|
|
196
|
+
*
|
|
197
|
+
* @param whitePoint White point, measured in the XYZ color space.
|
|
198
|
+
* default = D65, or sunny day afternoon
|
|
199
|
+
* @param adaptingLuminance The luminance of the adapting field. Informally,
|
|
200
|
+
* how bright it is in the room where the color is viewed. Can be
|
|
201
|
+
* calculated from lux by multiplying lux by 0.0586. default = 11.72,
|
|
202
|
+
* or 200 lux.
|
|
203
|
+
* @param backgroundLstar The lightness of the area surrounding the color.
|
|
204
|
+
* measured by L* in L*a*b*. default = 50.0
|
|
205
|
+
* @param surround A general description of the lighting surrounding the
|
|
206
|
+
* color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
|
|
207
|
+
* dimly light room, like watching TV at home at night. 2.0 means there
|
|
208
|
+
* is no difference between the lighting on the color and around it.
|
|
209
|
+
* default = 2.0
|
|
210
|
+
* @param discountingIlluminant Whether the eye accounts for the tint of the
|
|
211
|
+
* ambient lighting, such as knowing an apple is still red in green light.
|
|
212
|
+
* default = false, the eye does not perform this process on
|
|
213
|
+
* self-luminous objects like displays.
|
|
214
|
+
*/
|
|
215
|
+
static make(whitePoint?: number[], adaptingLuminance?: number, backgroundLstar?: number, surround?: number, discountingIlluminant?: boolean): ViewingConditions;
|
|
216
|
+
/**
|
|
217
|
+
* Parameters are intermediate values of the CAM16 conversion process. Their
|
|
218
|
+
* names are shorthand for technical color science terminology, this class
|
|
219
|
+
* would not benefit from documenting them individually. A brief overview
|
|
220
|
+
* is available in the CAM16 specification, and a complete overview requires
|
|
221
|
+
* a color science textbook, such as Fairchild's Color Appearance Models.
|
|
222
|
+
*/
|
|
223
|
+
private constructor();
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* CAM16, a color appearance model. Colors are not just defined by their hex
|
|
227
|
+
* code, but rather, a hex code and viewing conditions.
|
|
228
|
+
*
|
|
229
|
+
* CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*,
|
|
230
|
+
* b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
|
|
231
|
+
* specification, and should be used when measuring distances between colors.
|
|
232
|
+
*
|
|
233
|
+
* In traditional color spaces, a color can be identified solely by the
|
|
234
|
+
* observer's measurement of the color. Color appearance models such as CAM16
|
|
235
|
+
* also use information about the environment where the color was
|
|
236
|
+
* observed, known as the viewing conditions.
|
|
237
|
+
*
|
|
238
|
+
* For example, white under the traditional assumption of a midday sun white
|
|
239
|
+
* point is accurately measured as a slightly chromatic blue by CAM16. (roughly,
|
|
240
|
+
* hue 203, chroma 3, lightness 100)
|
|
241
|
+
*/
|
|
242
|
+
declare class Cam16 {
|
|
243
|
+
readonly hue: number;
|
|
244
|
+
readonly chroma: number;
|
|
245
|
+
readonly j: number;
|
|
246
|
+
readonly q: number;
|
|
247
|
+
readonly m: number;
|
|
248
|
+
readonly s: number;
|
|
249
|
+
readonly jstar: number;
|
|
250
|
+
readonly astar: number;
|
|
251
|
+
readonly bstar: number;
|
|
252
|
+
/**
|
|
253
|
+
* All of the CAM16 dimensions can be calculated from 3 of the dimensions, in
|
|
254
|
+
* the following combinations:
|
|
255
|
+
* - {j or q} and {c, m, or s} and hue
|
|
256
|
+
* - jstar, astar, bstar
|
|
257
|
+
* Prefer using a static method that constructs from 3 of those dimensions.
|
|
258
|
+
* This constructor is intended for those methods to use to return all
|
|
259
|
+
* possible dimensions.
|
|
260
|
+
*
|
|
261
|
+
* @param hue
|
|
262
|
+
* @param chroma informally, colorfulness / color intensity. like saturation
|
|
263
|
+
* in HSL, except perceptually accurate.
|
|
264
|
+
* @param j lightness
|
|
265
|
+
* @param q brightness; ratio of lightness to white point's lightness
|
|
266
|
+
* @param m colorfulness
|
|
267
|
+
* @param s saturation; ratio of chroma to white point's chroma
|
|
268
|
+
* @param jstar CAM16-UCS J coordinate
|
|
269
|
+
* @param astar CAM16-UCS a coordinate
|
|
270
|
+
* @param bstar CAM16-UCS b coordinate
|
|
271
|
+
*/
|
|
272
|
+
constructor(hue: number, chroma: number, j: number, q: number, m: number, s: number, jstar: number, astar: number, bstar: number);
|
|
273
|
+
/**
|
|
274
|
+
* CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
|
|
275
|
+
* a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
|
|
276
|
+
* specification, and is used to measure distances between colors.
|
|
277
|
+
*/
|
|
278
|
+
distance(other: Cam16): number;
|
|
279
|
+
/**
|
|
280
|
+
* @param argb ARGB representation of a color.
|
|
281
|
+
* @return CAM16 color, assuming the color was viewed in default viewing
|
|
282
|
+
* conditions.
|
|
283
|
+
*/
|
|
284
|
+
static fromInt(argb: number): Cam16;
|
|
285
|
+
/**
|
|
286
|
+
* @param argb ARGB representation of a color.
|
|
287
|
+
* @param viewingConditions Information about the environment where the color
|
|
288
|
+
* was observed.
|
|
289
|
+
* @return CAM16 color.
|
|
290
|
+
*/
|
|
291
|
+
static fromIntInViewingConditions(argb: number, viewingConditions: ViewingConditions): Cam16;
|
|
292
|
+
/**
|
|
293
|
+
* @param j CAM16 lightness
|
|
294
|
+
* @param c CAM16 chroma
|
|
295
|
+
* @param h CAM16 hue
|
|
296
|
+
*/
|
|
297
|
+
static fromJch(j: number, c: number, h: number): Cam16;
|
|
298
|
+
/**
|
|
299
|
+
* @param j CAM16 lightness
|
|
300
|
+
* @param c CAM16 chroma
|
|
301
|
+
* @param h CAM16 hue
|
|
302
|
+
* @param viewingConditions Information about the environment where the color
|
|
303
|
+
* was observed.
|
|
304
|
+
*/
|
|
305
|
+
static fromJchInViewingConditions(j: number, c: number, h: number, viewingConditions: ViewingConditions): Cam16;
|
|
306
|
+
/**
|
|
307
|
+
* @param jstar CAM16-UCS lightness.
|
|
308
|
+
* @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
|
|
309
|
+
* coordinate on the Y axis.
|
|
310
|
+
* @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
|
|
311
|
+
* coordinate on the X axis.
|
|
312
|
+
*/
|
|
313
|
+
static fromUcs(jstar: number, astar: number, bstar: number): Cam16;
|
|
314
|
+
/**
|
|
315
|
+
* @param jstar CAM16-UCS lightness.
|
|
316
|
+
* @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
|
|
317
|
+
* coordinate on the Y axis.
|
|
318
|
+
* @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
|
|
319
|
+
* coordinate on the X axis.
|
|
320
|
+
* @param viewingConditions Information about the environment where the color
|
|
321
|
+
* was observed.
|
|
322
|
+
*/
|
|
323
|
+
static fromUcsInViewingConditions(jstar: number, astar: number, bstar: number, viewingConditions: ViewingConditions): Cam16;
|
|
324
|
+
/**
|
|
325
|
+
* @return ARGB representation of color, assuming the color was viewed in
|
|
326
|
+
* default viewing conditions, which are near-identical to the default
|
|
327
|
+
* viewing conditions for sRGB.
|
|
328
|
+
*/
|
|
329
|
+
toInt(): number;
|
|
330
|
+
/**
|
|
331
|
+
* @param viewingConditions Information about the environment where the color
|
|
332
|
+
* will be viewed.
|
|
333
|
+
* @return ARGB representation of color
|
|
334
|
+
*/
|
|
335
|
+
viewed(viewingConditions: ViewingConditions): number;
|
|
336
|
+
static fromXyzInViewingConditions(x: number, y: number, z: number, viewingConditions: ViewingConditions): Cam16;
|
|
337
|
+
xyzInViewingConditions(viewingConditions: ViewingConditions): number[];
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* HCT, hue, chroma, and tone. A color system that provides a perceptually
|
|
341
|
+
* accurate color measurement system that can also accurately render what colors
|
|
342
|
+
* will appear as in different lighting environments.
|
|
343
|
+
*/
|
|
344
|
+
declare class Hct {
|
|
345
|
+
private argb;
|
|
346
|
+
/**
|
|
347
|
+
* @param hue 0 <= hue < 360; invalid values are corrected.
|
|
348
|
+
* @param chroma 0 <= chroma < ?; Informally, colorfulness. The color
|
|
349
|
+
* returned may be lower than the requested chroma. Chroma has a different
|
|
350
|
+
* maximum for any given hue and tone.
|
|
351
|
+
* @param tone 0 <= tone <= 100; invalid values are corrected.
|
|
352
|
+
* @return HCT representation of a color in default viewing conditions.
|
|
353
|
+
*/
|
|
354
|
+
internalHue: number;
|
|
355
|
+
internalChroma: number;
|
|
356
|
+
internalTone: number;
|
|
357
|
+
static from(hue: number, chroma: number, tone: number): Hct;
|
|
358
|
+
/**
|
|
359
|
+
* @param argb ARGB representation of a color.
|
|
360
|
+
* @return HCT representation of a color in default viewing conditions
|
|
361
|
+
*/
|
|
362
|
+
static fromInt(argb: number): Hct;
|
|
363
|
+
toInt(): number;
|
|
364
|
+
/**
|
|
365
|
+
* A number, in degrees, representing ex. red, orange, yellow, etc.
|
|
366
|
+
* Ranges from 0 <= hue < 360.
|
|
367
|
+
*/
|
|
368
|
+
get hue(): number;
|
|
369
|
+
/**
|
|
370
|
+
* @param newHue 0 <= newHue < 360; invalid values are corrected.
|
|
371
|
+
* Chroma may decrease because chroma has a different maximum for any given
|
|
372
|
+
* hue and tone.
|
|
373
|
+
*/
|
|
374
|
+
set hue(newHue: number);
|
|
375
|
+
get chroma(): number;
|
|
376
|
+
/**
|
|
377
|
+
* @param newChroma 0 <= newChroma < ?
|
|
378
|
+
* Chroma may decrease because chroma has a different maximum for any given
|
|
379
|
+
* hue and tone.
|
|
380
|
+
*/
|
|
381
|
+
set chroma(newChroma: number);
|
|
382
|
+
/** Lightness. Ranges from 0 to 100. */
|
|
383
|
+
get tone(): number;
|
|
384
|
+
/**
|
|
385
|
+
* @param newTone 0 <= newTone <= 100; invalid valids are corrected.
|
|
386
|
+
* Chroma may decrease because chroma has a different maximum for any given
|
|
387
|
+
* hue and tone.
|
|
388
|
+
*/
|
|
389
|
+
set tone(newTone: number);
|
|
390
|
+
/** Sets a property of the Hct object. */
|
|
391
|
+
setValue(propertyName: string, value: number): void;
|
|
392
|
+
toString(): string;
|
|
393
|
+
static isBlue(hue: number): boolean;
|
|
394
|
+
static isYellow(hue: number): boolean;
|
|
395
|
+
static isCyan(hue: number): boolean;
|
|
396
|
+
private constructor();
|
|
397
|
+
private setInternalState;
|
|
398
|
+
/**
|
|
399
|
+
* Translates a color into different [ViewingConditions].
|
|
400
|
+
*
|
|
401
|
+
* Colors change appearance. They look different with lights on versus off,
|
|
402
|
+
* the same color, as in hex code, on white looks different when on black.
|
|
403
|
+
* This is called color relativity, most famously explicated by Josef Albers
|
|
404
|
+
* in Interaction of Color.
|
|
405
|
+
*
|
|
406
|
+
* In color science, color appearance models can account for this and
|
|
407
|
+
* calculate the appearance of a color in different settings. HCT is based on
|
|
408
|
+
* CAM16, a color appearance model, and uses it to make these calculations.
|
|
409
|
+
*
|
|
410
|
+
* See [ViewingConditions.make] for parameters affecting color appearance.
|
|
411
|
+
*/
|
|
412
|
+
inViewingConditions(vc: ViewingConditions): Hct;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* A class that solves the HCT equation.
|
|
416
|
+
*/
|
|
417
|
+
declare class HctSolver {
|
|
418
|
+
static SCALED_DISCOUNT_FROM_LINRGB: number[][];
|
|
419
|
+
static LINRGB_FROM_SCALED_DISCOUNT: number[][];
|
|
420
|
+
static Y_FROM_LINRGB: number[];
|
|
421
|
+
static CRITICAL_PLANES: number[];
|
|
422
|
+
/**
|
|
423
|
+
* Sanitizes a small enough angle in radians.
|
|
424
|
+
*
|
|
425
|
+
* @param angle An angle in radians; must not deviate too much
|
|
426
|
+
* from 0.
|
|
427
|
+
* @return A coterminal angle between 0 and 2pi.
|
|
428
|
+
*/
|
|
429
|
+
private static sanitizeRadians;
|
|
430
|
+
/**
|
|
431
|
+
* Delinearizes an RGB component, returning a floating-point
|
|
432
|
+
* number.
|
|
433
|
+
*
|
|
434
|
+
* @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
|
|
435
|
+
* linear R/G/B channel
|
|
436
|
+
* @return 0.0 <= output <= 255.0, color channel converted to
|
|
437
|
+
* regular RGB space
|
|
438
|
+
*/
|
|
439
|
+
private static trueDelinearized;
|
|
440
|
+
private static chromaticAdaptation;
|
|
441
|
+
/**
|
|
442
|
+
* Returns the hue of a linear RGB color in CAM16.
|
|
443
|
+
*
|
|
444
|
+
* @param linrgb The linear RGB coordinates of a color.
|
|
445
|
+
* @return The hue of the color in CAM16, in radians.
|
|
446
|
+
*/
|
|
447
|
+
private static hueOf;
|
|
448
|
+
private static areInCyclicOrder;
|
|
449
|
+
/**
|
|
450
|
+
* Solves the lerp equation.
|
|
451
|
+
*
|
|
452
|
+
* @param source The starting number.
|
|
453
|
+
* @param mid The number in the middle.
|
|
454
|
+
* @param target The ending number.
|
|
455
|
+
* @return A number t such that lerp(source, target, t) = mid.
|
|
456
|
+
*/
|
|
457
|
+
private static intercept;
|
|
458
|
+
private static lerpPoint;
|
|
459
|
+
/**
|
|
460
|
+
* Intersects a segment with a plane.
|
|
461
|
+
*
|
|
462
|
+
* @param source The coordinates of point A.
|
|
463
|
+
* @param coordinate The R-, G-, or B-coordinate of the plane.
|
|
464
|
+
* @param target The coordinates of point B.
|
|
465
|
+
* @param axis The axis the plane is perpendicular with. (0: R, 1:
|
|
466
|
+
* G, 2: B)
|
|
467
|
+
* @return The intersection point of the segment AB with the plane
|
|
468
|
+
* R=coordinate, G=coordinate, or B=coordinate
|
|
469
|
+
*/
|
|
470
|
+
private static setCoordinate;
|
|
471
|
+
private static isBounded;
|
|
472
|
+
/**
|
|
473
|
+
* Returns the nth possible vertex of the polygonal intersection.
|
|
474
|
+
*
|
|
475
|
+
* @param y The Y value of the plane.
|
|
476
|
+
* @param n The zero-based index of the point. 0 <= n <= 11.
|
|
477
|
+
* @return The nth possible vertex of the polygonal intersection
|
|
478
|
+
* of the y plane and the RGB cube, in linear RGB coordinates, if
|
|
479
|
+
* it exists. If this possible vertex lies outside of the cube,
|
|
480
|
+
* [-1.0, -1.0, -1.0] is returned.
|
|
481
|
+
*/
|
|
482
|
+
private static nthVertex;
|
|
483
|
+
/**
|
|
484
|
+
* Finds the segment containing the desired color.
|
|
485
|
+
*
|
|
486
|
+
* @param y The Y value of the color.
|
|
487
|
+
* @param targetHue The hue of the color.
|
|
488
|
+
* @return A list of two sets of linear RGB coordinates, each
|
|
489
|
+
* corresponding to an endpoint of the segment containing the
|
|
490
|
+
* desired color.
|
|
491
|
+
*/
|
|
492
|
+
private static bisectToSegment;
|
|
493
|
+
private static midpoint;
|
|
494
|
+
private static criticalPlaneBelow;
|
|
495
|
+
private static criticalPlaneAbove;
|
|
496
|
+
/**
|
|
497
|
+
* Finds a color with the given Y and hue on the boundary of the
|
|
498
|
+
* cube.
|
|
499
|
+
*
|
|
500
|
+
* @param y The Y value of the color.
|
|
501
|
+
* @param targetHue The hue of the color.
|
|
502
|
+
* @return The desired color, in linear RGB coordinates.
|
|
503
|
+
*/
|
|
504
|
+
private static bisectToLimit;
|
|
505
|
+
private static inverseChromaticAdaptation;
|
|
506
|
+
/**
|
|
507
|
+
* Finds a color with the given hue, chroma, and Y.
|
|
508
|
+
*
|
|
509
|
+
* @param hueRadians The desired hue in radians.
|
|
510
|
+
* @param chroma The desired chroma.
|
|
511
|
+
* @param y The desired Y.
|
|
512
|
+
* @return The desired color as a hexadecimal integer, if found; 0
|
|
513
|
+
* otherwise.
|
|
514
|
+
*/
|
|
515
|
+
private static findResultByJ;
|
|
516
|
+
/**
|
|
517
|
+
* Finds an sRGB color with the given hue, chroma, and L*, if
|
|
518
|
+
* possible.
|
|
519
|
+
*
|
|
520
|
+
* @param hueDegrees The desired hue, in degrees.
|
|
521
|
+
* @param chroma The desired chroma.
|
|
522
|
+
* @param lstar The desired L*.
|
|
523
|
+
* @return A hexadecimal representing the sRGB color. The color
|
|
524
|
+
* has sufficiently close hue, chroma, and L* to the desired
|
|
525
|
+
* values, if possible; otherwise, the hue and L* will be
|
|
526
|
+
* sufficiently close, and chroma will be maximized.
|
|
527
|
+
*/
|
|
528
|
+
static solveToInt(hueDegrees: number, chroma: number, lstar: number): number;
|
|
529
|
+
/**
|
|
530
|
+
* Finds an sRGB color with the given hue, chroma, and L*, if
|
|
531
|
+
* possible.
|
|
532
|
+
*
|
|
533
|
+
* @param hueDegrees The desired hue, in degrees.
|
|
534
|
+
* @param chroma The desired chroma.
|
|
535
|
+
* @param lstar The desired L*.
|
|
536
|
+
* @return An CAM16 object representing the sRGB color. The color
|
|
537
|
+
* has sufficiently close hue, chroma, and L* to the desired
|
|
538
|
+
* values, if possible; otherwise, the hue and L* will be
|
|
539
|
+
* sufficiently close, and chroma will be maximized.
|
|
540
|
+
*/
|
|
541
|
+
static solveToCam(hueDegrees: number, chroma: number, lstar: number): Cam16;
|
|
542
|
+
}
|
|
543
|
+
declare namespace index_d_exports$3 {
|
|
544
|
+
export { Cam16, Hct, HctSolver, ViewingConditions };
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Check and/or fix universally disliked colors.
|
|
548
|
+
* Color science studies of color preference indicate universal distaste for
|
|
549
|
+
* dark yellow-greens, and also show this is correlated to distate for
|
|
550
|
+
* biological waste and rotting food.
|
|
551
|
+
*
|
|
552
|
+
* See Palmer and Schloss, 2010 or Schloss and Palmer's Chapter 21 in Handbook
|
|
553
|
+
* of Color Psychology (2015).
|
|
554
|
+
*/
|
|
555
|
+
declare class DislikeAnalyzer {
|
|
556
|
+
/**
|
|
557
|
+
* Returns true if a color is disliked.
|
|
558
|
+
*
|
|
559
|
+
* @param hct A color to be judged.
|
|
560
|
+
* @return Whether the color is disliked.
|
|
561
|
+
*
|
|
562
|
+
* Disliked is defined as a dark yellow-green that is not neutral.
|
|
563
|
+
*/
|
|
564
|
+
static isDisliked(hct: Hct): boolean;
|
|
565
|
+
/**
|
|
566
|
+
* If a color is disliked, lighten it to make it likable.
|
|
567
|
+
*
|
|
568
|
+
* @param hct A color to be judged.
|
|
569
|
+
* @return A new color if the original color is disliked, or the original
|
|
570
|
+
* color if it is acceptable.
|
|
571
|
+
*/
|
|
572
|
+
static fixIfDisliked(hct: Hct): Hct;
|
|
573
|
+
}
|
|
574
|
+
declare namespace index_d_exports$2 {
|
|
575
|
+
export { DislikeAnalyzer };
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* A convenience class for retrieving colors that are constant in hue and
|
|
579
|
+
* chroma, but vary in tone.
|
|
580
|
+
*/
|
|
581
|
+
declare class TonalPalette {
|
|
582
|
+
readonly hue: number;
|
|
583
|
+
readonly chroma: number;
|
|
584
|
+
readonly keyColor: Hct;
|
|
585
|
+
private readonly cache;
|
|
586
|
+
/**
|
|
587
|
+
* @param argb ARGB representation of a color
|
|
588
|
+
* @return Tones matching that color's hue and chroma.
|
|
589
|
+
*/
|
|
590
|
+
static fromInt(argb: number): TonalPalette;
|
|
591
|
+
/**
|
|
592
|
+
* @param hct Hct
|
|
593
|
+
* @return Tones matching that color's hue and chroma.
|
|
594
|
+
*/
|
|
595
|
+
static fromHct(hct: Hct): TonalPalette;
|
|
596
|
+
/**
|
|
597
|
+
* @param hue HCT hue
|
|
598
|
+
* @param chroma HCT chroma
|
|
599
|
+
* @return Tones matching hue and chroma.
|
|
600
|
+
*/
|
|
601
|
+
static fromHueAndChroma(hue: number, chroma: number): TonalPalette;
|
|
602
|
+
private constructor();
|
|
603
|
+
/**
|
|
604
|
+
* @param tone HCT tone, measured from 0 to 100.
|
|
605
|
+
* @return ARGB representation of a color with that tone.
|
|
606
|
+
*/
|
|
607
|
+
tone(tone: number): number;
|
|
608
|
+
/**
|
|
609
|
+
* @param tone HCT tone.
|
|
610
|
+
* @return HCT representation of a color with that tone.
|
|
611
|
+
*/
|
|
612
|
+
getHct(tone: number): Hct;
|
|
613
|
+
private averageArgb;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* @deprecated Use {@link DynamicScheme} for color scheme generation.
|
|
617
|
+
* Use {@link CorePalettes} for core palettes container class.
|
|
618
|
+
*/
|
|
619
|
+
interface CorePaletteColors {
|
|
620
|
+
primary: number;
|
|
621
|
+
secondary?: number;
|
|
622
|
+
tertiary?: number;
|
|
623
|
+
neutral?: number;
|
|
624
|
+
neutralVariant?: number;
|
|
625
|
+
error?: number;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* An intermediate concept between the key color for a UI theme, and a full
|
|
629
|
+
* color scheme. 5 sets of tones are generated, all except one use the same hue
|
|
630
|
+
* as the key color, and all vary in chroma.
|
|
631
|
+
*
|
|
632
|
+
* @deprecated Use {@link DynamicScheme} for color scheme generation.
|
|
633
|
+
* Use {@link CorePalettes} for core palettes container class.
|
|
634
|
+
*/
|
|
635
|
+
declare class CorePalette {
|
|
636
|
+
a1: TonalPalette;
|
|
637
|
+
a2: TonalPalette;
|
|
638
|
+
a3: TonalPalette;
|
|
639
|
+
n1: TonalPalette;
|
|
640
|
+
n2: TonalPalette;
|
|
641
|
+
error: TonalPalette;
|
|
642
|
+
/**
|
|
643
|
+
* @param argb ARGB representation of a color
|
|
644
|
+
*
|
|
645
|
+
* @deprecated Use {@link DynamicScheme} for color scheme generation.
|
|
646
|
+
* Use {@link CorePalettes} for core palettes container class.
|
|
647
|
+
*/
|
|
648
|
+
static of(argb: number): CorePalette;
|
|
649
|
+
/**
|
|
650
|
+
* @param argb ARGB representation of a color
|
|
651
|
+
*
|
|
652
|
+
* @deprecated Use {@link DynamicScheme} for color scheme generation.
|
|
653
|
+
* Use {@link CorePalettes} for core palettes container class.
|
|
654
|
+
*/
|
|
655
|
+
static contentOf(argb: number): CorePalette;
|
|
656
|
+
/**
|
|
657
|
+
* Create a [CorePalette] from a set of colors
|
|
658
|
+
*
|
|
659
|
+
* @deprecated Use {@link DynamicScheme} for color scheme generation.
|
|
660
|
+
* Use {@link CorePalettes} for core palettes container class.
|
|
661
|
+
*/
|
|
662
|
+
static fromColors(colors: CorePaletteColors): CorePalette;
|
|
663
|
+
/**
|
|
664
|
+
* Create a content [CorePalette] from a set of colors
|
|
665
|
+
*
|
|
666
|
+
* @deprecated Use {@link DynamicScheme} for color scheme generation.
|
|
667
|
+
* Use {@link CorePalettes} for core palettes container class.
|
|
668
|
+
*/
|
|
669
|
+
static contentFromColors(colors: CorePaletteColors): CorePalette;
|
|
670
|
+
private static createPaletteFromColors;
|
|
671
|
+
private constructor();
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Comprises foundational palettes to build a color scheme. Generated from a
|
|
675
|
+
* source color, these palettes will then be part of a [DynamicScheme] together
|
|
676
|
+
* with appearance preferences.
|
|
677
|
+
*/
|
|
678
|
+
declare class CorePalettes {
|
|
679
|
+
primary: TonalPalette;
|
|
680
|
+
secondary: TonalPalette;
|
|
681
|
+
tertiary: TonalPalette;
|
|
682
|
+
neutral: TonalPalette;
|
|
683
|
+
neutralVariant: TonalPalette;
|
|
684
|
+
constructor(primary: TonalPalette, secondary: TonalPalette, tertiary: TonalPalette, neutral: TonalPalette, neutralVariant: TonalPalette);
|
|
685
|
+
}
|
|
686
|
+
declare namespace index_d_exports$4 {
|
|
687
|
+
export { CorePalette, CorePalettes, TonalPalette };
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* @license
|
|
691
|
+
* Copyright 2021 Google LLC
|
|
692
|
+
*
|
|
693
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
694
|
+
* you may not use this file except in compliance with the License.
|
|
695
|
+
* You may obtain a copy of the License at
|
|
696
|
+
*
|
|
697
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
698
|
+
*
|
|
699
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
700
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
701
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
702
|
+
* See the License for the specific language governing permissions and
|
|
703
|
+
* limitations under the License.
|
|
704
|
+
*/
|
|
705
|
+
/**
|
|
706
|
+
* An interface to allow use of different color spaces by
|
|
707
|
+
* quantizers.
|
|
708
|
+
*/
|
|
709
|
+
declare interface PointProvider {
|
|
710
|
+
toInt(point: number[]): number;
|
|
711
|
+
fromInt(argb: number): number[];
|
|
712
|
+
distance(from: number[], to: number[]): number;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Provides conversions needed for K-Means quantization. Converting input to
|
|
716
|
+
* points, and converting the final state of the K-Means algorithm to colors.
|
|
717
|
+
*/
|
|
718
|
+
declare class PointProviderLab implements PointProvider {
|
|
719
|
+
/**
|
|
720
|
+
* Convert a color represented in ARGB to a 3-element array of L*a*b*
|
|
721
|
+
* coordinates of the color.
|
|
722
|
+
*/
|
|
723
|
+
fromInt(argb: number): number[];
|
|
724
|
+
/**
|
|
725
|
+
* Convert a 3-element array to a color represented in ARGB.
|
|
726
|
+
*/
|
|
727
|
+
toInt(point: number[]): number;
|
|
728
|
+
/**
|
|
729
|
+
* Standard CIE 1976 delta E formula also takes the square root, unneeded
|
|
730
|
+
* here. This method is used by quantization algorithms to compare distance,
|
|
731
|
+
* and the relative ordering is the same, with or without a square root.
|
|
732
|
+
*
|
|
733
|
+
* This relatively minor optimization is helpful because this method is
|
|
734
|
+
* called at least once for each pixel in an image.
|
|
735
|
+
*/
|
|
736
|
+
distance(from: number[], to: number[]): number;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* @license
|
|
740
|
+
* Copyright 2021 Google LLC
|
|
741
|
+
*
|
|
742
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
743
|
+
* you may not use this file except in compliance with the License.
|
|
744
|
+
* You may obtain a copy of the License at
|
|
745
|
+
*
|
|
746
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
747
|
+
*
|
|
748
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
749
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
750
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
751
|
+
* See the License for the specific language governing permissions and
|
|
752
|
+
* limitations under the License.
|
|
753
|
+
*/
|
|
754
|
+
/**
|
|
755
|
+
* An image quantizer that improves on the quality of a standard K-Means
|
|
756
|
+
* algorithm by setting the K-Means initial state to the output of a Wu
|
|
757
|
+
* quantizer, instead of random centroids. Improves on speed by several
|
|
758
|
+
* optimizations, as implemented in Wsmeans, or Weighted Square Means, K-Means
|
|
759
|
+
* with those optimizations.
|
|
760
|
+
*
|
|
761
|
+
* This algorithm was designed by M. Emre Celebi, and was found in their 2011
|
|
762
|
+
* paper, Improving the Performance of K-Means for Color Quantization.
|
|
763
|
+
* https://arxiv.org/abs/1101.0395
|
|
764
|
+
*/
|
|
765
|
+
declare class QuantizerCelebi {
|
|
766
|
+
/**
|
|
767
|
+
* @param pixels Colors in ARGB format.
|
|
768
|
+
* @param maxColors The number of colors to divide the image into. A lower
|
|
769
|
+
* number of colors may be returned.
|
|
770
|
+
* @return Map with keys of colors in ARGB format, and values of number of
|
|
771
|
+
* pixels in the original image that correspond to the color in the
|
|
772
|
+
* quantized image.
|
|
773
|
+
*/
|
|
774
|
+
static quantize(pixels: number[], maxColors: number): Map<number, number>;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* @license
|
|
778
|
+
* Copyright 2021 Google LLC
|
|
779
|
+
*
|
|
780
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
781
|
+
* you may not use this file except in compliance with the License.
|
|
782
|
+
* You may obtain a copy of the License at
|
|
783
|
+
*
|
|
784
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
785
|
+
*
|
|
786
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
787
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
788
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
789
|
+
* See the License for the specific language governing permissions and
|
|
790
|
+
* limitations under the License.
|
|
791
|
+
*/
|
|
792
|
+
/**
|
|
793
|
+
* Quantizes an image into a map, with keys of ARGB colors, and values of the
|
|
794
|
+
* number of times that color appears in the image.
|
|
795
|
+
*/
|
|
796
|
+
declare class QuantizerMap {
|
|
797
|
+
/**
|
|
798
|
+
* @param pixels Colors in ARGB format.
|
|
799
|
+
* @return A Map with keys of ARGB colors, and values of the number of times
|
|
800
|
+
* the color appears in the image.
|
|
801
|
+
*/
|
|
802
|
+
static quantize(pixels: number[]): Map<number, number>;
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* @license
|
|
806
|
+
* Copyright 2021 Google LLC
|
|
807
|
+
*
|
|
808
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
809
|
+
* you may not use this file except in compliance with the License.
|
|
810
|
+
* You may obtain a copy of the License at
|
|
811
|
+
*
|
|
812
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
813
|
+
*
|
|
814
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
815
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
816
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
817
|
+
* See the License for the specific language governing permissions and
|
|
818
|
+
* limitations under the License.
|
|
819
|
+
*/
|
|
820
|
+
/**
|
|
821
|
+
* An image quantizer that improves on the speed of a standard K-Means algorithm
|
|
822
|
+
* by implementing several optimizations, including deduping identical pixels
|
|
823
|
+
* and a triangle inequality rule that reduces the number of comparisons needed
|
|
824
|
+
* to identify which cluster a point should be moved to.
|
|
825
|
+
*
|
|
826
|
+
* Wsmeans stands for Weighted Square Means.
|
|
827
|
+
*
|
|
828
|
+
* This algorithm was designed by M. Emre Celebi, and was found in their 2011
|
|
829
|
+
* paper, Improving the Performance of K-Means for Color Quantization.
|
|
830
|
+
* https://arxiv.org/abs/1101.0395
|
|
831
|
+
*/
|
|
832
|
+
declare class QuantizerWsmeans {
|
|
833
|
+
/**
|
|
834
|
+
* @param inputPixels Colors in ARGB format.
|
|
835
|
+
* @param startingClusters Defines the initial state of the quantizer. Passing
|
|
836
|
+
* an empty array is fine, the implementation will create its own initial
|
|
837
|
+
* state that leads to reproducible results for the same inputs.
|
|
838
|
+
* Passing an array that is the result of Wu quantization leads to higher
|
|
839
|
+
* quality results.
|
|
840
|
+
* @param maxColors The number of colors to divide the image into. A lower
|
|
841
|
+
* number of colors may be returned.
|
|
842
|
+
* @return Colors in ARGB format.
|
|
843
|
+
*/
|
|
844
|
+
static quantize(inputPixels: number[], startingClusters: number[], maxColors: number): Map<number, number>;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* @license
|
|
848
|
+
* Copyright 2021 Google LLC
|
|
849
|
+
*
|
|
850
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
851
|
+
* you may not use this file except in compliance with the License.
|
|
852
|
+
* You may obtain a copy of the License at
|
|
853
|
+
*
|
|
854
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
855
|
+
*
|
|
856
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
857
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
858
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
859
|
+
* See the License for the specific language governing permissions and
|
|
860
|
+
* limitations under the License.
|
|
861
|
+
*/
|
|
862
|
+
/**
|
|
863
|
+
* An image quantizer that divides the image's pixels into clusters by
|
|
864
|
+
* recursively cutting an RGB cube, based on the weight of pixels in each area
|
|
865
|
+
* of the cube.
|
|
866
|
+
*
|
|
867
|
+
* The algorithm was described by Xiaolin Wu in Graphic Gems II, published in
|
|
868
|
+
* 1991.
|
|
869
|
+
*/
|
|
870
|
+
declare class QuantizerWu {
|
|
871
|
+
private weights;
|
|
872
|
+
private momentsR;
|
|
873
|
+
private momentsG;
|
|
874
|
+
private momentsB;
|
|
875
|
+
private moments;
|
|
876
|
+
private cubes;
|
|
877
|
+
constructor(weights?: number[], momentsR?: number[], momentsG?: number[], momentsB?: number[], moments?: number[], cubes?: Box[]);
|
|
878
|
+
/**
|
|
879
|
+
* @param pixels Colors in ARGB format.
|
|
880
|
+
* @param maxColors The number of colors to divide the image into. A lower
|
|
881
|
+
* number of colors may be returned.
|
|
882
|
+
* @return Colors in ARGB format.
|
|
883
|
+
*/
|
|
884
|
+
quantize(pixels: number[], maxColors: number): number[];
|
|
885
|
+
private constructHistogram;
|
|
886
|
+
private computeMoments;
|
|
887
|
+
private createBoxes;
|
|
888
|
+
private createResult;
|
|
889
|
+
private variance;
|
|
890
|
+
private cut;
|
|
891
|
+
private maximize;
|
|
892
|
+
private volume;
|
|
893
|
+
private bottom;
|
|
894
|
+
private top;
|
|
895
|
+
private getIndex;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Keeps track of the state of each box created as the Wu quantization
|
|
899
|
+
* algorithm progresses through dividing the image's pixels as plotted in RGB.
|
|
900
|
+
*/
|
|
901
|
+
declare class Box {
|
|
902
|
+
r0: number;
|
|
903
|
+
r1: number;
|
|
904
|
+
g0: number;
|
|
905
|
+
g1: number;
|
|
906
|
+
b0: number;
|
|
907
|
+
b1: number;
|
|
908
|
+
vol: number;
|
|
909
|
+
constructor(r0?: number, r1?: number, g0?: number, g1?: number, b0?: number, b1?: number, vol?: number);
|
|
910
|
+
}
|
|
911
|
+
declare namespace index_d_exports$5 {
|
|
912
|
+
export { PointProvider, PointProviderLab, QuantizerCelebi, QuantizerMap, QuantizerWsmeans, QuantizerWu };
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* DEPRECATED. The `Scheme` class is deprecated in favor of `DynamicScheme`.
|
|
916
|
+
* Please see
|
|
917
|
+
* https://github.com/material-foundation/material-color-utilities/blob/main/dev_guide/creating_color_scheme.md
|
|
918
|
+
* for migration guidance.
|
|
919
|
+
*
|
|
920
|
+
* Represents a Material color scheme, a mapping of color roles to colors.
|
|
921
|
+
*/
|
|
922
|
+
declare class Scheme {
|
|
923
|
+
private readonly props;
|
|
924
|
+
get primary(): number;
|
|
925
|
+
get onPrimary(): number;
|
|
926
|
+
get primaryContainer(): number;
|
|
927
|
+
get onPrimaryContainer(): number;
|
|
928
|
+
get secondary(): number;
|
|
929
|
+
get onSecondary(): number;
|
|
930
|
+
get secondaryContainer(): number;
|
|
931
|
+
get onSecondaryContainer(): number;
|
|
932
|
+
get tertiary(): number;
|
|
933
|
+
get onTertiary(): number;
|
|
934
|
+
get tertiaryContainer(): number;
|
|
935
|
+
get onTertiaryContainer(): number;
|
|
936
|
+
get error(): number;
|
|
937
|
+
get onError(): number;
|
|
938
|
+
get errorContainer(): number;
|
|
939
|
+
get onErrorContainer(): number;
|
|
940
|
+
get background(): number;
|
|
941
|
+
get onBackground(): number;
|
|
942
|
+
get surface(): number;
|
|
943
|
+
get onSurface(): number;
|
|
944
|
+
get surfaceVariant(): number;
|
|
945
|
+
get onSurfaceVariant(): number;
|
|
946
|
+
get outline(): number;
|
|
947
|
+
get outlineVariant(): number;
|
|
948
|
+
get shadow(): number;
|
|
949
|
+
get scrim(): number;
|
|
950
|
+
get inverseSurface(): number;
|
|
951
|
+
get inverseOnSurface(): number;
|
|
952
|
+
get inversePrimary(): number;
|
|
953
|
+
/**
|
|
954
|
+
* @param argb ARGB representation of a color.
|
|
955
|
+
* @return Light Material color scheme, based on the color's hue.
|
|
956
|
+
*/
|
|
957
|
+
static light(argb: number): Scheme;
|
|
958
|
+
/**
|
|
959
|
+
* @param argb ARGB representation of a color.
|
|
960
|
+
* @return Dark Material color scheme, based on the color's hue.
|
|
961
|
+
*/
|
|
962
|
+
static dark(argb: number): Scheme;
|
|
963
|
+
/**
|
|
964
|
+
* @param argb ARGB representation of a color.
|
|
965
|
+
* @return Light Material content color scheme, based on the color's hue.
|
|
966
|
+
*/
|
|
967
|
+
static lightContent(argb: number): Scheme;
|
|
968
|
+
/**
|
|
969
|
+
* @param argb ARGB representation of a color.
|
|
970
|
+
* @return Dark Material content color scheme, based on the color's hue.
|
|
971
|
+
*/
|
|
972
|
+
static darkContent(argb: number): Scheme;
|
|
973
|
+
/**
|
|
974
|
+
* Light scheme from core palette
|
|
975
|
+
*/
|
|
976
|
+
static lightFromCorePalette(core: CorePalette): Scheme;
|
|
977
|
+
/**
|
|
978
|
+
* Dark scheme from core palette
|
|
979
|
+
*/
|
|
980
|
+
static darkFromCorePalette(core: CorePalette): Scheme;
|
|
981
|
+
private constructor();
|
|
982
|
+
toJSON(): {
|
|
983
|
+
primary: number;
|
|
984
|
+
onPrimary: number;
|
|
985
|
+
primaryContainer: number;
|
|
986
|
+
onPrimaryContainer: number;
|
|
987
|
+
secondary: number;
|
|
988
|
+
onSecondary: number;
|
|
989
|
+
secondaryContainer: number;
|
|
990
|
+
onSecondaryContainer: number;
|
|
991
|
+
tertiary: number;
|
|
992
|
+
onTertiary: number;
|
|
993
|
+
tertiaryContainer: number;
|
|
994
|
+
onTertiaryContainer: number;
|
|
995
|
+
error: number;
|
|
996
|
+
onError: number;
|
|
997
|
+
errorContainer: number;
|
|
998
|
+
onErrorContainer: number;
|
|
999
|
+
background: number;
|
|
1000
|
+
onBackground: number;
|
|
1001
|
+
surface: number;
|
|
1002
|
+
onSurface: number;
|
|
1003
|
+
surfaceVariant: number;
|
|
1004
|
+
onSurfaceVariant: number;
|
|
1005
|
+
outline: number;
|
|
1006
|
+
outlineVariant: number;
|
|
1007
|
+
shadow: number;
|
|
1008
|
+
scrim: number;
|
|
1009
|
+
inverseSurface: number;
|
|
1010
|
+
inverseOnSurface: number;
|
|
1011
|
+
inversePrimary: number;
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Represents an Android 12 color scheme, a mapping of color roles to colors.
|
|
1016
|
+
*/
|
|
1017
|
+
declare class SchemeAndroid {
|
|
1018
|
+
private readonly props;
|
|
1019
|
+
get colorAccentPrimary(): number;
|
|
1020
|
+
get colorAccentPrimaryVariant(): number;
|
|
1021
|
+
get colorAccentSecondary(): number;
|
|
1022
|
+
get colorAccentSecondaryVariant(): number;
|
|
1023
|
+
get colorAccentTertiary(): number;
|
|
1024
|
+
get colorAccentTertiaryVariant(): number;
|
|
1025
|
+
get textColorPrimary(): number;
|
|
1026
|
+
get textColorSecondary(): number;
|
|
1027
|
+
get textColorTertiary(): number;
|
|
1028
|
+
get textColorPrimaryInverse(): number;
|
|
1029
|
+
get textColorSecondaryInverse(): number;
|
|
1030
|
+
get textColorTertiaryInverse(): number;
|
|
1031
|
+
get colorBackground(): number;
|
|
1032
|
+
get colorBackgroundFloating(): number;
|
|
1033
|
+
get colorSurface(): number;
|
|
1034
|
+
get colorSurfaceVariant(): number;
|
|
1035
|
+
get colorSurfaceHighlight(): number;
|
|
1036
|
+
get surfaceHeader(): number;
|
|
1037
|
+
get underSurface(): number;
|
|
1038
|
+
get offState(): number;
|
|
1039
|
+
get accentSurface(): number;
|
|
1040
|
+
get textPrimaryOnAccent(): number;
|
|
1041
|
+
get textSecondaryOnAccent(): number;
|
|
1042
|
+
get volumeBackground(): number;
|
|
1043
|
+
get scrim(): number;
|
|
1044
|
+
/**
|
|
1045
|
+
* @param argb ARGB representation of a color.
|
|
1046
|
+
* @return Light Material color scheme, based on the color's hue.
|
|
1047
|
+
*/
|
|
1048
|
+
static light(argb: number): SchemeAndroid;
|
|
1049
|
+
/**
|
|
1050
|
+
* @param argb ARGB representation of a color.
|
|
1051
|
+
* @return Dark Material color scheme, based on the color's hue.
|
|
1052
|
+
*/
|
|
1053
|
+
static dark(argb: number): SchemeAndroid;
|
|
1054
|
+
/**
|
|
1055
|
+
* @param argb ARGB representation of a color.
|
|
1056
|
+
* @return Light Android color scheme, based on the color's hue.
|
|
1057
|
+
*/
|
|
1058
|
+
static lightContent(argb: number): SchemeAndroid;
|
|
1059
|
+
/**
|
|
1060
|
+
* @param argb ARGB representation of a color.
|
|
1061
|
+
* @return Dark Android color scheme, based on the color's hue.
|
|
1062
|
+
*/
|
|
1063
|
+
static darkContent(argb: number): SchemeAndroid;
|
|
1064
|
+
/**
|
|
1065
|
+
* Light scheme from core palette
|
|
1066
|
+
*/
|
|
1067
|
+
static lightFromCorePalette(core: CorePalette): SchemeAndroid;
|
|
1068
|
+
/**
|
|
1069
|
+
* Dark scheme from core palette
|
|
1070
|
+
*/
|
|
1071
|
+
static darkFromCorePalette(core: CorePalette): SchemeAndroid;
|
|
1072
|
+
private constructor();
|
|
1073
|
+
toJSON(): {
|
|
1074
|
+
colorAccentPrimary: number;
|
|
1075
|
+
colorAccentPrimaryVariant: number;
|
|
1076
|
+
colorAccentSecondary: number;
|
|
1077
|
+
colorAccentSecondaryVariant: number;
|
|
1078
|
+
colorAccentTertiary: number;
|
|
1079
|
+
colorAccentTertiaryVariant: number;
|
|
1080
|
+
textColorPrimary: number;
|
|
1081
|
+
textColorSecondary: number;
|
|
1082
|
+
textColorTertiary: number;
|
|
1083
|
+
textColorPrimaryInverse: number;
|
|
1084
|
+
textColorSecondaryInverse: number;
|
|
1085
|
+
textColorTertiaryInverse: number;
|
|
1086
|
+
colorBackground: number;
|
|
1087
|
+
colorBackgroundFloating: number;
|
|
1088
|
+
colorSurface: number;
|
|
1089
|
+
colorSurfaceVariant: number;
|
|
1090
|
+
colorSurfaceHighlight: number;
|
|
1091
|
+
surfaceHeader: number;
|
|
1092
|
+
underSurface: number;
|
|
1093
|
+
offState: number;
|
|
1094
|
+
accentSurface: number;
|
|
1095
|
+
textPrimaryOnAccent: number;
|
|
1096
|
+
textSecondaryOnAccent: number;
|
|
1097
|
+
volumeBackground: number;
|
|
1098
|
+
scrim: number;
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* @license
|
|
1103
|
+
* Copyright 2023 Google LLC
|
|
1104
|
+
*
|
|
1105
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1106
|
+
* you may not use this file except in compliance with the License.
|
|
1107
|
+
* You may obtain a copy of the License at
|
|
1108
|
+
*
|
|
1109
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1110
|
+
*
|
|
1111
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1112
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1113
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1114
|
+
* See the License for the specific language governing permissions and
|
|
1115
|
+
* limitations under the License.
|
|
1116
|
+
*/
|
|
1117
|
+
/**
|
|
1118
|
+
* A class containing a value that changes with the contrast level.
|
|
1119
|
+
*
|
|
1120
|
+
* Usually represents the contrast requirements for a dynamic color on its
|
|
1121
|
+
* background. The four values correspond to values for contrast levels -1.0,
|
|
1122
|
+
* 0.0, 0.5, and 1.0, respectively.
|
|
1123
|
+
*/
|
|
1124
|
+
declare class ContrastCurve {
|
|
1125
|
+
readonly low: number;
|
|
1126
|
+
readonly normal: number;
|
|
1127
|
+
readonly medium: number;
|
|
1128
|
+
readonly high: number;
|
|
1129
|
+
/**
|
|
1130
|
+
* Creates a `ContrastCurve` object.
|
|
1131
|
+
*
|
|
1132
|
+
* @param low Value for contrast level -1.0
|
|
1133
|
+
* @param normal Value for contrast level 0.0
|
|
1134
|
+
* @param medium Value for contrast level 0.5
|
|
1135
|
+
* @param high Value for contrast level 1.0
|
|
1136
|
+
*/
|
|
1137
|
+
constructor(low: number, normal: number, medium: number, high: number);
|
|
1138
|
+
/**
|
|
1139
|
+
* Returns the value at a given contrast level.
|
|
1140
|
+
*
|
|
1141
|
+
* @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
|
|
1142
|
+
* is the lowest; 1.0 is the highest.
|
|
1143
|
+
* @return The value. For contrast ratios, a number between 1.0 and 21.0.
|
|
1144
|
+
*/
|
|
1145
|
+
get(contrastLevel: number): number;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* DynamicColors for the colors in the Material Design system.
|
|
1149
|
+
*/
|
|
1150
|
+
declare class MaterialDynamicColors {
|
|
1151
|
+
static contentAccentToneDelta: number;
|
|
1152
|
+
private static readonly colorSpec;
|
|
1153
|
+
highestSurface(s: DynamicScheme): DynamicColor;
|
|
1154
|
+
primaryPaletteKeyColor(): DynamicColor;
|
|
1155
|
+
secondaryPaletteKeyColor(): DynamicColor;
|
|
1156
|
+
tertiaryPaletteKeyColor(): DynamicColor;
|
|
1157
|
+
neutralPaletteKeyColor(): DynamicColor;
|
|
1158
|
+
neutralVariantPaletteKeyColor(): DynamicColor;
|
|
1159
|
+
errorPaletteKeyColor(): DynamicColor;
|
|
1160
|
+
background(): DynamicColor;
|
|
1161
|
+
onBackground(): DynamicColor;
|
|
1162
|
+
surface(): DynamicColor;
|
|
1163
|
+
surfaceDim(): DynamicColor;
|
|
1164
|
+
surfaceBright(): DynamicColor;
|
|
1165
|
+
surfaceContainerLowest(): DynamicColor;
|
|
1166
|
+
surfaceContainerLow(): DynamicColor;
|
|
1167
|
+
surfaceContainer(): DynamicColor;
|
|
1168
|
+
surfaceContainerHigh(): DynamicColor;
|
|
1169
|
+
surfaceContainerHighest(): DynamicColor;
|
|
1170
|
+
onSurface(): DynamicColor;
|
|
1171
|
+
surfaceVariant(): DynamicColor;
|
|
1172
|
+
onSurfaceVariant(): DynamicColor;
|
|
1173
|
+
outline(): DynamicColor;
|
|
1174
|
+
outlineVariant(): DynamicColor;
|
|
1175
|
+
inverseSurface(): DynamicColor;
|
|
1176
|
+
inverseOnSurface(): DynamicColor;
|
|
1177
|
+
shadow(): DynamicColor;
|
|
1178
|
+
scrim(): DynamicColor;
|
|
1179
|
+
surfaceTint(): DynamicColor;
|
|
1180
|
+
primary(): DynamicColor;
|
|
1181
|
+
primaryDim(): DynamicColor | undefined;
|
|
1182
|
+
onPrimary(): DynamicColor;
|
|
1183
|
+
primaryContainer(): DynamicColor;
|
|
1184
|
+
onPrimaryContainer(): DynamicColor;
|
|
1185
|
+
inversePrimary(): DynamicColor;
|
|
1186
|
+
primaryFixed(): DynamicColor;
|
|
1187
|
+
primaryFixedDim(): DynamicColor;
|
|
1188
|
+
onPrimaryFixed(): DynamicColor;
|
|
1189
|
+
onPrimaryFixedVariant(): DynamicColor;
|
|
1190
|
+
secondary(): DynamicColor;
|
|
1191
|
+
secondaryDim(): DynamicColor | undefined;
|
|
1192
|
+
onSecondary(): DynamicColor;
|
|
1193
|
+
secondaryContainer(): DynamicColor;
|
|
1194
|
+
onSecondaryContainer(): DynamicColor;
|
|
1195
|
+
secondaryFixed(): DynamicColor;
|
|
1196
|
+
secondaryFixedDim(): DynamicColor;
|
|
1197
|
+
onSecondaryFixed(): DynamicColor;
|
|
1198
|
+
onSecondaryFixedVariant(): DynamicColor;
|
|
1199
|
+
tertiary(): DynamicColor;
|
|
1200
|
+
tertiaryDim(): DynamicColor | undefined;
|
|
1201
|
+
onTertiary(): DynamicColor;
|
|
1202
|
+
tertiaryContainer(): DynamicColor;
|
|
1203
|
+
onTertiaryContainer(): DynamicColor;
|
|
1204
|
+
tertiaryFixed(): DynamicColor;
|
|
1205
|
+
tertiaryFixedDim(): DynamicColor;
|
|
1206
|
+
onTertiaryFixed(): DynamicColor;
|
|
1207
|
+
onTertiaryFixedVariant(): DynamicColor;
|
|
1208
|
+
error(): DynamicColor;
|
|
1209
|
+
errorDim(): DynamicColor | undefined;
|
|
1210
|
+
onError(): DynamicColor;
|
|
1211
|
+
errorContainer(): DynamicColor;
|
|
1212
|
+
onErrorContainer(): DynamicColor;
|
|
1213
|
+
allColors: DynamicColor[];
|
|
1214
|
+
/** @deprecated Use highestSurface() instead. */
|
|
1215
|
+
static highestSurface(s: DynamicScheme): DynamicColor;
|
|
1216
|
+
/** @deprecated Use primaryPaletteKeyColor() instead. */
|
|
1217
|
+
static primaryPaletteKeyColor: DynamicColor;
|
|
1218
|
+
/** @deprecated Use secondaryPaletteKeyColor() instead. */
|
|
1219
|
+
static secondaryPaletteKeyColor: DynamicColor;
|
|
1220
|
+
/** @deprecated Use tertiaryPaletteKeyColor() instead. */
|
|
1221
|
+
static tertiaryPaletteKeyColor: DynamicColor;
|
|
1222
|
+
/** @deprecated Use neutralPaletteKeyColor() instead. */
|
|
1223
|
+
static neutralPaletteKeyColor: DynamicColor;
|
|
1224
|
+
/** @deprecated Use neutralVariantPaletteKeyColor() instead. */
|
|
1225
|
+
static neutralVariantPaletteKeyColor: DynamicColor;
|
|
1226
|
+
/** @deprecated Use background() instead. */
|
|
1227
|
+
static background: DynamicColor;
|
|
1228
|
+
/** @deprecated Use background() instead. */
|
|
1229
|
+
static onBackground: DynamicColor;
|
|
1230
|
+
/** @deprecated Use surface() instead. */
|
|
1231
|
+
static surface: DynamicColor;
|
|
1232
|
+
/** @deprecated Use surfaceDim() instead. */
|
|
1233
|
+
static surfaceDim: DynamicColor;
|
|
1234
|
+
/** @deprecated Use surfaceBright() instead. */
|
|
1235
|
+
static surfaceBright: DynamicColor;
|
|
1236
|
+
/** @deprecated Use surfaceContainerLowest() instead. */
|
|
1237
|
+
static surfaceContainerLowest: DynamicColor;
|
|
1238
|
+
/** @deprecated Use surfaceContainerLow() instead. */
|
|
1239
|
+
static surfaceContainerLow: DynamicColor;
|
|
1240
|
+
/** @deprecated Use surfaceContainer() instead. */
|
|
1241
|
+
static surfaceContainer: DynamicColor;
|
|
1242
|
+
/** @deprecated Use surfaceContainerHigh() instead. */
|
|
1243
|
+
static surfaceContainerHigh: DynamicColor;
|
|
1244
|
+
/** @deprecated Use surfaceContainerHighest() instead. */
|
|
1245
|
+
static surfaceContainerHighest: DynamicColor;
|
|
1246
|
+
/** @deprecated Use onSurface() instead. */
|
|
1247
|
+
static onSurface: DynamicColor;
|
|
1248
|
+
/** @deprecated Use surfaceVariant() instead. */
|
|
1249
|
+
static surfaceVariant: DynamicColor;
|
|
1250
|
+
/** @deprecated Use onSurfaceVariant() instead. */
|
|
1251
|
+
static onSurfaceVariant: DynamicColor;
|
|
1252
|
+
/** @deprecated Use inverseSurface() instead. */
|
|
1253
|
+
static inverseSurface: DynamicColor;
|
|
1254
|
+
/** @deprecated Use inverseOnSurface() instead. */
|
|
1255
|
+
static inverseOnSurface: DynamicColor;
|
|
1256
|
+
/** @deprecated Use outline() instead. */
|
|
1257
|
+
static outline: DynamicColor;
|
|
1258
|
+
/** @deprecated Use outlineVariant() instead. */
|
|
1259
|
+
static outlineVariant: DynamicColor;
|
|
1260
|
+
/** @deprecated Use shadow() instead. */
|
|
1261
|
+
static shadow: DynamicColor;
|
|
1262
|
+
/** @deprecated Use scrim() instead. */
|
|
1263
|
+
static scrim: DynamicColor;
|
|
1264
|
+
/** @deprecated Use surfaceTint() instead. */
|
|
1265
|
+
static surfaceTint: DynamicColor;
|
|
1266
|
+
/** @deprecated Use primary() instead. */
|
|
1267
|
+
static primary: DynamicColor;
|
|
1268
|
+
/** @deprecated Use onPrimary() instead. */
|
|
1269
|
+
static onPrimary: DynamicColor;
|
|
1270
|
+
/** @deprecated Use primaryContainer() instead. */
|
|
1271
|
+
static primaryContainer: DynamicColor;
|
|
1272
|
+
/** @deprecated Use onPrimaryContainer() instead. */
|
|
1273
|
+
static onPrimaryContainer: DynamicColor;
|
|
1274
|
+
/** @deprecated Use inversePrimary() instead. */
|
|
1275
|
+
static inversePrimary: DynamicColor;
|
|
1276
|
+
/** @deprecated Use secondary() instead. */
|
|
1277
|
+
static secondary: DynamicColor;
|
|
1278
|
+
/** @deprecated Use onSecondary() instead. */
|
|
1279
|
+
static onSecondary: DynamicColor;
|
|
1280
|
+
/** @deprecated Use secondaryContainer() instead. */
|
|
1281
|
+
static secondaryContainer: DynamicColor;
|
|
1282
|
+
/** @deprecated Use onSecondaryContainer() instead. */
|
|
1283
|
+
static onSecondaryContainer: DynamicColor;
|
|
1284
|
+
/** @deprecated Use tertiary() instead. */
|
|
1285
|
+
static tertiary: DynamicColor;
|
|
1286
|
+
/** @deprecated Use onTertiary() instead. */
|
|
1287
|
+
static onTertiary: DynamicColor;
|
|
1288
|
+
/** @deprecated Use tertiaryContainer() instead. */
|
|
1289
|
+
static tertiaryContainer: DynamicColor;
|
|
1290
|
+
/** @deprecated Use onTertiaryContainer() instead. */
|
|
1291
|
+
static onTertiaryContainer: DynamicColor;
|
|
1292
|
+
/** @deprecated Use error() instead. */
|
|
1293
|
+
static error: DynamicColor;
|
|
1294
|
+
/** @deprecated Use onError() instead. */
|
|
1295
|
+
static onError: DynamicColor;
|
|
1296
|
+
/** @deprecated Use errorContainer() instead. */
|
|
1297
|
+
static errorContainer: DynamicColor;
|
|
1298
|
+
/** @deprecated Use onErrorContainer() instead. */
|
|
1299
|
+
static onErrorContainer: DynamicColor;
|
|
1300
|
+
/** @deprecated Use primaryFixed() instead. */
|
|
1301
|
+
static primaryFixed: DynamicColor;
|
|
1302
|
+
/** @deprecated Use primaryFixedDim() instead. */
|
|
1303
|
+
static primaryFixedDim: DynamicColor;
|
|
1304
|
+
/** @deprecated Use onPrimaryFixed() instead. */
|
|
1305
|
+
static onPrimaryFixed: DynamicColor;
|
|
1306
|
+
/** @deprecated Use onPrimaryFixedVariant() instead. */
|
|
1307
|
+
static onPrimaryFixedVariant: DynamicColor;
|
|
1308
|
+
/** @deprecated Use secondaryFixed() instead. */
|
|
1309
|
+
static secondaryFixed: DynamicColor;
|
|
1310
|
+
/** @deprecated Use secondaryFixedDim() instead. */
|
|
1311
|
+
static secondaryFixedDim: DynamicColor;
|
|
1312
|
+
/** @deprecated Use onSecondaryFixed() instead. */
|
|
1313
|
+
static onSecondaryFixed: DynamicColor;
|
|
1314
|
+
/** @deprecated Use onSecondaryFixedVariant() instead. */
|
|
1315
|
+
static onSecondaryFixedVariant: DynamicColor;
|
|
1316
|
+
/** @deprecated Use tertiaryFixed() instead. */
|
|
1317
|
+
static tertiaryFixed: DynamicColor;
|
|
1318
|
+
/** @deprecated Use tertiaryFixedDim() instead. */
|
|
1319
|
+
static tertiaryFixedDim: DynamicColor;
|
|
1320
|
+
/** @deprecated Use onTertiaryFixed() instead. */
|
|
1321
|
+
static onTertiaryFixed: DynamicColor;
|
|
1322
|
+
/** @deprecated Use onTertiaryFixedVariant() instead. */
|
|
1323
|
+
static onTertiaryFixedVariant: DynamicColor;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* @license
|
|
1327
|
+
* Copyright 2022 Google LLC
|
|
1328
|
+
*
|
|
1329
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1330
|
+
* you may not use this file except in compliance with the License.
|
|
1331
|
+
* You may obtain a copy of the License at
|
|
1332
|
+
*
|
|
1333
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1334
|
+
*
|
|
1335
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1336
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1337
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1338
|
+
* See the License for the specific language governing permissions and
|
|
1339
|
+
* limitations under the License.
|
|
1340
|
+
*/
|
|
1341
|
+
/**
|
|
1342
|
+
* Set of themes supported by Dynamic Color.
|
|
1343
|
+
* Instantiate the corresponding subclass, ex. SchemeTonalSpot, to create
|
|
1344
|
+
* colors corresponding to the theme.
|
|
1345
|
+
*/
|
|
1346
|
+
declare enum Variant {
|
|
1347
|
+
MONOCHROME = 0,
|
|
1348
|
+
NEUTRAL = 1,
|
|
1349
|
+
TONAL_SPOT = 2,
|
|
1350
|
+
VIBRANT = 3,
|
|
1351
|
+
EXPRESSIVE = 4,
|
|
1352
|
+
FIDELITY = 5,
|
|
1353
|
+
CONTENT = 6,
|
|
1354
|
+
RAINBOW = 7,
|
|
1355
|
+
FRUIT_SALAD = 8,
|
|
1356
|
+
CMF = 9
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* The platform on which this scheme is intended to be used. Only used in the
|
|
1360
|
+
* 2025 spec.
|
|
1361
|
+
*/
|
|
1362
|
+
type Platform = 'phone' | 'watch';
|
|
1363
|
+
/**
|
|
1364
|
+
* @param sourceColorHct The primary source color of the theme as an HCT color.
|
|
1365
|
+
* @param sourceColorHcts The source colors of the theme as HCT colors.
|
|
1366
|
+
* @param variant The variant, or style, of the theme.
|
|
1367
|
+
* @param contrastLevel Value from -1 to 1. -1 represents minimum contrast, 0
|
|
1368
|
+
* represents standard (i.e. the design as spec'd), and 1 represents maximum
|
|
1369
|
+
* contrast.
|
|
1370
|
+
* @param isDark Whether the scheme is in dark mode or light mode.
|
|
1371
|
+
* @param platform The platform on which this scheme is intended to be used.
|
|
1372
|
+
* @param specVersion The version of the design spec that this scheme is based
|
|
1373
|
+
* on.
|
|
1374
|
+
* @param primaryPalette Given a tone, produces a color. Hue and chroma of the
|
|
1375
|
+
* color are specified in the design specification of the variant. Usually
|
|
1376
|
+
* colorful.
|
|
1377
|
+
* @param secondaryPalette Given a tone, produces a color. Hue and chroma of the
|
|
1378
|
+
* color are specified in the design specification of the variant. Usually
|
|
1379
|
+
* less colorful.
|
|
1380
|
+
* @param tertiaryPalette Given a tone, produces a color. Hue and chroma of the
|
|
1381
|
+
* color are specified in the design specification of the variant. Usually a
|
|
1382
|
+
* different hue from primary and colorful.
|
|
1383
|
+
* @param neutralPalette Given a tone, produces a color. Hue and chroma of the
|
|
1384
|
+
* color are specified in the design specification of the variant. Usually
|
|
1385
|
+
* not colorful at all, intended for background & surface colors.
|
|
1386
|
+
* @param neutralVariantPalette Given a tone, produces a color. Hue and chroma
|
|
1387
|
+
* of the color are specified in the design specification of the variant.
|
|
1388
|
+
* Usually not colorful, but slightly more colorful than Neutral. Intended
|
|
1389
|
+
* for backgrounds & surfaces.
|
|
1390
|
+
* @param errorPalette Given a tone, produces a reddish, colorful, color.
|
|
1391
|
+
*/
|
|
1392
|
+
interface DynamicSchemeOptions {
|
|
1393
|
+
sourceColorHct?: Hct;
|
|
1394
|
+
sourceColorHcts?: Hct[];
|
|
1395
|
+
variant: Variant;
|
|
1396
|
+
contrastLevel: number;
|
|
1397
|
+
isDark: boolean;
|
|
1398
|
+
platform?: Platform;
|
|
1399
|
+
specVersion?: SpecVersion;
|
|
1400
|
+
primaryPalette?: TonalPalette;
|
|
1401
|
+
secondaryPalette?: TonalPalette;
|
|
1402
|
+
tertiaryPalette?: TonalPalette;
|
|
1403
|
+
neutralPalette?: TonalPalette;
|
|
1404
|
+
neutralVariantPalette?: TonalPalette;
|
|
1405
|
+
errorPalette?: TonalPalette;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Constructed by a set of values representing the current UI state (such as
|
|
1409
|
+
* whether or not its dark theme, what the theme style is, etc.), and
|
|
1410
|
+
* provides a set of TonalPalettes that can create colors that fit in
|
|
1411
|
+
* with the theme style. Used by DynamicColor to resolve into a color.
|
|
1412
|
+
*/
|
|
1413
|
+
declare class DynamicScheme {
|
|
1414
|
+
static readonly DEFAULT_SPEC_VERSION = "2021";
|
|
1415
|
+
static readonly DEFAULT_PLATFORM = "phone";
|
|
1416
|
+
/**
|
|
1417
|
+
* The source color of the theme as an HCT color.
|
|
1418
|
+
*/
|
|
1419
|
+
sourceColorHct: Hct;
|
|
1420
|
+
/**
|
|
1421
|
+
* The source colors of the theme as HCT colors.
|
|
1422
|
+
*
|
|
1423
|
+
* If provided, `sourceColorHct` will be the first color in this list. Any
|
|
1424
|
+
* other colors will be used to generate multicolored palettes.
|
|
1425
|
+
*
|
|
1426
|
+
* If not provided, `sourceColorHcts` will be a list containing only
|
|
1427
|
+
* `sourceColorHct`.
|
|
1428
|
+
*/
|
|
1429
|
+
sourceColorHcts: Hct[];
|
|
1430
|
+
/** The source color of the theme as an ARGB 32-bit integer. */
|
|
1431
|
+
readonly sourceColorArgb: number;
|
|
1432
|
+
/** The variant, or style, of the theme. */
|
|
1433
|
+
readonly variant: Variant;
|
|
1434
|
+
/**
|
|
1435
|
+
* Value from -1 to 1. -1 represents minimum contrast. 0 represents standard
|
|
1436
|
+
* (i.e. the design as spec'd), and 1 represents maximum contrast.
|
|
1437
|
+
*/
|
|
1438
|
+
readonly contrastLevel: number;
|
|
1439
|
+
/** Whether the scheme is in dark mode or light mode. */
|
|
1440
|
+
readonly isDark: boolean;
|
|
1441
|
+
/** The platform on which this scheme is intended to be used. */
|
|
1442
|
+
readonly platform: Platform;
|
|
1443
|
+
/** The version of the design spec that this scheme is based on. */
|
|
1444
|
+
readonly specVersion: SpecVersion;
|
|
1445
|
+
/**
|
|
1446
|
+
* Given a tone, produces a color. Hue and chroma of the
|
|
1447
|
+
* color are specified in the design specification of the variant. Usually
|
|
1448
|
+
* colorful.
|
|
1449
|
+
*/
|
|
1450
|
+
readonly primaryPalette: TonalPalette;
|
|
1451
|
+
/**
|
|
1452
|
+
* Given a tone, produces a color. Hue and chroma of
|
|
1453
|
+
* the color are specified in the design specification of the variant. Usually
|
|
1454
|
+
* less colorful.
|
|
1455
|
+
*/
|
|
1456
|
+
readonly secondaryPalette: TonalPalette;
|
|
1457
|
+
/**
|
|
1458
|
+
* Given a tone, produces a color. Hue and chroma of
|
|
1459
|
+
* the color are specified in the design specification of the variant. Usually
|
|
1460
|
+
* a different hue from primary and colorful.
|
|
1461
|
+
*/
|
|
1462
|
+
readonly tertiaryPalette: TonalPalette;
|
|
1463
|
+
/**
|
|
1464
|
+
* Given a tone, produces a color. Hue and chroma of the
|
|
1465
|
+
* color are specified in the design specification of the variant. Usually not
|
|
1466
|
+
* colorful at all, intended for background & surface colors.
|
|
1467
|
+
*/
|
|
1468
|
+
readonly neutralPalette: TonalPalette;
|
|
1469
|
+
/**
|
|
1470
|
+
* Given a tone, produces a color. Hue and chroma
|
|
1471
|
+
* of the color are specified in the design specification of the variant.
|
|
1472
|
+
* Usually not colorful, but slightly more colorful than Neutral. Intended for
|
|
1473
|
+
* backgrounds & surfaces.
|
|
1474
|
+
*/
|
|
1475
|
+
readonly neutralVariantPalette: TonalPalette;
|
|
1476
|
+
/**
|
|
1477
|
+
* Given a tone, produces a reddish, colorful, color.
|
|
1478
|
+
*/
|
|
1479
|
+
errorPalette: TonalPalette;
|
|
1480
|
+
readonly colors: MaterialDynamicColors;
|
|
1481
|
+
private static maybeFallbackSpecVersion;
|
|
1482
|
+
constructor(args: DynamicSchemeOptions);
|
|
1483
|
+
toString(): string;
|
|
1484
|
+
/**
|
|
1485
|
+
* Returns a new hue based on a piecewise function and input color hue.
|
|
1486
|
+
*
|
|
1487
|
+
* For example, for the following function:
|
|
1488
|
+
* result = 26 if 0 <= hue < 101
|
|
1489
|
+
* result = 39 if 101 <= hue < 210
|
|
1490
|
+
* result = 28 if 210 <= hue < 360
|
|
1491
|
+
*
|
|
1492
|
+
* call the function as:
|
|
1493
|
+
*
|
|
1494
|
+
* const hueBreakpoints = [0, 101, 210, 360];
|
|
1495
|
+
* const hues = [26, 39, 28];
|
|
1496
|
+
* const result = scheme.piecewise(hue, hueBreakpoints, hues);
|
|
1497
|
+
*
|
|
1498
|
+
* @param sourceColorHct The input value.
|
|
1499
|
+
* @param hueBreakpoints The breakpoints, in sorted order. No default lower or
|
|
1500
|
+
* upper bounds are assumed.
|
|
1501
|
+
* @param hues The hues that should be applied when source color's hue is >=
|
|
1502
|
+
* the same index in hueBrakpoints array, and < the hue at the next index
|
|
1503
|
+
* in hueBrakpoints array. Otherwise, the source color's hue is returned.
|
|
1504
|
+
*/
|
|
1505
|
+
static getPiecewiseHue(sourceColorHct: Hct, hueBreakpoints: number[], hues: number[]): number;
|
|
1506
|
+
/**
|
|
1507
|
+
* Returns a shifted hue based on a piecewise function and input color hue.
|
|
1508
|
+
*
|
|
1509
|
+
* For example, for the following function:
|
|
1510
|
+
* result = hue + 26 if 0 <= hue < 101
|
|
1511
|
+
* result = hue - 39 if 101 <= hue < 210
|
|
1512
|
+
* result = hue + 28 if 210 <= hue < 360
|
|
1513
|
+
*
|
|
1514
|
+
* call the function as:
|
|
1515
|
+
*
|
|
1516
|
+
* const hueBreakpoints = [0, 101, 210, 360];
|
|
1517
|
+
* const hues = [26, -39, 28];
|
|
1518
|
+
* const result = scheme.getRotatedHue(hue, hueBreakpoints, hues);
|
|
1519
|
+
*
|
|
1520
|
+
* @param sourceColorHct the source color of the theme, in HCT.
|
|
1521
|
+
* @param hueBreakpoints The "breakpoints", i.e. the hues at which a rotation
|
|
1522
|
+
* should be apply. No default lower or upper bounds are assumed.
|
|
1523
|
+
* @param rotations The rotation that should be applied when source color's
|
|
1524
|
+
* hue is >= the same index in hues array, and < the hue at the next
|
|
1525
|
+
* index in hues array. Otherwise, the source color's hue is returned.
|
|
1526
|
+
*/
|
|
1527
|
+
static getRotatedHue(sourceColorHct: Hct, hueBreakpoints: number[], rotations: number[]): number;
|
|
1528
|
+
getArgb(dynamicColor: DynamicColor): number;
|
|
1529
|
+
getHct(dynamicColor: DynamicColor): Hct;
|
|
1530
|
+
get primaryPaletteKeyColor(): number;
|
|
1531
|
+
get secondaryPaletteKeyColor(): number;
|
|
1532
|
+
get tertiaryPaletteKeyColor(): number;
|
|
1533
|
+
get neutralPaletteKeyColor(): number;
|
|
1534
|
+
get neutralVariantPaletteKeyColor(): number;
|
|
1535
|
+
get errorPaletteKeyColor(): number;
|
|
1536
|
+
get background(): number;
|
|
1537
|
+
get onBackground(): number;
|
|
1538
|
+
get surface(): number;
|
|
1539
|
+
get surfaceDim(): number;
|
|
1540
|
+
get surfaceBright(): number;
|
|
1541
|
+
get surfaceContainerLowest(): number;
|
|
1542
|
+
get surfaceContainerLow(): number;
|
|
1543
|
+
get surfaceContainer(): number;
|
|
1544
|
+
get surfaceContainerHigh(): number;
|
|
1545
|
+
get surfaceContainerHighest(): number;
|
|
1546
|
+
get onSurface(): number;
|
|
1547
|
+
get surfaceVariant(): number;
|
|
1548
|
+
get onSurfaceVariant(): number;
|
|
1549
|
+
get inverseSurface(): number;
|
|
1550
|
+
get inverseOnSurface(): number;
|
|
1551
|
+
get outline(): number;
|
|
1552
|
+
get outlineVariant(): number;
|
|
1553
|
+
get shadow(): number;
|
|
1554
|
+
get scrim(): number;
|
|
1555
|
+
get surfaceTint(): number;
|
|
1556
|
+
get primary(): number;
|
|
1557
|
+
get primaryDim(): number;
|
|
1558
|
+
get onPrimary(): number;
|
|
1559
|
+
get primaryContainer(): number;
|
|
1560
|
+
get onPrimaryContainer(): number;
|
|
1561
|
+
get primaryFixed(): number;
|
|
1562
|
+
get primaryFixedDim(): number;
|
|
1563
|
+
get onPrimaryFixed(): number;
|
|
1564
|
+
get onPrimaryFixedVariant(): number;
|
|
1565
|
+
get inversePrimary(): number;
|
|
1566
|
+
get secondary(): number;
|
|
1567
|
+
get secondaryDim(): number;
|
|
1568
|
+
get onSecondary(): number;
|
|
1569
|
+
get secondaryContainer(): number;
|
|
1570
|
+
get onSecondaryContainer(): number;
|
|
1571
|
+
get secondaryFixed(): number;
|
|
1572
|
+
get secondaryFixedDim(): number;
|
|
1573
|
+
get onSecondaryFixed(): number;
|
|
1574
|
+
get onSecondaryFixedVariant(): number;
|
|
1575
|
+
get tertiary(): number;
|
|
1576
|
+
get tertiaryDim(): number;
|
|
1577
|
+
get onTertiary(): number;
|
|
1578
|
+
get tertiaryContainer(): number;
|
|
1579
|
+
get onTertiaryContainer(): number;
|
|
1580
|
+
get tertiaryFixed(): number;
|
|
1581
|
+
get tertiaryFixedDim(): number;
|
|
1582
|
+
get onTertiaryFixed(): number;
|
|
1583
|
+
get onTertiaryFixedVariant(): number;
|
|
1584
|
+
get error(): number;
|
|
1585
|
+
get errorDim(): number;
|
|
1586
|
+
get onError(): number;
|
|
1587
|
+
get errorContainer(): number;
|
|
1588
|
+
get onErrorContainer(): number;
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Describes the different in tone between colors.
|
|
1592
|
+
*
|
|
1593
|
+
* nearer and farther are deprecated. Use DeltaConstraint instead.
|
|
1594
|
+
*/
|
|
1595
|
+
type TonePolarity = 'darker' | 'lighter' | 'nearer' | 'farther' | 'relative_darker' | 'relative_lighter';
|
|
1596
|
+
/**
|
|
1597
|
+
* Describes how to fulfill a tone delta pair constraint.
|
|
1598
|
+
*/
|
|
1599
|
+
type DeltaConstraint = 'exact' | 'nearer' | 'farther';
|
|
1600
|
+
/**
|
|
1601
|
+
* Documents a constraint between two DynamicColors, in which their tones must
|
|
1602
|
+
* have a certain distance from each other.
|
|
1603
|
+
*
|
|
1604
|
+
* Prefer a DynamicColor with a background, this is for special cases when
|
|
1605
|
+
* designers want tonal distance, literally contrast, between two colors that
|
|
1606
|
+
* don't have a background / foreground relationship or a contrast guarantee.
|
|
1607
|
+
*/
|
|
1608
|
+
declare class ToneDeltaPair {
|
|
1609
|
+
readonly roleA: DynamicColor;
|
|
1610
|
+
readonly roleB: DynamicColor;
|
|
1611
|
+
readonly delta: number;
|
|
1612
|
+
readonly polarity: TonePolarity;
|
|
1613
|
+
readonly stayTogether: boolean;
|
|
1614
|
+
readonly constraint?: DeltaConstraint | undefined;
|
|
1615
|
+
/**
|
|
1616
|
+
* Documents a constraint in tone distance between two DynamicColors.
|
|
1617
|
+
*
|
|
1618
|
+
* The polarity is an adjective that describes "A", compared to "B".
|
|
1619
|
+
*
|
|
1620
|
+
* For instance, ToneDeltaPair(A, B, 15, 'darker', 'exact') states that
|
|
1621
|
+
* A's tone should be exactly 15 darker than B's.
|
|
1622
|
+
*
|
|
1623
|
+
* 'relative_darker' and 'relative_lighter' describes the tone adjustment
|
|
1624
|
+
* relative to the surface color trend (white in light mode; black in dark
|
|
1625
|
+
* mode). For instance, ToneDeltaPair(A, B, 10, 'relative_lighter',
|
|
1626
|
+
* 'farther') states that A should be at least 10 lighter than B in light
|
|
1627
|
+
* mode, and at least 10 darker than B in dark mode.
|
|
1628
|
+
*
|
|
1629
|
+
* @param roleA The first role in a pair.
|
|
1630
|
+
* @param roleB The second role in a pair.
|
|
1631
|
+
* @param delta Required difference between tones. Absolute value, negative
|
|
1632
|
+
* values have undefined behavior.
|
|
1633
|
+
* @param polarity The relative relation between tones of roleA and roleB,
|
|
1634
|
+
* as described above.
|
|
1635
|
+
* @param constraint How to fulfill the tone delta pair constraint.
|
|
1636
|
+
* @param stayTogether Whether these two roles should stay on the same side
|
|
1637
|
+
* of the "awkward zone" (T50-59). This is necessary for certain cases where
|
|
1638
|
+
* one role has two backgrounds.
|
|
1639
|
+
*/
|
|
1640
|
+
constructor(roleA: DynamicColor, roleB: DynamicColor, delta: number, polarity: TonePolarity, stayTogether: boolean, constraint?: DeltaConstraint | undefined);
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* @param name The name of the dynamic color. Defaults to empty.
|
|
1644
|
+
* @param palette Function that provides a TonalPalette given DynamicScheme. A
|
|
1645
|
+
* TonalPalette is defined by a hue and chroma, so this replaces the need to
|
|
1646
|
+
* specify hue/chroma. By providing a tonal palette, when contrast
|
|
1647
|
+
* adjustments are made, intended chroma can be preserved.
|
|
1648
|
+
* @param tone Function that provides a tone given DynamicScheme. When not
|
|
1649
|
+
* provided, the tone is same as the background tone or 50, when no
|
|
1650
|
+
* background is provided.
|
|
1651
|
+
* @param chromaMultiplier A factor that multiplies the chroma for this color.
|
|
1652
|
+
* Default to 1.
|
|
1653
|
+
* @param isBackground Whether this dynamic color is a background, with some
|
|
1654
|
+
* other color as the foreground. Defaults to false.
|
|
1655
|
+
* @param background The background of the dynamic color (as a function of a
|
|
1656
|
+
* `DynamicScheme`), if it exists.
|
|
1657
|
+
* @param secondBackground A second background of the dynamic color (as a
|
|
1658
|
+
* function of a `DynamicScheme`), if it exists.
|
|
1659
|
+
* @param contrastCurve A `ContrastCurve` object specifying how its contrast
|
|
1660
|
+
* against its background should behave in various contrast levels options.
|
|
1661
|
+
* Must used together with `background`. When not provided or resolved as
|
|
1662
|
+
* undefined, the contrast curve is calculated based on other constraints.
|
|
1663
|
+
* @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
|
|
1664
|
+
* constraint between two colors. One of them must be the color being
|
|
1665
|
+
* constructed. When not provided or resolved as undefined, the tone is
|
|
1666
|
+
* calculated based on other constraints.
|
|
1667
|
+
*/
|
|
1668
|
+
interface FromPaletteOptions {
|
|
1669
|
+
name?: string;
|
|
1670
|
+
palette: (scheme: DynamicScheme) => TonalPalette;
|
|
1671
|
+
tone?: (scheme: DynamicScheme) => number;
|
|
1672
|
+
chromaMultiplier?: (scheme: DynamicScheme) => number;
|
|
1673
|
+
isBackground?: boolean;
|
|
1674
|
+
background?: (scheme: DynamicScheme) => DynamicColor | undefined;
|
|
1675
|
+
secondBackground?: (scheme: DynamicScheme) => DynamicColor | undefined;
|
|
1676
|
+
contrastCurve?: (scheme: DynamicScheme) => ContrastCurve | undefined;
|
|
1677
|
+
toneDeltaPair?: (scheme: DynamicScheme) => ToneDeltaPair | undefined;
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* A color that adjusts itself based on UI state provided by DynamicScheme.
|
|
1681
|
+
*
|
|
1682
|
+
* Colors without backgrounds do not change tone when contrast changes. Colors
|
|
1683
|
+
* with backgrounds become closer to their background as contrast lowers, and
|
|
1684
|
+
* further when contrast increases.
|
|
1685
|
+
*
|
|
1686
|
+
* Prefer static constructors. They require either a hexcode, a palette and
|
|
1687
|
+
* tone, or a hue and chroma. Optionally, they can provide a background
|
|
1688
|
+
* DynamicColor.
|
|
1689
|
+
*/
|
|
1690
|
+
declare class DynamicColor {
|
|
1691
|
+
readonly name: string;
|
|
1692
|
+
readonly palette: (scheme: DynamicScheme) => TonalPalette;
|
|
1693
|
+
readonly tone: (scheme: DynamicScheme) => number;
|
|
1694
|
+
readonly isBackground: boolean;
|
|
1695
|
+
readonly chromaMultiplier?: ((scheme: DynamicScheme) => number) | undefined;
|
|
1696
|
+
readonly background?: ((scheme: DynamicScheme) => DynamicColor | undefined) | undefined;
|
|
1697
|
+
readonly secondBackground?: ((scheme: DynamicScheme) => DynamicColor | undefined) | undefined;
|
|
1698
|
+
readonly contrastCurve?: ((scheme: DynamicScheme) => ContrastCurve | undefined) | undefined;
|
|
1699
|
+
readonly toneDeltaPair?: ((scheme: DynamicScheme) => ToneDeltaPair | undefined) | undefined;
|
|
1700
|
+
private readonly hctCache;
|
|
1701
|
+
/**
|
|
1702
|
+
* Create a DynamicColor defined by a TonalPalette and HCT tone.
|
|
1703
|
+
*
|
|
1704
|
+
* @param args Functions with DynamicScheme as input. Must provide a palette
|
|
1705
|
+
* and tone. May provide a background DynamicColor and ToneDeltaPair.
|
|
1706
|
+
*/
|
|
1707
|
+
static fromPalette(args: FromPaletteOptions): DynamicColor;
|
|
1708
|
+
static getInitialToneFromBackground(background?: (scheme: DynamicScheme) => DynamicColor | undefined): (scheme: DynamicScheme) => number;
|
|
1709
|
+
/**
|
|
1710
|
+
* The base constructor for DynamicColor.
|
|
1711
|
+
*
|
|
1712
|
+
* _Strongly_ prefer using one of the convenience constructors. This class is
|
|
1713
|
+
* arguably too flexible to ensure it can support any scenario. Functional
|
|
1714
|
+
* arguments allow overriding without risks that come with subclasses.
|
|
1715
|
+
*
|
|
1716
|
+
* For example, the default behavior of adjust tone at max contrast
|
|
1717
|
+
* to be at a 7.0 ratio with its background is principled and
|
|
1718
|
+
* matches accessibility guidance. That does not mean it's the desired
|
|
1719
|
+
* approach for _every_ design system, and every color pairing,
|
|
1720
|
+
* always, in every case.
|
|
1721
|
+
*
|
|
1722
|
+
* @param name The name of the dynamic color. Defaults to empty.
|
|
1723
|
+
* @param palette Function that provides a TonalPalette given DynamicScheme. A
|
|
1724
|
+
* TonalPalette is defined by a hue and chroma, so this replaces the need
|
|
1725
|
+
* to specify hue/chroma. By providing a tonal palette, when contrast
|
|
1726
|
+
* adjustments are made, intended chroma can be preserved.
|
|
1727
|
+
* @param tone Function that provides a tone, given a DynamicScheme.
|
|
1728
|
+
* @param isBackground Whether this dynamic color is a background, with some
|
|
1729
|
+
* other color as the foreground. Defaults to false.
|
|
1730
|
+
* @param chromaMultiplier A factor that multiplies the chroma for this color.
|
|
1731
|
+
* @param background The background of the dynamic color (as a function of a
|
|
1732
|
+
* `DynamicScheme`), if it exists.
|
|
1733
|
+
* @param secondBackground A second background of the dynamic color (as a
|
|
1734
|
+
* function of a `DynamicScheme`), if it exists.
|
|
1735
|
+
* @param contrastCurve A `ContrastCurve` object specifying how its contrast
|
|
1736
|
+
* against its background should behave in various contrast levels
|
|
1737
|
+
* options.
|
|
1738
|
+
* @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
|
|
1739
|
+
* constraint between two colors. One of them must be the color being
|
|
1740
|
+
* constructed.
|
|
1741
|
+
*/
|
|
1742
|
+
constructor(name: string, palette: (scheme: DynamicScheme) => TonalPalette, tone: (scheme: DynamicScheme) => number, isBackground: boolean, chromaMultiplier?: ((scheme: DynamicScheme) => number) | undefined, background?: ((scheme: DynamicScheme) => DynamicColor | undefined) | undefined, secondBackground?: ((scheme: DynamicScheme) => DynamicColor | undefined) | undefined, contrastCurve?: ((scheme: DynamicScheme) => ContrastCurve | undefined) | undefined, toneDeltaPair?: ((scheme: DynamicScheme) => ToneDeltaPair | undefined) | undefined);
|
|
1743
|
+
/**
|
|
1744
|
+
* Returns a deep copy of this DynamicColor.
|
|
1745
|
+
*/
|
|
1746
|
+
clone(): DynamicColor;
|
|
1747
|
+
/**
|
|
1748
|
+
* Clears the cache of HCT values for this color. For testing or debugging
|
|
1749
|
+
* purposes.
|
|
1750
|
+
*/
|
|
1751
|
+
clearCache(): void;
|
|
1752
|
+
/**
|
|
1753
|
+
* Returns a ARGB integer (i.e. a hex code).
|
|
1754
|
+
*
|
|
1755
|
+
* @param scheme Defines the conditions of the user interface, for example,
|
|
1756
|
+
* whether or not it is dark mode or light mode, and what the desired
|
|
1757
|
+
* contrast level is.
|
|
1758
|
+
*/
|
|
1759
|
+
getArgb(scheme: DynamicScheme): number;
|
|
1760
|
+
/**
|
|
1761
|
+
* Returns a color, expressed in the HCT color space, that this
|
|
1762
|
+
* DynamicColor is under the conditions in scheme.
|
|
1763
|
+
*
|
|
1764
|
+
* @param scheme Defines the conditions of the user interface, for example,
|
|
1765
|
+
* whether or not it is dark mode or light mode, and what the desired
|
|
1766
|
+
* contrast level is.
|
|
1767
|
+
*/
|
|
1768
|
+
getHct(scheme: DynamicScheme): Hct;
|
|
1769
|
+
/**
|
|
1770
|
+
* Returns a tone, T in the HCT color space, that this DynamicColor is under
|
|
1771
|
+
* the conditions in scheme.
|
|
1772
|
+
*
|
|
1773
|
+
* @param scheme Defines the conditions of the user interface, for example,
|
|
1774
|
+
* whether or not it is dark mode or light mode, and what the desired
|
|
1775
|
+
* contrast level is.
|
|
1776
|
+
*/
|
|
1777
|
+
getTone(scheme: DynamicScheme): number;
|
|
1778
|
+
/**
|
|
1779
|
+
* Given a background tone, finds a foreground tone, while ensuring they reach
|
|
1780
|
+
* a contrast ratio that is as close to [ratio] as possible.
|
|
1781
|
+
*
|
|
1782
|
+
* @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
|
|
1783
|
+
* falls outside that range.
|
|
1784
|
+
* @param ratio The contrast ratio desired between bgTone and the return
|
|
1785
|
+
* value.
|
|
1786
|
+
*/
|
|
1787
|
+
static foregroundTone(bgTone: number, ratio: number): number;
|
|
1788
|
+
/**
|
|
1789
|
+
* Returns whether [tone] prefers a light foreground.
|
|
1790
|
+
*
|
|
1791
|
+
* People prefer white foregrounds on ~T60-70. Observed over time, and also
|
|
1792
|
+
* by Andrew Somers during research for APCA.
|
|
1793
|
+
*
|
|
1794
|
+
* T60 used as to create the smallest discontinuity possible when skipping
|
|
1795
|
+
* down to T49 in order to ensure light foregrounds.
|
|
1796
|
+
* Since `tertiaryContainer` in dark monochrome scheme requires a tone of
|
|
1797
|
+
* 60, it should not be adjusted. Therefore, 60 is excluded here.
|
|
1798
|
+
*/
|
|
1799
|
+
static tonePrefersLightForeground(tone: number): boolean;
|
|
1800
|
+
/**
|
|
1801
|
+
* Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
|
|
1802
|
+
* color.
|
|
1803
|
+
*/
|
|
1804
|
+
static toneAllowsLightForeground(tone: number): boolean;
|
|
1805
|
+
/**
|
|
1806
|
+
* Adjusts a tone such that white has 4.5 contrast, if the tone is
|
|
1807
|
+
* reasonably close to supporting it.
|
|
1808
|
+
*/
|
|
1809
|
+
static enableLightForeground(tone: number): number;
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* The version of the material color spec to use.
|
|
1813
|
+
*/
|
|
1814
|
+
type SpecVersion = '2021' | '2025' | '2026';
|
|
1815
|
+
/**
|
|
1816
|
+
* A Dynamic Color theme with 2 source colors.
|
|
1817
|
+
*/
|
|
1818
|
+
declare class SchemeCmf extends DynamicScheme {
|
|
1819
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1820
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1821
|
+
static getErrorHue(primaryHue: number, tertiaryHue: number): number;
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* A scheme that places the source color in `Scheme.primaryContainer`.
|
|
1825
|
+
*
|
|
1826
|
+
* Primary Container is the source color, adjusted for color relativity.
|
|
1827
|
+
* It maintains constant appearance in light mode and dark mode.
|
|
1828
|
+
* This adds ~5 tone in light mode, and subtracts ~5 tone in dark mode.
|
|
1829
|
+
* Tertiary Container is the complement to the source color, using
|
|
1830
|
+
* `TemperatureCache`. It also maintains constant appearance.
|
|
1831
|
+
*/
|
|
1832
|
+
declare class SchemeContent extends DynamicScheme {
|
|
1833
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1834
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* A Dynamic Color theme that is intentionally detached from the source color.
|
|
1838
|
+
*/
|
|
1839
|
+
declare class SchemeExpressive extends DynamicScheme {
|
|
1840
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1841
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* A scheme that places the source color in `Scheme.primaryContainer`.
|
|
1845
|
+
*
|
|
1846
|
+
* Primary Container is the source color, adjusted for color relativity.
|
|
1847
|
+
* It maintains constant appearance in light mode and dark mode.
|
|
1848
|
+
* This adds ~5 tone in light mode, and subtracts ~5 tone in dark mode.
|
|
1849
|
+
* Tertiary Container is the complement to the source color, using
|
|
1850
|
+
* `TemperatureCache`. It also maintains constant appearance.
|
|
1851
|
+
*/
|
|
1852
|
+
declare class SchemeFidelity extends DynamicScheme {
|
|
1853
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1854
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* A playful theme - the source color's hue does not appear in the theme.
|
|
1858
|
+
*/
|
|
1859
|
+
declare class SchemeFruitSalad extends DynamicScheme {
|
|
1860
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1861
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1862
|
+
}
|
|
1863
|
+
/** A Dynamic Color theme that is grayscale. */
|
|
1864
|
+
declare class SchemeMonochrome extends DynamicScheme {
|
|
1865
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1866
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1867
|
+
}
|
|
1868
|
+
/** A Dynamic Color theme that is near grayscale. */
|
|
1869
|
+
declare class SchemeNeutral extends DynamicScheme {
|
|
1870
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1871
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* A playful theme - the source color's hue does not appear in the theme.
|
|
1875
|
+
*/
|
|
1876
|
+
declare class SchemeRainbow extends DynamicScheme {
|
|
1877
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1878
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* A Dynamic Color theme with low to medium colorfulness and a Tertiary
|
|
1882
|
+
* TonalPalette with a hue related to the source color.
|
|
1883
|
+
*
|
|
1884
|
+
* The default Material You theme on Android 12 and 13.
|
|
1885
|
+
*/
|
|
1886
|
+
declare class SchemeTonalSpot extends DynamicScheme {
|
|
1887
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1888
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* A Dynamic Color theme that maxes out colorfulness at each position in the
|
|
1892
|
+
* Primary Tonal Palette.
|
|
1893
|
+
*/
|
|
1894
|
+
declare class SchemeVibrant extends DynamicScheme {
|
|
1895
|
+
constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1896
|
+
constructor(sourceColorHcts: Hct[], isDark: boolean, contrastLevel: number, specVersion?: SpecVersion, platform?: Platform);
|
|
1897
|
+
}
|
|
1898
|
+
declare namespace index_d_exports$6 {
|
|
1899
|
+
export { Scheme, SchemeAndroid, SchemeCmf, SchemeContent, SchemeExpressive, SchemeFidelity, SchemeFruitSalad, SchemeMonochrome, SchemeNeutral, SchemeRainbow, SchemeTonalSpot, SchemeVibrant };
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* @license
|
|
1903
|
+
* Copyright 2021 Google LLC
|
|
1904
|
+
*
|
|
1905
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1906
|
+
* you may not use this file except in compliance with the License.
|
|
1907
|
+
* You may obtain a copy of the License at
|
|
1908
|
+
*
|
|
1909
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1910
|
+
*
|
|
1911
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1912
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1913
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1914
|
+
* See the License for the specific language governing permissions and
|
|
1915
|
+
* limitations under the License.
|
|
1916
|
+
*/
|
|
1917
|
+
/**
|
|
1918
|
+
* Default options for ranking colors based on usage counts.
|
|
1919
|
+
* desired: is the max count of the colors returned.
|
|
1920
|
+
* fallbackColorARGB: Is the default color that should be used if no
|
|
1921
|
+
* other colors are suitable.
|
|
1922
|
+
* filter: controls if the resulting colors should be filtered to not include
|
|
1923
|
+
* hues that are not used often enough, and colors that are effectively
|
|
1924
|
+
* grayscale.
|
|
1925
|
+
*/
|
|
1926
|
+
declare interface ScoreOptions {
|
|
1927
|
+
desired?: number;
|
|
1928
|
+
fallbackColorARGB?: number;
|
|
1929
|
+
filter?: boolean;
|
|
1930
|
+
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Given a large set of colors, remove colors that are unsuitable for a UI
|
|
1933
|
+
* theme, and rank the rest based on suitability.
|
|
1934
|
+
*
|
|
1935
|
+
* Enables use of a high cluster count for image quantization, thus ensuring
|
|
1936
|
+
* colors aren't muddied, while curating the high cluster count to a much
|
|
1937
|
+
* smaller number of appropriate choices.
|
|
1938
|
+
*/
|
|
1939
|
+
declare class Score {
|
|
1940
|
+
private static readonly TARGET_CHROMA;
|
|
1941
|
+
private static readonly WEIGHT_PROPORTION;
|
|
1942
|
+
private static readonly WEIGHT_CHROMA_ABOVE;
|
|
1943
|
+
private static readonly WEIGHT_CHROMA_BELOW;
|
|
1944
|
+
private static readonly CUTOFF_CHROMA;
|
|
1945
|
+
private static readonly CUTOFF_EXCITED_PROPORTION;
|
|
1946
|
+
private constructor();
|
|
1947
|
+
/**
|
|
1948
|
+
* Given a map with keys of colors and values of how often the color appears,
|
|
1949
|
+
* rank the colors based on suitability for being used for a UI theme.
|
|
1950
|
+
*
|
|
1951
|
+
* @param colorsToPopulation map with keys of colors and values of how often
|
|
1952
|
+
* the color appears, usually from a source image.
|
|
1953
|
+
* @param {ScoreOptions} options optional parameters.
|
|
1954
|
+
* @return Colors sorted by suitability for a UI theme. The most suitable
|
|
1955
|
+
* color is the first item, the least suitable is the last. There will
|
|
1956
|
+
* always be at least one color returned. If all the input colors
|
|
1957
|
+
* were not suitable for a theme, a default fallback color will be
|
|
1958
|
+
* provided, Google Blue.
|
|
1959
|
+
*/
|
|
1960
|
+
static score(colorsToPopulation: Map<number, number>, options?: ScoreOptions): number[];
|
|
1961
|
+
}
|
|
1962
|
+
declare namespace index_d_exports$7 {
|
|
1963
|
+
export { Score };
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Design utilities using color temperature theory.
|
|
1967
|
+
*
|
|
1968
|
+
* Analogous colors, complementary color, and cache to efficiently, lazily,
|
|
1969
|
+
* generate data for calculations when needed.
|
|
1970
|
+
*/
|
|
1971
|
+
declare class TemperatureCache {
|
|
1972
|
+
input: Hct;
|
|
1973
|
+
constructor(input: Hct);
|
|
1974
|
+
hctsByTempCache: Hct[];
|
|
1975
|
+
hctsByHueCache: Hct[];
|
|
1976
|
+
tempsByHctCache: Map<Hct, number>;
|
|
1977
|
+
inputRelativeTemperatureCache: number;
|
|
1978
|
+
complementCache: Hct | null;
|
|
1979
|
+
get hctsByTemp(): Hct[];
|
|
1980
|
+
get warmest(): Hct;
|
|
1981
|
+
get coldest(): Hct;
|
|
1982
|
+
/**
|
|
1983
|
+
* A set of colors with differing hues, equidistant in temperature.
|
|
1984
|
+
*
|
|
1985
|
+
* In art, this is usually described as a set of 5 colors on a color wheel
|
|
1986
|
+
* divided into 12 sections. This method allows provision of either of those
|
|
1987
|
+
* values.
|
|
1988
|
+
*
|
|
1989
|
+
* Behavior is undefined when [count] or [divisions] is 0.
|
|
1990
|
+
* When divisions < count, colors repeat.
|
|
1991
|
+
*
|
|
1992
|
+
* [count] The number of colors to return, includes the input color.
|
|
1993
|
+
* [divisions] The number of divisions on the color wheel.
|
|
1994
|
+
*/
|
|
1995
|
+
analogous(count?: number, divisions?: number): Hct[];
|
|
1996
|
+
/**
|
|
1997
|
+
* A color that complements the input color aesthetically.
|
|
1998
|
+
*
|
|
1999
|
+
* In art, this is usually described as being across the color wheel.
|
|
2000
|
+
* History of this shows intent as a color that is just as cool-warm as the
|
|
2001
|
+
* input color is warm-cool.
|
|
2002
|
+
*/
|
|
2003
|
+
get complement(): Hct;
|
|
2004
|
+
/**
|
|
2005
|
+
* Temperature relative to all colors with the same chroma and tone.
|
|
2006
|
+
* Value on a scale from 0 to 1.
|
|
2007
|
+
*/
|
|
2008
|
+
relativeTemperature(hct: Hct): number;
|
|
2009
|
+
/** Relative temperature of the input color. See [relativeTemperature]. */
|
|
2010
|
+
get inputRelativeTemperature(): number;
|
|
2011
|
+
/** A Map with keys of HCTs in [hctsByTemp], values of raw temperature. */
|
|
2012
|
+
get tempsByHct(): Map<Hct, number>;
|
|
2013
|
+
/**
|
|
2014
|
+
* HCTs for all hues, with the same chroma/tone as the input.
|
|
2015
|
+
* Sorted ascending, hue 0 to 360.
|
|
2016
|
+
*/
|
|
2017
|
+
get hctsByHue(): Hct[];
|
|
2018
|
+
/** Determines if an angle is between two other angles, rotating clockwise. */
|
|
2019
|
+
static isBetween(angle: number, a: number, b: number): boolean;
|
|
2020
|
+
/**
|
|
2021
|
+
* Value representing cool-warm factor of a color.
|
|
2022
|
+
* Values below 0 are considered cool, above, warm.
|
|
2023
|
+
*
|
|
2024
|
+
* Color science has researched emotion and harmony, which art uses to select
|
|
2025
|
+
* colors. Warm-cool is the foundation of analogous and complementary colors.
|
|
2026
|
+
* See:
|
|
2027
|
+
* - Li-Chen Ou's Chapter 19 in Handbook of Color Psychology (2015).
|
|
2028
|
+
* - Josef Albers' Interaction of Color chapters 19 and 21.
|
|
2029
|
+
*
|
|
2030
|
+
* Implementation of Ou, Woodcock and Wright's algorithm, which uses
|
|
2031
|
+
* L*a*b* / LCH color space.
|
|
2032
|
+
* Return value has these properties:
|
|
2033
|
+
* - Values below 0 are cool, above 0 are warm.
|
|
2034
|
+
* - Lower bound: -0.52 - (chroma ^ 1.07 / 20). L*a*b* chroma is infinite.
|
|
2035
|
+
* Assuming max of 130 chroma, -9.66.
|
|
2036
|
+
* - Upper bound: -0.52 + (chroma ^ 1.07 / 20). L*a*b* chroma is infinite.
|
|
2037
|
+
* Assuming max of 130 chroma, 8.61.
|
|
2038
|
+
*/
|
|
2039
|
+
static rawTemperature(color: Hct): number;
|
|
2040
|
+
}
|
|
2041
|
+
declare namespace index_d_exports$8 {
|
|
2042
|
+
export { TemperatureCache };
|
|
2043
|
+
}
|
|
2044
|
+
declare namespace ColorUtils_d_exports {
|
|
2045
|
+
export { alphaFromArgb, argbFromLab, argbFromLinrgb, argbFromLstar, argbFromRgb, argbFromXyz, blueFromArgb, delinearized, greenFromArgb, isOpaque, labFromArgb, linearized, lstarFromArgb, lstarFromY, redFromArgb, whitePointD65, xyzFromArgb, yFromLstar };
|
|
2046
|
+
}
|
|
2047
|
+
/**
|
|
2048
|
+
* @license
|
|
2049
|
+
* Copyright 2021 Google LLC
|
|
2050
|
+
*
|
|
2051
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2052
|
+
* you may not use this file except in compliance with the License.
|
|
2053
|
+
* You may obtain a copy of the License at
|
|
2054
|
+
*
|
|
2055
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2056
|
+
*
|
|
2057
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2058
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2059
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2060
|
+
* See the License for the specific language governing permissions and
|
|
2061
|
+
* limitations under the License.
|
|
2062
|
+
*/
|
|
2063
|
+
/**
|
|
2064
|
+
* Converts a color from RGB components to ARGB format.
|
|
2065
|
+
*/
|
|
2066
|
+
declare function argbFromRgb(red: number, green: number, blue: number): number;
|
|
2067
|
+
/**
|
|
2068
|
+
* Converts a color from linear RGB components to ARGB format.
|
|
2069
|
+
*/
|
|
2070
|
+
declare function argbFromLinrgb(linrgb: number[]): number;
|
|
2071
|
+
/**
|
|
2072
|
+
* Returns the alpha component of a color in ARGB format.
|
|
2073
|
+
*/
|
|
2074
|
+
declare function alphaFromArgb(argb: number): number;
|
|
2075
|
+
/**
|
|
2076
|
+
* Returns the red component of a color in ARGB format.
|
|
2077
|
+
*/
|
|
2078
|
+
declare function redFromArgb(argb: number): number;
|
|
2079
|
+
/**
|
|
2080
|
+
* Returns the green component of a color in ARGB format.
|
|
2081
|
+
*/
|
|
2082
|
+
declare function greenFromArgb(argb: number): number;
|
|
2083
|
+
/**
|
|
2084
|
+
* Returns the blue component of a color in ARGB format.
|
|
2085
|
+
*/
|
|
2086
|
+
declare function blueFromArgb(argb: number): number;
|
|
2087
|
+
/**
|
|
2088
|
+
* Returns whether a color in ARGB format is opaque.
|
|
2089
|
+
*/
|
|
2090
|
+
declare function isOpaque(argb: number): boolean;
|
|
2091
|
+
/**
|
|
2092
|
+
* Converts a color from ARGB to XYZ.
|
|
2093
|
+
*/
|
|
2094
|
+
declare function argbFromXyz(x: number, y: number, z: number): number;
|
|
2095
|
+
/**
|
|
2096
|
+
* Converts a color from XYZ to ARGB.
|
|
2097
|
+
*/
|
|
2098
|
+
declare function xyzFromArgb(argb: number): number[];
|
|
2099
|
+
/**
|
|
2100
|
+
* Converts a color represented in Lab color space into an ARGB
|
|
2101
|
+
* integer.
|
|
2102
|
+
*/
|
|
2103
|
+
declare function argbFromLab(l: number, a: number, b: number): number;
|
|
2104
|
+
/**
|
|
2105
|
+
* Converts a color from ARGB representation to L*a*b*
|
|
2106
|
+
* representation.
|
|
2107
|
+
*
|
|
2108
|
+
* @param argb the ARGB representation of a color
|
|
2109
|
+
* @return a Lab object representing the color
|
|
2110
|
+
*/
|
|
2111
|
+
declare function labFromArgb(argb: number): number[];
|
|
2112
|
+
/**
|
|
2113
|
+
* Converts an L* value to an ARGB representation.
|
|
2114
|
+
*
|
|
2115
|
+
* @param lstar L* in L*a*b*
|
|
2116
|
+
* @return ARGB representation of grayscale color with lightness
|
|
2117
|
+
* matching L*
|
|
2118
|
+
*/
|
|
2119
|
+
declare function argbFromLstar(lstar: number): number;
|
|
2120
|
+
/**
|
|
2121
|
+
* Computes the L* value of a color in ARGB representation.
|
|
2122
|
+
*
|
|
2123
|
+
* @param argb ARGB representation of a color
|
|
2124
|
+
* @return L*, from L*a*b*, coordinate of the color
|
|
2125
|
+
*/
|
|
2126
|
+
declare function lstarFromArgb(argb: number): number;
|
|
2127
|
+
/**
|
|
2128
|
+
* Converts an L* value to a Y value.
|
|
2129
|
+
*
|
|
2130
|
+
* L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
|
|
2131
|
+
*
|
|
2132
|
+
* L* measures perceptual luminance, a linear scale. Y in XYZ
|
|
2133
|
+
* measures relative luminance, a logarithmic scale.
|
|
2134
|
+
*
|
|
2135
|
+
* @param lstar L* in L*a*b*
|
|
2136
|
+
* @return Y in XYZ
|
|
2137
|
+
*/
|
|
2138
|
+
declare function yFromLstar(lstar: number): number;
|
|
2139
|
+
/**
|
|
2140
|
+
* Converts a Y value to an L* value.
|
|
2141
|
+
*
|
|
2142
|
+
* L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
|
|
2143
|
+
*
|
|
2144
|
+
* L* measures perceptual luminance, a linear scale. Y in XYZ
|
|
2145
|
+
* measures relative luminance, a logarithmic scale.
|
|
2146
|
+
*
|
|
2147
|
+
* @param y Y in XYZ
|
|
2148
|
+
* @return L* in L*a*b*
|
|
2149
|
+
*/
|
|
2150
|
+
declare function lstarFromY(y: number): number;
|
|
2151
|
+
/**
|
|
2152
|
+
* Linearizes an RGB component.
|
|
2153
|
+
*
|
|
2154
|
+
* @param rgbComponent 0 <= rgb_component <= 255, represents R/G/B
|
|
2155
|
+
* channel
|
|
2156
|
+
* @return 0.0 <= output <= 100.0, color channel converted to
|
|
2157
|
+
* linear RGB space
|
|
2158
|
+
*/
|
|
2159
|
+
declare function linearized(rgbComponent: number): number;
|
|
2160
|
+
/**
|
|
2161
|
+
* Delinearizes an RGB component.
|
|
2162
|
+
*
|
|
2163
|
+
* @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
|
|
2164
|
+
* linear R/G/B channel
|
|
2165
|
+
* @return 0 <= output <= 255, color channel converted to regular
|
|
2166
|
+
* RGB space
|
|
2167
|
+
*/
|
|
2168
|
+
declare function delinearized(rgbComponent: number): number;
|
|
2169
|
+
/**
|
|
2170
|
+
* Returns the standard white point; white on a sunny day.
|
|
2171
|
+
*
|
|
2172
|
+
* @return The white point
|
|
2173
|
+
*/
|
|
2174
|
+
declare function whitePointD65(): number[];
|
|
2175
|
+
declare namespace MathUtils_d_exports {
|
|
2176
|
+
export { clampDouble, clampInt, differenceDegrees, lerp, matrixMultiply, rotationDirection, sanitizeDegreesDouble, sanitizeDegreesInt, signum };
|
|
2177
|
+
}
|
|
2178
|
+
/**
|
|
2179
|
+
* @license
|
|
2180
|
+
* Copyright 2021 Google LLC
|
|
2181
|
+
*
|
|
2182
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2183
|
+
* you may not use this file except in compliance with the License.
|
|
2184
|
+
* You may obtain a copy of the License at
|
|
2185
|
+
*
|
|
2186
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2187
|
+
*
|
|
2188
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2189
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2190
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2191
|
+
* See the License for the specific language governing permissions and
|
|
2192
|
+
* limitations under the License.
|
|
2193
|
+
*/
|
|
2194
|
+
/**
|
|
2195
|
+
* Utility methods for mathematical operations.
|
|
2196
|
+
*/
|
|
2197
|
+
/**
|
|
2198
|
+
* The signum function.
|
|
2199
|
+
*
|
|
2200
|
+
* @return 1 if num > 0, -1 if num < 0, and 0 if num = 0
|
|
2201
|
+
*/
|
|
2202
|
+
declare function signum(num: number): number;
|
|
2203
|
+
/**
|
|
2204
|
+
* The linear interpolation function.
|
|
2205
|
+
*
|
|
2206
|
+
* @return start if amount = 0 and stop if amount = 1
|
|
2207
|
+
*/
|
|
2208
|
+
declare function lerp(start: number, stop: number, amount: number): number;
|
|
2209
|
+
/**
|
|
2210
|
+
* Clamps an integer between two integers.
|
|
2211
|
+
*
|
|
2212
|
+
* @return input when min <= input <= max, and either min or max
|
|
2213
|
+
* otherwise.
|
|
2214
|
+
*/
|
|
2215
|
+
declare function clampInt(min: number, max: number, input: number): number;
|
|
2216
|
+
/**
|
|
2217
|
+
* Clamps an integer between two floating-point numbers.
|
|
2218
|
+
*
|
|
2219
|
+
* @return input when min <= input <= max, and either min or max
|
|
2220
|
+
* otherwise.
|
|
2221
|
+
*/
|
|
2222
|
+
declare function clampDouble(min: number, max: number, input: number): number;
|
|
2223
|
+
/**
|
|
2224
|
+
* Sanitizes a degree measure as an integer.
|
|
2225
|
+
*
|
|
2226
|
+
* @return a degree measure between 0 (inclusive) and 360
|
|
2227
|
+
* (exclusive).
|
|
2228
|
+
*/
|
|
2229
|
+
declare function sanitizeDegreesInt(degrees: number): number;
|
|
2230
|
+
/**
|
|
2231
|
+
* Sanitizes a degree measure as a floating-point number.
|
|
2232
|
+
*
|
|
2233
|
+
* @return a degree measure between 0.0 (inclusive) and 360.0
|
|
2234
|
+
* (exclusive).
|
|
2235
|
+
*/
|
|
2236
|
+
declare function sanitizeDegreesDouble(degrees: number): number;
|
|
2237
|
+
/**
|
|
2238
|
+
* Sign of direction change needed to travel from one angle to
|
|
2239
|
+
* another.
|
|
2240
|
+
*
|
|
2241
|
+
* For angles that are 180 degrees apart from each other, both
|
|
2242
|
+
* directions have the same travel distance, so either direction is
|
|
2243
|
+
* shortest. The value 1.0 is returned in this case.
|
|
2244
|
+
*
|
|
2245
|
+
* @param from The angle travel starts from, in degrees.
|
|
2246
|
+
* @param to The angle travel ends at, in degrees.
|
|
2247
|
+
* @return -1 if decreasing from leads to the shortest travel
|
|
2248
|
+
* distance, 1 if increasing from leads to the shortest travel
|
|
2249
|
+
* distance.
|
|
2250
|
+
*/
|
|
2251
|
+
declare function rotationDirection(from: number, to: number): number;
|
|
2252
|
+
/**
|
|
2253
|
+
* Distance of two points on a circle, represented using degrees.
|
|
2254
|
+
*/
|
|
2255
|
+
declare function differenceDegrees(a: number, b: number): number;
|
|
2256
|
+
/**
|
|
2257
|
+
* Multiplies a 1x3 row vector with a 3x3 matrix.
|
|
2258
|
+
*/
|
|
2259
|
+
declare function matrixMultiply(row: number[], matrix: number[][]): number[];
|
|
2260
|
+
declare namespace StringUtils_d_exports {
|
|
2261
|
+
export { argbFromHex, hexFromArgb };
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* @license
|
|
2265
|
+
* Copyright 2021 Google LLC
|
|
2266
|
+
*
|
|
2267
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2268
|
+
* you may not use this file except in compliance with the License.
|
|
2269
|
+
* You may obtain a copy of the License at
|
|
2270
|
+
*
|
|
2271
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2272
|
+
*
|
|
2273
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2274
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2275
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2276
|
+
* See the License for the specific language governing permissions and
|
|
2277
|
+
* limitations under the License.
|
|
2278
|
+
*/
|
|
2279
|
+
/**
|
|
2280
|
+
* Utility methods for hexadecimal representations of colors.
|
|
2281
|
+
*/
|
|
2282
|
+
/**
|
|
2283
|
+
* @param argb ARGB representation of a color.
|
|
2284
|
+
* @return Hex string representing color, ex. #ff0000 for red.
|
|
2285
|
+
*/
|
|
2286
|
+
declare function hexFromArgb(argb: number): string;
|
|
2287
|
+
/**
|
|
2288
|
+
* @param hex String representing color as hex code. Accepts strings with or
|
|
2289
|
+
* without leading #, and string representing the color using 3, 6, or 8
|
|
2290
|
+
* hex characters.
|
|
2291
|
+
* @return ARGB representation of color.
|
|
2292
|
+
*/
|
|
2293
|
+
declare function argbFromHex(hex: string): number;
|
|
2294
|
+
declare namespace index_d_exports$9 {
|
|
2295
|
+
export { ColorUtils_d_exports as ColorUtils, MathUtils_d_exports as MathUtils, StringUtils_d_exports as StringUtils };
|
|
2296
|
+
}
|
|
2297
|
+
export { index_d_exports as blend, index_d_exports$1 as contrast, index_d_exports$2 as dislike, index_d_exports$3 as hct, index_d_exports$4 as palettes, index_d_exports$5 as quantize, index_d_exports$6 as scheme, index_d_exports$7 as score, index_d_exports$8 as temperature, index_d_exports$9 as utils };
|