UNPKG

kviewui-uni

Version:

基于UNI-APP框架的多端开发UI组件库,让您的开发效率加倍提升

33 lines (26 loc) 540 B
import Color from 'color'; function getRgbStr(color) { return Color(color) .rgb() .round() .color .join(','); } const formats = ['hex', 'rgb', 'hsl']; function getFormat(format) { if (!format || formats.indexOf(format) < 0) { return 'hex'; } return format; } function getColorString(color, format) { const innerFormat = getFormat(format); if (innerFormat === 'hex') { return color[innerFormat](); } return color[innerFormat]().round().string(); } export default { getRgbStr, getColorString }