UNPKG

@castianta/chart-lc

Version:
53 lines (45 loc) 1.62 kB
import { SolidFill, ColorHEX, ColorRGBA, ColorCSS, RadialGradientFill, SolidLine } from '@arction/lcjs'; var colorType = function colorType(color) { if (color.startsWith('#')) return ColorHEX(color); if (color.startsWith('rgba')) { var rgba = color.replace('rgba(', '').replace(')', '').split(','); return ColorRGBA.apply(void 0, rgba.map(function (item, index) { if (index === 3) { return item * 255; } else { return item; } })); } return ColorCSS(color); }; var toStyle = function toStyle(data, color) { if (data !== null && data !== void 0 && data.color) { var _data$color = data === null || data === void 0 ? void 0 : data.color, r = _data$color.r, g = _data$color.g, b = _data$color.b, a = _data$color.a; return new SolidFill({ color: colorType(color ? color : "rgba(" + r * 255 + "," + g * 255 + "," + b * 255 + "," + a + ")") }); } else { return new RadialGradientFill(data); } }; var toStrokeStyle = function toStrokeStyle(width, color, stroke) { var _stroke$toJS = stroke.toJS(), thickness = _stroke$toJS.thickness, _stroke$toJS$fillStyl = _stroke$toJS.fillStyle.color, r = _stroke$toJS$fillStyl.r, g = _stroke$toJS$fillStyl.g, b = _stroke$toJS$fillStyl.b, a = _stroke$toJS$fillStyl.a; return new SolidLine({ thickness: width ? width : thickness, fillStyle: new SolidFill({ color: colorType(color ? color : "rgba(" + r * 255 + "," + g * 255 + "," + b * 255 + "," + a + ")") }) }); }; export { toStyle, colorType, toStrokeStyle };