UNPKG

5.09 kBTypeScriptView Raw
1/**
2 * Represents a color object. Stores all color components (alpha (opacity), red, green, blue) in a [0..255] range.
3 */
4export declare class Color {
5 constructor(knownColor: string);
6 constructor(hex: string);
7 constructor(argb: number);
8 constructor(alpha: number, red: number, green: number, blue: number, type?: 'rgb' | 'hsl' | 'hsv');
9
10 /**
11 * Gets the Alpha component (in the [0, 255] range) of this color. This is a read-only property.
12 */
13 public a: number;
14
15 /**
16 * Gets the Red component (in the [0, 255] range) of this color. This is a read-only property.
17 */
18 public r: number;
19
20 /**
21 * Gets the Green component (in the [0, 255] range) of this color. This is a read-only property.
22 */
23 public g: number;
24
25 /**
26 * Gets the Blue component (in the [0, 255] range) of this color. This is a read-only property.
27 */
28 public b: number;
29
30 /**
31 * Gets the Hexadecimal string representation of this color. This is a read-only property.
32 */
33 public hex: string;
34
35 /**
36 * Gets the Argb Number representation of this color where each 8 bits represent a single color component. This is a read-only property.
37 */
38 public argb: number;
39
40 /**
41 * Gets the known name of this instance. Defined only if it has been constructed from a known color name - e.g. "red". This is a read-only property.
42 */
43 public name: string;
44
45 /**
46 * Gets the android-specific integer value representation. Same as the Argb one. This is a read-only property.
47 */
48 android: number;
49
50 /**
51 * Gets the iOS-specific UIColor value representation. This is a read-only property.
52 */
53 ios: any /* UIColor */;
54
55 /**
56 * Specifies whether this Color is equal to the Color parameter.
57 * @param value The Color to test.
58 */
59 public equals(value: Color): boolean;
60
61 /**
62 * Compares two Color instances.
63 * @param value1 A Color to compare.
64 * @param value2 A Color to compare.
65 */
66 public static equals(value1: Color, value2: Color): boolean;
67
68 /**
69 * Validates if a value can be converted to color.
70 * @param value Input string.
71 */
72 public static isValid(value: any): boolean;
73
74 /**
75 * Creates color from iOS-specific UIColor value representation.
76 */
77 public static fromIosColor(value: any /* UIColor */): Color;
78
79 /**
80 * return true if brightenss < 128
81 *
82 */
83 public isDark(): boolean;
84
85 /**
86 * return true if brightenss >= 128
87 *
88 */
89 public isLight(): boolean;
90
91 /**
92 * return the [brightness](http://www.w3.org/TR/AERT#color-contrast)
93 *
94 */
95 public getBrightness(): number;
96 /**
97 * return the [luminance](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef)
98 *
99 */
100 public getLuminance(): number;
101
102 /**
103 * Return this color (as a new Color instance) with the provided alpha
104 *
105 * @param alpha (between 0 and 255)
106 */
107 public setAlpha(a: number): Color;
108 /**
109 * return the hsl representation of the color
110 *
111 */
112 public toHsl(): { h: number; s: number; l: number; a: number };
113
114 /**
115 * return the [CSS hsv](https://www.w3schools.com/Css/css_colors_hsl.asp) representation of the color
116 *
117 */
118 public toHslString(): string;
119
120 /**
121 * return the hsv representation of the color
122 *
123 */
124 public toHsv(): { h: number; s: number; v: number; a: number };
125
126 /**
127 * return the [CSS hsv](https://www.w3schools.com/Css/css_colors_rgb.asp) representation of the color
128 *
129 */
130 public toHsvString(): string;
131
132 /**
133 * return the [CSS rgb](https://www.w3schools.com/Css/css_colors_rgb.asp) representation of the color
134 *
135 */
136 public toRgbString(): string;
137
138 /**
139 * Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling greyscale.
140 *
141 * @param amount (between 0 and 100)
142 */
143 public desaturate(amount: number): Color;
144
145 /**
146 * Saturate the color a given amount, from 0 to 100.
147 *
148 * @param amount (between 0 and 100)
149 */
150 public saturate(amount: number): Color;
151
152 /**
153 * Completely desaturates a color into greyscale. Same as calling desaturate(100).
154 *
155 * @returns
156 */
157 public greyscale(): Color;
158
159 /**
160 * Lighten the color a given amount, from 0 to 100. Providing 100 will always return white.
161 *
162 * @param amount (between 0 and 100)
163 * @returns olor : Color
164 */
165 public lighten(amount: number): Color;
166
167 /**
168 * Brighten the color a given amount, from 0 to 100.
169 *
170 * @param amount (between 0 and 100)
171 */
172 public brighten(amount: number): Color;
173
174 /**
175 * Darken the color a given amount, from 0 to 100. Providing 100 will always return black.
176 *
177 * @param amount (between 0 and 100)
178 */
179 public darken(amount: number): Color;
180
181 /**
182 * Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing (since it sets the hue back to what it was before).
183 *
184 * @param amount (between 0 and 100)
185 */
186 public spin(amount: number): Color;
187
188 /**
189 * returns the color complement
190 *
191 */
192 public complement(): Color;
193
194 /**
195 * returns the color complement
196 *
197 */
198 public static mix(color1: Color, color2: Color, amount: number): Color;
199
200 /**
201 * returns a new Color from HSL
202 *
203 */
204 public static fromHSL(a, h, s, l): Color;
205 public static fromHSV(a, h, s, l): Color;
206}
207
\No newline at end of file