@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
17 lines • 923 B
JavaScript
import { Ink, SpotColor } from "@aurigma/design-atoms-model";
import { convertPercentToByte } from "./Utils";
var SpotColorParser = /** @class */ (function () {
function SpotColorParser() {
}
SpotColorParser.prototype.parse = function (colorString, colorParser) {
var spotRegex = /^\s*spot\(\s*([^()]*)\s*,\s*(.{3,4}\([^()]*\))\s*(,\s*(\d{1}(\.\d{1,})?))?\s*(,\s*(\d{1,3})%)?\s*(,\s*(.*)\s*)?\)\s*;{0,1}\s*$/;
var match = spotRegex.exec(colorString);
if (match == null || match.length !== 10) {
return null;
}
return new SpotColor(new Ink(match[1].replace(/'/g, "").replace(/\"/g, ""), colorParser.parse(match[2]), match[4] != null ? parseFloat(match[4]) : 1), match[7] != null ? convertPercentToByte(parseFloat(match[7])) : 255);
};
return SpotColorParser;
}());
export { SpotColorParser };
//# sourceMappingURL=SpotColorParser.js.map