alecmce-primitivesjs
Version:
A small library for visualizing the prime factor decomposition of numbers.
34 lines (33 loc) • 1.39 kB
JavaScript
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var SCALAR = Math.sqrt(2) / 2;
var Five = (function () {
function Five(drawCircle, color, padding, child) {
this.drawCircle = drawCircle;
this.color = color;
this.padding = padding;
this.child = child;
this.offset = 2 * child.radius + padding;
this.radius = this.offset + child.radius + padding;
this.delta = SCALAR * this.offset;
}
Five.prototype.draw = function (config) {
var container = this.drawCircle(__assign({}, config, { radius: this.radius, color: this.color, stroke: true }));
this.child.draw({ container: container, x: 0, y: 0 });
this.child.draw({ container: container, x: +this.delta, y: +this.delta });
this.child.draw({ container: container, x: +this.delta, y: -this.delta });
this.child.draw({ container: container, x: -this.delta, y: -this.delta });
this.child.draw({ container: container, x: -this.delta, y: +this.delta });
return container;
};
return Five;
}());
exports.Five = Five;