UNPKG

xframelib

Version:

The accumulated front-end development foundation library originates from projects and serves projects.

75 lines (74 loc) 2.39 kB
/** * rgb转十六进制 * @param colorRGB rgb颜色值 * @returns */ export declare function getHexColor(colorRGB: string): string; /** * 十六进制转RGB * @param color16 十六进制颜色值 * @returns */ export declare function getRGBColor(color16: string): string; /** * 解决十六进制短颜色问题 * @param colorHex 十六进制颜色 * @returns */ export declare function getLongHexColor(colorHex: string): string; export declare enum EnumColor { RGBA = 0, Hex = 1, Hsla = 2 } /** * 判断是否是16进制颜色 * @param colorStr 颜色字符串 * @returns */ export declare function isEnumColor(colorStr: string): EnumColor | undefined; export declare function getRGBColorFromHSLA(colorHSLA: string): string | undefined; /** * 判断是否 十六进制颜色值. * 输入形式可为 #fff000 #f00 * * @param String color 十六进制颜色值 * @return Boolean */ export declare function isHexColor(color: string): boolean; /** * RGB 颜色值转换为 十六进制颜色值. * r, g, 和 b 需要在 [0, 255] 范围内 * * @return String 类似#ff00ff * @param r * @param g * @param b */ export declare function rgbToHex(r: number, g: number, b: number): string; /** * Transform a HEX color to its RGB representation * @param {string} hex The color to transform * @returns The RGB representation of the passed color */ export declare function hexToRGB(hex: string): string; export declare function colorIsDark(color: string): boolean | undefined; /** * Darkens a HEX color given the passed percentage * @param {string} color The color to process * @param {number} amount The amount to change the color by * @returns {string} The HEX representation of the processed color */ export declare function darken(color: string, amount: number): string; /** * Lightens a 6 char HEX color according to the passed percentage * @param {string} color The color to change * @param {number} amount The amount to change the color by * @returns {string} The processed color represented as HEX */ export declare function lighten(color: string, amount: number): string; /** * Determines what the best text color is (black or white) based con the contrast with the background * @param hexColor - Last selected color by the user */ export declare function calculateBestTextColor(hexColor: string): "#000000" | "#FFFFFF";