zhangyong
2023-08-22 1353e87cb21a4032d585d7404bae9042f2ebcf08
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import { HSL, HSLA, HSV, HSVA, Numberify, RGB, RGBA } from './interfaces';
export interface TinyColorOptions {
    format: string;
    gradientType: string;
}
export type ColorInput = string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | TinyColor;
export type ColorFormats = 'rgb' | 'prgb' | 'hex' | 'hex3' | 'hex4' | 'hex6' | 'hex8' | 'name' | 'hsl' | 'hsv';
export declare class TinyColor {
    /** red */
    r: number;
    /** green */
    g: number;
    /** blue */
    b: number;
    /** alpha */
    a: number;
    /** the format used to create the tinycolor instance */
    format: ColorFormats;
    /** input passed into the constructer used to create the tinycolor instance */
    originalInput: ColorInput;
    /** the color was successfully parsed */
    isValid: boolean;
    gradientType?: string;
    /** rounded alpha */
    roundA: number;
    constructor(color?: ColorInput, opts?: Partial<TinyColorOptions>);
    isDark(): boolean;
    isLight(): boolean;
    /**
     * Returns the perceived brightness of the color, from 0-255.
     */
    getBrightness(): number;
    /**
     * Returns the perceived luminance of a color, from 0-1.
     */
    getLuminance(): number;
    /**
     * Returns the alpha value of a color, from 0-1.
     */
    getAlpha(): number;
    /**
     * Sets the alpha value on the current color.
     *
     * @param alpha - The new alpha value. The accepted range is 0-1.
     */
    setAlpha(alpha?: string | number): this;
    /**
     * Returns whether the color is monochrome.
     */
    isMonochrome(): boolean;
    /**
     * Returns the object as a HSVA object.
     */
    toHsv(): Numberify<HSVA>;
    /**
     * Returns the hsva values interpolated into a string with the following format:
     * "hsva(xxx, xxx, xxx, xx)".
     */
    toHsvString(): string;
    /**
     * Returns the object as a HSLA object.
     */
    toHsl(): Numberify<HSLA>;
    /**
     * Returns the hsla values interpolated into a string with the following format:
     * "hsla(xxx, xxx, xxx, xx)".
     */
    toHslString(): string;
    /**
     * Returns the hex value of the color.
     * @param allow3Char will shorten hex value to 3 char if possible
     */
    toHex(allow3Char?: boolean): string;
    /**
     * Returns the hex value of the color -with a # prefixed.
     * @param allow3Char will shorten hex value to 3 char if possible
     */
    toHexString(allow3Char?: boolean): string;
    /**
     * Returns the hex 8 value of the color.
     * @param allow4Char will shorten hex value to 4 char if possible
     */
    toHex8(allow4Char?: boolean): string;
    /**
     * Returns the hex 8 value of the color -with a # prefixed.
     * @param allow4Char will shorten hex value to 4 char if possible
     */
    toHex8String(allow4Char?: boolean): string;
    /**
     * Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
     * @param allowShortChar will shorten hex value to 3 or 4 char if possible
     */
    toHexShortString(allowShortChar?: boolean): string;
    /**
     * Returns the object as a RGBA object.
     */
    toRgb(): Numberify<RGBA>;
    /**
     * Returns the RGBA values interpolated into a string with the following format:
     * "RGBA(xxx, xxx, xxx, xx)".
     */
    toRgbString(): string;
    /**
     * Returns the object as a RGBA object.
     */
    toPercentageRgb(): RGBA;
    /**
     * Returns the RGBA relative values interpolated into a string
     */
    toPercentageRgbString(): string;
    /**
     * The 'real' name of the color -if there is one.
     */
    toName(): string | false;
    /**
     * String representation of the color.
     *
     * @param format - The format to be used when displaying the string representation.
     */
    toString<T extends 'name'>(format: T): boolean | string;
    toString<T extends ColorFormats>(format?: T): string;
    toNumber(): number;
    clone(): TinyColor;
    /**
     * Lighten the color a given amount. Providing 100 will always return white.
     * @param amount - valid between 1-100
     */
    lighten(amount?: number): TinyColor;
    /**
     * Brighten the color a given amount, from 0 to 100.
     * @param amount - valid between 1-100
     */
    brighten(amount?: number): TinyColor;
    /**
     * Darken the color a given amount, from 0 to 100.
     * Providing 100 will always return black.
     * @param amount - valid between 1-100
     */
    darken(amount?: number): TinyColor;
    /**
     * Mix the color with pure white, from 0 to 100.
     * Providing 0 will do nothing, providing 100 will always return white.
     * @param amount - valid between 1-100
     */
    tint(amount?: number): TinyColor;
    /**
     * Mix the color with pure black, from 0 to 100.
     * Providing 0 will do nothing, providing 100 will always return black.
     * @param amount - valid between 1-100
     */
    shade(amount?: number): TinyColor;
    /**
     * Desaturate the color a given amount, from 0 to 100.
     * Providing 100 will is the same as calling greyscale
     * @param amount - valid between 1-100
     */
    desaturate(amount?: number): TinyColor;
    /**
     * Saturate the color a given amount, from 0 to 100.
     * @param amount - valid between 1-100
     */
    saturate(amount?: number): TinyColor;
    /**
     * Completely desaturates a color into greyscale.
     * Same as calling `desaturate(100)`
     */
    greyscale(): TinyColor;
    /**
     * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
     * Values outside of this range will be wrapped into this range.
     */
    spin(amount: number): TinyColor;
    /**
     * Mix the current color a given amount with another color, from 0 to 100.
     * 0 means no mixing (return current color).
     */
    mix(color: ColorInput, amount?: number): TinyColor;
    analogous(results?: number, slices?: number): TinyColor[];
    /**
     * taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
     */
    complement(): TinyColor;
    monochromatic(results?: number): TinyColor[];
    splitcomplement(): TinyColor[];
    /**
     * Compute how the color would appear on a background
     */
    onBackground(background: ColorInput): TinyColor;
    /**
     * Alias for `polyad(3)`
     */
    triad(): TinyColor[];
    /**
     * Alias for `polyad(4)`
     */
    tetrad(): TinyColor[];
    /**
     * Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
     * monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
     */
    polyad(n: number): TinyColor[];
    /**
     * compare color vs current color
     */
    equals(color?: ColorInput): boolean;
}
export declare function tinycolor(color?: ColorInput, opts?: Partial<TinyColorOptions>): TinyColor;