"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var SvgHelper = (function () { function SvgHelper() { } SvgHelper.createRect = function (width, height, attributes) { var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); rect.setAttribute('width', width.toString()); rect.setAttribute('height', height.toString()); if (attributes) { SvgHelper.setAttributes(rect, attributes); } return rect; }; SvgHelper.createLine = function (x1, y1, x2, y2, attributes) { var line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); line.setAttribute('x1', x1.toString()); line.setAttribute('y1', y1.toString()); line.setAttribute('x2', x2.toString()); line.setAttribute('y2', y2.toString()); if (attributes) { SvgHelper.setAttributes(line, attributes); } return line; }; SvgHelper.createPolygon = function (points, attributes) { var polygon = document.createElementNS('http://www.w3.org/2000/svg', 'polygon'); polygon.setAttribute('points', points); if (attributes) { SvgHelper.setAttributes(polygon, attributes); } return polygon; }; SvgHelper.createCircle = function (radius, attributes) { var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); circle.setAttribute('cx', (radius / 2).toString()); circle.setAttribute('cy', (radius / 2).toString()); circle.setAttribute('r', radius.toString()); if (attributes) { SvgHelper.setAttributes(circle, attributes); } return circle; }; SvgHelper.createGroup = function (attributes) { var g = document.createElementNS('http://www.w3.org/2000/svg', 'g'); if (attributes) { SvgHelper.setAttributes(g, attributes); } return g; }; SvgHelper.setAttributes = function (el, attributes) { for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var _a = attributes_1[_i], attr = _a[0], value = _a[1]; el.setAttribute(attr, value); } }; SvgHelper.createTransform = function () { var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); return svg.createSVGTransform(); }; SvgHelper.createDefs = function () { var defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs'); return defs; }; SvgHelper.createMarker = function (id, orient, markerWidth, markerHeight, refX, refY, markerElement) { var marker = document.createElementNS('http://www.w3.org/2000/svg', 'marker'); SvgHelper.setAttributes(marker, [ ['id', id], ['orient', orient], ['markerWidth', markerWidth.toString()], ['markerHeight', markerHeight.toString()], ['refX', refX.toString()], ['refY', refY.toString()] ]); marker.appendChild(markerElement); return marker; }; SvgHelper.createText = function (attributes) { var text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); text.setAttribute('x', '0'); text.setAttribute('y', '0'); if (attributes) { SvgHelper.setAttributes(text, attributes); } return text; }; SvgHelper.createTSpan = function (text, attributes) { var tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan'); tspan.textContent = text; if (attributes) { SvgHelper.setAttributes(tspan, attributes); } return tspan; }; return SvgHelper; }()); exports.SvgHelper = SvgHelper;