nhanh-pure-function 4.6.1 → 4.6.2
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/dist/Format/index.d.ts +8 -0
- package/dist/Utility/modules/colorConverter.d.ts +22 -6
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +166 -154
- package/package.json +1 -1
package/dist/Format/index.d.ts
CHANGED
|
@@ -108,4 +108,12 @@ export declare function _Format_MillisecondToReadable(ms: number, maxUnit?: Unit
|
|
|
108
108
|
* @throws 当size小于1时抛出错误
|
|
109
109
|
*/
|
|
110
110
|
export declare function _Format_ChunkArray<T>(arr: T[], size: number): T[][];
|
|
111
|
+
/**
|
|
112
|
+
* 截断字符串,超出最大长度时追加后缀
|
|
113
|
+
* @param str 原始字符串
|
|
114
|
+
* @param max 最大长度
|
|
115
|
+
* @param suffix 超出时追加的后缀,默认为 "..."
|
|
116
|
+
* @returns 截断后的字符串
|
|
117
|
+
*/
|
|
118
|
+
export declare function _Format_Truncate(str: string, max: number, suffix?: string): string;
|
|
111
119
|
export {};
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RGBA 颜色分量对象。
|
|
3
|
+
* r/g/b 范围 0-255,a 范围 0-1
|
|
4
|
+
*/
|
|
5
|
+
export interface _Utility_RGBA {
|
|
6
|
+
r: number;
|
|
7
|
+
g: number;
|
|
8
|
+
b: number;
|
|
9
|
+
a: number;
|
|
10
|
+
}
|
|
1
11
|
/**
|
|
2
12
|
* 颜色转换工具。
|
|
3
13
|
* 支持输入:hex/rgb/hsl/hsv,统一解析后输出指定格式。
|
|
@@ -92,14 +102,20 @@ export declare class _Utility_ColorConverter {
|
|
|
92
102
|
a: number;
|
|
93
103
|
};
|
|
94
104
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
105
|
+
* 将颜色输入统一解析为 RGBA 对象。
|
|
106
|
+
* 字符串走 parseColor,已是对象则直接返回。
|
|
107
|
+
*/
|
|
108
|
+
private static resolveColorInput;
|
|
109
|
+
/**
|
|
110
|
+
* 判断两个颜色是否在允许的色差范围内(基于 RGBA 欧几里得距离)。
|
|
111
|
+
* 颜色参数支持任意颜色字符串或 { r, g, b, a } 对象。
|
|
112
|
+
* @param colorA 第一个颜色(字符串或 RGBA 对象)
|
|
113
|
+
* @param colorB 第二个颜色(字符串或 RGBA 对象)
|
|
114
|
+
* @param threshold 允许的最大色差值,范围约 0(完全相同)到 510(含 alpha 最大距离)
|
|
115
|
+
* @param includeAlpha 是否将 alpha 差值纳入计算,默认 true
|
|
100
116
|
* @returns true 表示在允许色差内
|
|
101
117
|
*/
|
|
102
|
-
static isWithinColorDifference(colorA: string, colorB: string, threshold: number, includeAlpha?: boolean): boolean;
|
|
118
|
+
static isWithinColorDifference(colorA: string | _Utility_RGBA, colorB: string | _Utility_RGBA, threshold: number, includeAlpha?: boolean): boolean;
|
|
103
119
|
/**
|
|
104
120
|
* 混合两个颜色(在 RGBA 空间线性插值)。
|
|
105
121
|
* @param colorA 起始颜色
|