UNPKG

svg-engine

Version:
84 lines 3.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ShapeInstances = void 0; const SVGInstance_js_1 = require("../../../node/instance/SVGInstance.js"); const SVGRectInstance_js_1 = require("../../instances/SVGRectInstance.js"); const SVGCircleInstance_js_1 = require("../../instances/SVGCircleInstance.js"); const SVGLineInstance_js_1 = require("../../instances/SVGLineInstance.js"); const SVGPathInstance_js_1 = require("../../instances/SVGPathInstance.js"); const SVGTextInstance_js_1 = require("../../instances/SVGTextInstance.js"); class ShapeInstances extends SVGInstance_js_1.SVGInstance { addRect(xOrUndefined, yOrUndefined, widthOrUndefined, heightOrUndefined) { const rect = new SVGRectInstance_js_1.SVGRectInstance(this); if (xOrUndefined !== undefined) { rect.attr("x", xOrUndefined + ""); } if (yOrUndefined !== undefined) { rect.attr("y", yOrUndefined + ""); } if (widthOrUndefined !== undefined) { rect.attr("width", widthOrUndefined + ""); } if (heightOrUndefined !== undefined) { rect.attr("height", heightOrUndefined + ""); } this.appendInstance(rect); return rect; } addCircle(cxOrUndefined, cyOrUndefined, radiusOrUndefined) { const circle = new SVGCircleInstance_js_1.SVGCircleInstance(this); if (cxOrUndefined !== undefined) { circle.attr("cx", cxOrUndefined + ""); } if (cyOrUndefined !== undefined) { circle.attr("cy", cyOrUndefined + ""); } if (radiusOrUndefined !== undefined) { circle.attr("r", radiusOrUndefined + ""); } this.appendInstance(circle); return circle; } addLine(x1OrUndefined, y1OrUndefined, x2OrUndefined, y2OrUndefined) { const line = new SVGLineInstance_js_1.SVGLineInstance(this); if (x1OrUndefined !== undefined) { line.attr("x1", x1OrUndefined + ""); } if (y1OrUndefined !== undefined) { line.attr("y1", y1OrUndefined + ""); } if (x2OrUndefined !== undefined) { line.attr("x2", x2OrUndefined + ""); } if (y2OrUndefined !== undefined) { line.attr("y2", y2OrUndefined + ""); } this.appendInstance(line); return line; } addPath(dOrUndefined) { const path = new SVGPathInstance_js_1.SVGPathInstance(this); if (dOrUndefined !== undefined) { path.attr("d", dOrUndefined + ""); } this.appendInstance(path); return path; } addText(xOrTextOrUndefined, yOrUndefined, textOrUndefined) { const text = new SVGTextInstance_js_1.SVGTextInstance(this); if (typeof xOrTextOrUndefined === "string" && typeof yOrUndefined === "undefined") { text.text(xOrTextOrUndefined); } else if ((typeof xOrTextOrUndefined === "string" || typeof xOrTextOrUndefined === "number") && (typeof yOrUndefined === "string" || typeof yOrUndefined === "number")) { text.attr("x", xOrTextOrUndefined); text.attr("y", yOrUndefined); if (typeof textOrUndefined === "string") { text.text(textOrUndefined); } } this.appendInstance(text); return text; } } exports.ShapeInstances = ShapeInstances; //# sourceMappingURL=shapeInstances.js.map