-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathindex.d.ts
More file actions
164 lines (153 loc) · 6.39 KB
/
index.d.ts
File metadata and controls
164 lines (153 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import type { Color } from '@csstools/color-helpers';
import type { ComponentValue } from '@csstools/css-parser-algorithms';
import { FunctionNode } from '@csstools/css-parser-algorithms';
/**
* Convert a color function to a `ColorData` object.
*
* @param {ComponentValue} colorNode - The color function to be converted.
* @returns {ColorData|false} The color function as a `ColorData` object or `false` if it could not be converted.
*/
export declare function color(colorNode: ComponentValue): ColorData | false;
/**
* A color data object.
* It contains as much information as possible about the color and the original parsed syntax.
*/
export declare interface ColorData {
/**
* The color notation of the color data.
*
* We use "color notation" and not "color space" because these represent the original notation and not the actual color space.
* The actual color space is however always implied by the color notation.
*/
colorNotation: ColorNotation;
/**
* The color channels.
* This is always an array of three numbers
* but the channels can only be interpreted by looking at the color notation.
*/
channels: Color;
/**
* The alpha channel.
* This is either a number between `0` and `1` or a `ComponentValue` object.
*
* Since most computations are not dependent on the alpha channel,
* we allow things like `var(--some-alpha)` as an alpha channel value for most inputs.
*/
alpha: number | ComponentValue;
/**
* Information about the original syntax.
*/
syntaxFlags: Set<SyntaxFlag>;
}
/**
* Check if a color data object fits the `display-p3` gamut.
*
* @param {ColorData} x - The color data to be checked.
* @returns {boolean} Whether the color data fits the `display-p3` gamut.
*/
export declare function colorDataFitsDisplayP3_Gamut(x: ColorData): boolean;
/**
* Check if a color data object fits the `sRGB` gamut.
*
* @param {ColorData} x - The color data to be checked.
* @returns {boolean} Whether the color data fits the `sRGB` gamut.
*/
export declare function colorDataFitsRGB_Gamut(x: ColorData): boolean;
export declare enum ColorNotation {
/** Adobe 1999, expressed through `color(a98-rgb 0 0 0)` */
A98_RGB = "a98-rgb",
/** Display P3, expressed through `color(display-p3 0 0 0)` */
Display_P3 = "display-p3",
/** Hex, expressed through `#000` */
HEX = "hex",
/** HSL, expressed through `hsl(0 0% 0%)` */
HSL = "hsl",
/** HWB, expressed through `hwb(0 0% 0%)` */
HWB = "hwb",
/** LCH, expressed through `lch(0 0% 0deg)` */
LCH = "lch",
/** Lab, expressed through `lab(0 0 0)` */
Lab = "lab",
/** Linear sRGB, expressed through `color(linear-srgb 0 0 0)` */
Linear_sRGB = "srgb-linear",
/** Oklch, expressed through `oklch(0 0% 0deg)` */
OKLCH = "oklch",
/** Oklab, expressed through `oklab(0 0 0)` */
OKLab = "oklab",
/** ProPhoto RGB, expressed through `color(prophoto-rgb 0 0 0)` */
ProPhoto_RGB = "prophoto-rgb",
/** RGB, expressed through `rgb(0 0 0)` */
RGB = "rgb",
/** sRGB, expressed through `color(srgb 0 0 0)` */
sRGB = "srgb",
/** Rec. 2020, expressed through `color(rec2020 0 0 0)` */
Rec2020 = "rec2020",
/** XYZ, expressed through `color(xyz-d50 0 0 0)` */
XYZ_D50 = "xyz-d50",
/** XYZ, expressed through `color(xyz-d65 0 0 0)` */
XYZ_D65 = "xyz-d65"
}
export declare function serializeHSL(color: ColorData, gamutMapping?: boolean): FunctionNode;
/**
* Convert color data to component values in the OKLCH color space.
* The return value can be converted to a string by calling `toString()` on it.
*
* @param {ColorData} color - The color data to be serialized.
* @returns {FunctionNode} The serialized color data as a FunctionNode object.
*/
export declare function serializeOKLCH(color: ColorData): FunctionNode;
/**
* Convert color data to component values in the display-p3 color space.
* The return value can be converted to a string by calling `toString()` on it.
*
* @param {ColorData} color - The color data to be serialized.
* @param {boolean} gamutMapping - Whether to perform gamut mapping, defaults to `true`.
* @returns {FunctionNode} The serialized color data as a FunctionNode object.
*/
export declare function serializeP3(color: ColorData, gamutMapping?: boolean): FunctionNode;
/**
* Convert color data to component values in the srgb color space.
* The return value can be converted to a string by calling `toString()` on it.
*
* @param {ColorData} color - The color data to be serialized.
* @param {boolean} gamutMapping - Whether to perform gamut mapping, defaults to `true`.
* @returns {FunctionNode} The serialized color data as a FunctionNode object.
*/
export declare function serializeRGB(color: ColorData, gamutMapping?: boolean): FunctionNode;
export declare enum SyntaxFlag {
/** Is a color keyword, e.g. `transparent`, `currentColor`, ... */
ColorKeyword = "color-keyword",
/** Has an explicit alpha channel */
HasAlpha = "has-alpha",
/** Has a channel with a dimension value, e.g. `50deg` */
HasDimensionValues = "has-dimension-values",
/** Has a channel with the `none` keyword */
HasNoneKeywords = "has-none-keywords",
/** Has a channel with a number value */
HasNumberValues = "has-number-values",
/** Has an alpha channel with a percentage value */
HasPercentageAlpha = "has-percentage-alpha",
/** Has a channel with a percentage value */
HasPercentageValues = "has-percentage-values",
/** Has an alpha channel with a `var()` function value */
HasVariableAlpha = "has-variable-alpha",
/** Is Hex notation */
Hex = "hex",
/** Is legacy HSL, e.g. `hsl(50deg, 0%, 0%)` */
LegacyHSL = "legacy-hsl",
/** Is legacy RGB, e.g. `rgb(0, 0, 0)` */
LegacyRGB = "legacy-rgb",
/** Is a named color, e.g. `red`, `blue` */
NamedColor = "named-color",
/** Is a relative color syntax, e.g. `rgb(from purple r g b)` */
RelativeColorSyntax = "relative-color-syntax",
/** Is a mixed color, e.g. `color-mix(in oklch, red, blue)` */
ColorMix = "color-mix",
/** Is a variadic mixed color, e.g. `color-mix(in oklch, red)` `color-mix(in oklch, red, blue, green)` */
ColorMixVariadic = "color-mix-variadic",
/** Is a contrasting color, e.g. `contrast-color()` */
ContrastColor = "contrast-color",
/** Is an experimental color syntax */
Experimental = "experimental"
}
export { }