UNPKG

alecmce-primitivesjs

Version:

A small library for visualizing the prime factor decomposition of numbers.

35 lines (34 loc) 1.26 kB
"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 ANGLE = Math.PI * 2 / 3; var DIVISOR = Math.cos(Math.PI / 6); var Three = (function () { function Three(drawCircle, color, padding, child) { this.drawCircle = drawCircle; this.color = color; this.padding = padding; this.child = child; this.offset = (child.radius + padding / 2) / DIVISOR; this.radius = this.offset + child.radius + padding; } Three.prototype.draw = function (config) { var container = this.drawCircle(__assign({}, config, { radius: this.radius, color: this.color, stroke: true })); for (var i = 0; i < 3; ++i) { var angle = ANGLE * i; var x = this.offset * Math.sin(angle); var y = -this.offset * Math.cos(angle); this.child.draw({ container: container, x: x, y: y }); } return container; }; return Three; }()); exports.Three = Three;