@castianta/chart-lc
Version:
62 lines (50 loc) • 1.77 kB
JavaScript
;
exports.__esModule = true;
exports.toStyle = exports.toStrokeStyle = exports.colorType = void 0;
var _lcjs = require("@arction/lcjs");
var colorType = function colorType(color) {
if (color.startsWith('#')) return (0, _lcjs.ColorHEX)(color);
if (color.startsWith('rgba')) {
var rgba = color.replace('rgba(', '').replace(')', '').split(',');
return _lcjs.ColorRGBA.apply(void 0, rgba.map(function (item, index) {
if (index === 3) {
return item * 255;
} else {
return item;
}
}));
}
return (0, _lcjs.ColorCSS)(color);
};
exports.colorType = colorType;
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 _lcjs.SolidFill({
color: colorType(color ? color : "rgba(" + r * 255 + "," + g * 255 + "," + b * 255 + "," + a + ")")
});
} else {
return new _lcjs.RadialGradientFill(data);
}
};
exports.toStyle = toStyle;
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 _lcjs.SolidLine({
thickness: width ? width : thickness,
fillStyle: new _lcjs.SolidFill({
color: colorType(color ? color : "rgba(" + r * 255 + "," + g * 255 + "," + b * 255 + "," + a + ")")
})
});
};
exports.toStrokeStyle = toStrokeStyle;