UNPKG

@prescott/geo-pattern

Version:

Create beautiful generative geometric background images from a string.

28 lines 962 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Pattern = void 0; const svg_1 = require("./svg"); class Pattern { constructor() { this.width = 100; this.height = 100; } toSVG() { var _a, _b, _c, _d; const root = new svg_1.SVGNode("svg", { xmlns: "http://www.w3.org/2000/svg", width: Math.floor(this.width), height: Math.floor(this.height), }, [ ...((_b = (_a = this.background) === null || _a === void 0 ? void 0 : _a.image) !== null && _b !== void 0 ? _b : []), ...((_d = (_c = this.structure) === null || _c === void 0 ? void 0 : _c.image) !== null && _d !== void 0 ? _d : []), ]); return root.toXML(); } toDataURL() { const svg = this.toSVG(); return `data:image/svg+xml,${encodeURIComponent(svg)}`; } } exports.Pattern = Pattern; //# sourceMappingURL=pattern.js.map