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.

13 lines 765 B
import { Ink, SpotColor } from "@aurigma/design-atoms-model"; import { convertPercentToByte } from "./Utils"; export class SpotColorParser { parse(colorString, colorParser) { const 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*$/; const 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); } } //# sourceMappingURL=SpotColorParser.js.map