UNPKG

game-of-life-d3-boots

Version:

conway's game of life with a small bit of interactivity. an observer can click on a square to "infect" it (turn its living color to red). then, whenever that cell is live, it will "infect" its living neighbors

22 lines (20 loc) 498 B
module.exports = Vector; /** * A set of (x,y) coordinates in space. * @constructor * @param {number} x - x-coordinate * @param {number} y - y-coordinate */ function Vector(x, y) { this.x = x; this.y = y; } /** * Vector addition. Returns a new Vector that is the result of adding another Vector to the calling Vector object. * @method * @param {Vector} vector * @returns {Vector} */ Vector.prototype.plus = function plus(w) { return new Vector(this.x + w.x, this.y + w.y); };