UNPKG

color-range

Version:
30 lines (24 loc) 780 B
declare type ColorReturnType = 'RGB' | 'RGBA' | 'HEX' | 'HSLA'; /** * 计算给定百分比在多段颜色区间中的过渡色。 * * @param percent 百分比,0-100。 * @param type 返回颜色格式:'RGB' | 'RGBA' | 'HEX' | 'HSLA'(目前实现不真正返回 HSLA)。 * @param colors 颜色断点,字符串形式均分步长。 * @returns 格式化后的颜色字符串。 */ declare function colorRange( percent: number, type: ColorReturnType, ...colors: string[] ): string; /** * 颜色断点数组形式:[color, startPercent]。 * 例如:["#000000", 0], ["#ffffff", 100] */ declare function colorRange( percent: number, type: ColorReturnType, ...colors: Array<[string, number]> ): string; export = colorRange;