UNPKG

@prescott/geo-pattern

Version:

Create beautiful generative geometric background images from a string.

57 lines 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlaidComposer = void 0; const svg_1 = require("../svg"); const base_1 = require("./base"); class PlaidComposer extends base_1.StructureComposer { constructor() { super(...arguments); this.name = "plaid"; } generate() { const nodes = []; let height = 0; let width = 0; // horizontal stripes for (let i = 0; i < 18 * 2; i += 2) { const space = this.seed.read(i, 1); height += space + 5; const value = this.seed.read(i + 1, 1); const opacity = this.opacity(value); const fill = this.fillColor(value); const stripeHeight = value + 5; nodes.push(new svg_1.SVGNode("rect", { x: 0, y: height, width: "100%", height: stripeHeight, opacity, fill, })); height += stripeHeight; } // vertical stripes for (let i = 0; i < 18 * 2; i += 2) { const space = this.seed.read(i, 1); width += space + 5; const value = this.seed.read(i + 1, 1); const opacity = this.opacity(value); const fill = this.fillColor(value); const stripeWidth = value + 5; nodes.push(new svg_1.SVGNode("rect", { x: width, y: 0, width: stripeWidth, height: "100%", opacity, fill, })); width += stripeWidth; } this.width = width; this.height = height; return nodes; } } exports.PlaidComposer = PlaidComposer; //# sourceMappingURL=plaid.js.map