define(["require", "exports", "../utility/dom-util"], function (require, exports, dom_util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var BarcodeSVGRenderering = (function () {
function BarcodeSVGRenderering() {
}
BarcodeSVGRenderering.prototype.renderRootElement = function (attribute, backGroundColor) {
var canvasObj = dom_util_1.createSvgElement('svg', attribute);
canvasObj.setAttribute('style', 'background:' + backGroundColor);
return canvasObj;
};
BarcodeSVGRenderering.prototype.renderRect = function (svg, attribute) {
if (attribute.imageSource) {
return this.renderImage(svg, attribute);
}
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
rect.setAttribute('x', attribute.x.toString());
rect.setAttribute('y', attribute.y.toString());
rect.setAttribute('width', attribute.width.toString());
rect.setAttribute('height', attribute.height.toString());
rect.setAttribute('fill', attribute.color);
rect.setAttribute('style', 'shape-rendering: crispEdges');
svg.appendChild(rect);
return svg;
};
BarcodeSVGRenderering.prototype.renderText = function (svg, attribute) {
var text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
text.setAttribute('x', attribute.x.toString());
text.setAttribute('y', attribute.y.toString());
text.setAttribute('fill', attribute.color);
text.style.fontSize = attribute.stringSize.toString() + 'px';
text.style.fontFamily = attribute.fontStyle;
text.textContent = attribute.string;
svg.appendChild(text);
return svg;
};
BarcodeSVGRenderering.prototype.renderImage = function (svg, attribute) {
var image = document.createElementNS('http://www.w3.org/2000/svg', 'image');
image.setAttribute('x', attribute.x.toString());
image.setAttribute('y', attribute.y.toString());
image.setAttribute('width', attribute.width.toString());
image.setAttribute('height', attribute.height.toString());
image.setAttribute('href', attribute.imageSource);
image.setAttribute('preserveAspectRatio', 'none');
svg.appendChild(image);
return svg;
};
return BarcodeSVGRenderering;
}());
exports.BarcodeSVGRenderering = BarcodeSVGRenderering;
});
|