1 | export declare class Color {
|
2 | readonly r: number;
|
3 | readonly g: number;
|
4 | readonly b: number;
|
5 | readonly a: number;
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | constructor(r: number, g: number, b: number, a?: number);
|
19 | /**
|
20 | * The given string can be in one of the following formats:
|
21 | * - #rgb
|
22 | * - #rrggbb
|
23 | * - rgb(r, g, b)
|
24 | * - rgba(r, g, b, a)
|
25 | * - CSS color name such as 'white', 'orange', 'cyan', etc.
|
26 | * @param str
|
27 | */
|
28 | static fromString(str: string): Color;
|
29 | private static hexRe;
|
30 | private static shortHexRe;
|
31 | static fromHexString(str: string): Color;
|
32 | private static rgbRe;
|
33 | private static rgbaRe;
|
34 | static fromRgbaString(str: string): Color;
|
35 | static fromArray(arr: [number, number, number] | [number, number, number, number]): Color;
|
36 | /**
|
37 | * Creates an instance of the Color class from the given HSB(A) components.
|
38 | * @param h Hue in the [0, 360) range.
|
39 | * @param s Saturation in the [0, 1] range.
|
40 | * @param b Brightness in the [0, 1] range.
|
41 | * @param alpha Opacity in the [0, 1] range. Defaults to 1 (completely opaque).
|
42 | */
|
43 | static fromHSB(h: number, s: number, b: number, alpha?: number): Color;
|
44 | private static padHex;
|
45 | toHexString(): string;
|
46 | toRgbaString(fractionDigits?: number): string;
|
47 | toString(): string;
|
48 | toHSB(): [number, number, number];
|
49 | /**
|
50 | * Converts the given RGB triple to an array of HSB (HSV) components.
|
51 | * The hue component will be `NaN` for achromatic colors.
|
52 | */
|
53 | static RGBtoHSB(r: number, g: number, b: number): [number, number, number];
|
54 | /**
|
55 | * Converts the given HSB (HSV) triple to an array of RGB components.
|
56 | */
|
57 | static HSBtoRGB(H: number, S: number, B: number): [number, number, number];
|
58 | private derive;
|
59 | brighter(): Color;
|
60 | darker(): Color;
|
61 | /**
|
62 | * CSS Color Module Level 4:
|
63 | * https://drafts.csswg.org/css-color/#named-colors
|
64 | */
|
65 | private static nameToHex;
|
66 | }
|