motion-and-tween
Version:
Motion and Tween
37 lines (36 loc) • 834 B
JavaScript
var Vector = /** @class */ (function () {
function Vector(x, y) {
if (x) {
this.x = x;
}
else {
this.x = 0;
}
if (y) {
this.y = y;
}
else {
this.y = 0;
}
}
Vector.prototype.toString = function () {
return "Vector[".concat(this.x, ",").concat(this.y, "]");
};
Vector.prototype.add = function (vector) {
var newX = 0;
var newY = 0;
if (this.x && vector.x) {
newX = this.x + vector.x;
}
if (this.y && vector.y) {
newY = this.y + vector.y;
}
return new Vector(newX, newY);
};
Vector.add = function (v1, v2) {
return v1.add(v2);
};
return Vector;
}());
export { Vector };
export default Vector;