@996-design/996-fast-color 1.0.0
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/LICENSE +20 -0
- package/NOTICE.md +22 -0
- package/README.md +21 -0
- package/es/FastColor.d.ts +100 -0
- package/es/FastColor.js +571 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/presetColors.d.ts +151 -0
- package/es/presetColors.js +151 -0
- package/es/types.d.ts +24 -0
- package/es/types.js +1 -0
- package/lib/FastColor.d.ts +100 -0
- package/lib/FastColor.js +579 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +27 -0
- package/lib/presetColors.d.ts +151 -0
- package/lib/presetColors.js +157 -0
- package/lib/types.d.ts +24 -0
- package/lib/types.js +5 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Upstream attribution
|
|
2
|
+
|
|
3
|
+
The runtime and declaration artifacts in `es/` and `lib/` are derived from
|
|
4
|
+
`@ant-design/fast-color` 3.0.1.
|
|
5
|
+
|
|
6
|
+
- Upstream: https://github.com/ant-design/fast-color/tree/3.0.1
|
|
7
|
+
- License: MIT. See `LICENSE`.
|
|
8
|
+
|
|
9
|
+
Local changes are limited to the package identity, workspace scripts, package
|
|
10
|
+
metadata, and namespace references. The color implementation is otherwise kept
|
|
11
|
+
aligned with the published 3.0.1 package.
|
|
12
|
+
|
|
13
|
+
## Mechanical parity source
|
|
14
|
+
|
|
15
|
+
- npm tarball: https://registry.npmjs.org/@ant-design/fast-color/-/fast-color-3.0.1.tgz
|
|
16
|
+
- Integrity: `sha512-esKJegpW4nckh0o6kV3Tkb7NPIZYbPnnFxmQDUmL08ukXZAvV85TZBr70eGuke/CIArLaP6aw8lt9KILjnWuOw==`
|
|
17
|
+
- Guard inventory: 16 runtime files; sorted-path SHA-256
|
|
18
|
+
`0a75335e068de66ea5e581157abc98467137e335674c1f122986d358e32a6376`.
|
|
19
|
+
|
|
20
|
+
The parity inventory excludes package metadata, local build products,
|
|
21
|
+
`node_modules`, and caches. Every inventoried file is compared after only the
|
|
22
|
+
declared package-namespace rewrite.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# 996 Design Fast Color
|
|
2
|
+
|
|
3
|
+
Small immutable color class for parsing, conversion, channel operations, mixing and contrast calculations.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @996-design/996-fast-color
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { FastColor } from "@996-design/996-fast-color";
|
|
15
|
+
|
|
16
|
+
const accent = new FastColor("#5b8cff").setA(0.88).toRgbString();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
MIT. See `LICENSE` and `NOTICE.md` for license and source attribution.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { ColorInput, HSL, HSV, RGB } from './types';
|
|
2
|
+
export declare class FastColor {
|
|
3
|
+
/**
|
|
4
|
+
* All FastColor objects are valid. So isValid is always true. This property is kept to be compatible with TinyColor.
|
|
5
|
+
*/
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Red, R in RGB
|
|
9
|
+
*/
|
|
10
|
+
r: number;
|
|
11
|
+
/**
|
|
12
|
+
* Green, G in RGB
|
|
13
|
+
*/
|
|
14
|
+
g: number;
|
|
15
|
+
/**
|
|
16
|
+
* Blue, B in RGB
|
|
17
|
+
*/
|
|
18
|
+
b: number;
|
|
19
|
+
/**
|
|
20
|
+
* Alpha/Opacity, A in RGBA/HSLA
|
|
21
|
+
*/
|
|
22
|
+
a: number;
|
|
23
|
+
private _h?;
|
|
24
|
+
private _hsl_s?;
|
|
25
|
+
private _hsv_s?;
|
|
26
|
+
private _l?;
|
|
27
|
+
private _v?;
|
|
28
|
+
private _max?;
|
|
29
|
+
private _min?;
|
|
30
|
+
private _brightness?;
|
|
31
|
+
constructor(input: ColorInput);
|
|
32
|
+
setR(value: number): this;
|
|
33
|
+
setG(value: number): this;
|
|
34
|
+
setB(value: number): this;
|
|
35
|
+
setA(value: number): this;
|
|
36
|
+
setHue(value: number): this;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the perceived luminance of a color, from 0-1.
|
|
39
|
+
* @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
40
|
+
*/
|
|
41
|
+
getLuminance(): number;
|
|
42
|
+
getHue(): number;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated should use getHSVSaturation or getHSLSaturation instead
|
|
45
|
+
*/
|
|
46
|
+
getSaturation(): number;
|
|
47
|
+
getHSVSaturation(): number;
|
|
48
|
+
getHSLSaturation(): number;
|
|
49
|
+
getLightness(): number;
|
|
50
|
+
getValue(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the perceived brightness of the color, from 0-255.
|
|
53
|
+
* Note: this is not the b of HSB
|
|
54
|
+
* @see http://www.w3.org/TR/AERT#color-contrast
|
|
55
|
+
*/
|
|
56
|
+
getBrightness(): number;
|
|
57
|
+
darken(amount?: number): this;
|
|
58
|
+
lighten(amount?: number): this;
|
|
59
|
+
/**
|
|
60
|
+
* Mix the current color a given amount with another color, from 0 to 100.
|
|
61
|
+
* 0 means no mixing (return current color).
|
|
62
|
+
*/
|
|
63
|
+
mix(input: ColorInput, amount?: number): this;
|
|
64
|
+
/**
|
|
65
|
+
* Mix the color with pure white, from 0 to 100.
|
|
66
|
+
* Providing 0 will do nothing, providing 100 will always return white.
|
|
67
|
+
*/
|
|
68
|
+
tint(amount?: number): this;
|
|
69
|
+
/**
|
|
70
|
+
* Mix the color with pure black, from 0 to 100.
|
|
71
|
+
* Providing 0 will do nothing, providing 100 will always return black.
|
|
72
|
+
*/
|
|
73
|
+
shade(amount?: number): this;
|
|
74
|
+
onBackground(background: ColorInput): this;
|
|
75
|
+
isDark(): boolean;
|
|
76
|
+
isLight(): boolean;
|
|
77
|
+
equals(other: FastColor): boolean;
|
|
78
|
+
clone(): this;
|
|
79
|
+
toHexString(): string;
|
|
80
|
+
/** CSS support color pattern */
|
|
81
|
+
toHsl(): HSL;
|
|
82
|
+
/** CSS support color pattern */
|
|
83
|
+
toHslString(): string;
|
|
84
|
+
/** Same as toHsb */
|
|
85
|
+
toHsv(): HSV;
|
|
86
|
+
toRgb(): RGB;
|
|
87
|
+
toRgbString(): string;
|
|
88
|
+
toString(): string;
|
|
89
|
+
/** Return a new FastColor object with one channel changed */
|
|
90
|
+
private _sc;
|
|
91
|
+
private _c;
|
|
92
|
+
private getMax;
|
|
93
|
+
private getMin;
|
|
94
|
+
private fromHexString;
|
|
95
|
+
private fromHsl;
|
|
96
|
+
private fromHsv;
|
|
97
|
+
private fromHsvString;
|
|
98
|
+
private fromHslString;
|
|
99
|
+
private fromRgbString;
|
|
100
|
+
}
|