UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

21 lines 881 B
import { LabColor } from "@aurigma/design-atoms-model"; import { convertPercentToByte } from "./Utils"; var LabColorParser = /** @class */ (function () { function LabColorParser() { } LabColorParser.prototype.parse = function (colorString) { var labRegex = /^\s*lab\(\s*(\d{1,3})\s*,\s*(-*\d{1,3})\s*,\s*(-*\d{1,3})\s*(,\s*(\d{1,3})%)?\s*(\,\s*(.*)\s*)?\)\s*;{0,1}\s*$/; var match = labRegex.exec(colorString); if (match == null || match.length !== 8) { return null; } var alpha = 255; if (match[5] != null) { alpha = convertPercentToByte(parseFloat(match[5])); } return new LabColor(parseInt(match[1]), parseInt(match[2]), parseInt(match[3]), alpha); }; return LabColorParser; }()); export { LabColorParser }; //# sourceMappingURL=LabColorParser.js.map