@tdurtschi/bug
Version:
Bug is a simulation that models a weevil walking around in an HTML canvas.
49 lines • 1.66 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__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;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var Victor = require("victor");
var TreeBuilder = (function () {
function TreeBuilder() {
var _this = this;
this.left = function (left) {
_this.leftBranch = Object.assign({}, TreeBuilder.defaultNode, left);
return _this;
};
this.right = function (right) {
_this.rightBranch = Object.assign({}, TreeBuilder.defaultNode, right);
return _this;
};
this.node = function (x, y) {
_this.nodeVector = new Victor(x, y);
return _this;
};
this.build = function () {
var tree = __assign(__assign({}, TreeBuilder.defaultNode), { node: _this.nodeVector || new Victor(0, 0), left: _this.leftBranch, right: _this.rightBranch });
if (tree.left)
tree.left.parent = tree;
if (tree.right)
tree.right.parent = tree;
return tree;
};
}
TreeBuilder.defaultNode = {
depth: 0,
parent: null,
left: null,
right: null,
node: new Victor(0, 0)
};
return TreeBuilder;
}());
exports.default = TreeBuilder;
//# sourceMappingURL=treeBuilder.js.map