UNPKG

svg-engine

Version:
56 lines 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Fill = void 0; const SVGInstance_js_1 = require("../../../node/instance/SVGInstance.js"); class Fill extends SVGInstance_js_1.SVGInstance { fill(fill) { if (typeof fill === "undefined") { const fill = this.attr("fill"); return typeof fill === "string" ? fill : null; } else if (typeof fill === "string") { this.attr("fill", fill); return this; } return null; } fillOpacity(fillOpacity) { if (typeof fillOpacity === "undefined") { const fillOpacity = this.attr("fill-opacity"); return typeof fillOpacity === "number" ? fillOpacity : null; } else if (typeof fillOpacity === "number") { this.attr("fill-opacity", fillOpacity); return this; } return null; } fillRule(fillRule) { if (typeof fillRule === "undefined") { const fillRule = this.attr("fill-rule"); return typeof fillRule === "string" ? fillRule : null; } else if (typeof fillRule === "string") { this.attr("fill-rule", fillRule); return this; } return null; } fillLinearGradient(gradient, rotation) { var _a, _b, _c; const defs = (_b = (_a = this.root) === null || _a === void 0 ? void 0 : _a.childInstances.find(instance => instance.element.tagName === "defs")) !== null && _b !== void 0 ? _b : (_c = this.root) === null || _c === void 0 ? void 0 : _c.addDefs(); const linearGradient = defs === null || defs === void 0 ? void 0 : defs.addLinearGradient(); const id = defs.element.childNodes.length; linearGradient.attr("id", "gradient-" + id); if (typeof rotation === "number") { linearGradient.attr("gradientTransform", "rotate(" + rotation + ")"); } for (const stop of gradient) { linearGradient.addStop(stop.position, stop.color); } this.attr("fill", "url(#gradient-" + id + ")"); return this; } } exports.Fill = Fill; //# sourceMappingURL=fill.js.map