alecmce-primitivesjs
Version:
A small library for visualizing the prime factor decomposition of numbers.
38 lines (37 loc) • 1.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
var Svg = (function () {
function Svg(elementOrType) {
if (typeof elementOrType == 'string') {
this.element = document.createElementNS(SVG_NAMESPACE, elementOrType);
}
}
Svg.prototype.append = function (child) {
this.element.appendChild(child);
return this;
};
Svg.prototype.appendTo = function (container) {
container.appendChild(this.element);
return this;
};
Svg.prototype.setAttribute = function (attribute, value) {
this.element.setAttributeNS(null, attribute, value);
return this;
};
Svg.prototype.position = function (x, y) {
this.setAttribute('transform', "translate(" + x + "," + y + ")");
return this;
};
Svg.prototype.scale = function (scalar) {
this.setAttribute('transform', "scale(" + scalar + ")");
return this;
};
Svg.prototype.remove = function () {
if (this.element.parentNode) {
this.element.parentNode.removeChild(this.element);
}
};
return Svg;
}());
exports.Svg = Svg;
;