lib/walker.js
function walk(start, end, fn) {
  this.start = new Vec2(start);
  this.end = new Vec2(end);
  this.direction = calcDirection(this.start, this.end);

  // positive deltas go right and down
  this.cellStepDelta = {
    horizontal: 0,
    vertical: 0
  }

  this.tMax = new Vec2();
  this.tDelta = new Vec2();

  this.currentCoord = positionToCoordinate(this.start, this.cellWidth, this.cellHeight);
  this.endCoord = positionToCoordinate(this.end, this.cellWidth, this.cellHeight);

  this.initStepMath();

  while (!this.isPastEnd()) {
    fn(coord(this.currentCoord));

    if (this.shouldMoveHorizontally()) {
      this.moveHorizontally();
    } else {
      this.moveVertically();
    }
  }
}
function walk(start, end, fn) {
  this.start = new Vec2(start);
  this.end = new Vec2(end);
  this.direction = calcDirection(this.start, this.end);

  // positive deltas go right and down
  this.cellStepDelta = {
    horizontal: 0,
    vertical: 0
  }

  this.tMax = new Vec2();
  this.tDelta = new Vec2();

  this.currentCoord = positionToCoordinate(this.start, this.cellWidth, this.cellHeight);
  this.endCoord = positionToCoordinate(this.end, this.cellWidth, this.cellHeight);

  this.initStepMath();

  while (!this.isPastEnd()) {
    fn(coord(this.currentCoord));

    if (this.shouldMoveHorizontally()) {
      this.moveHorizontally();
    } else {
      this.moveVertically();
    }
  }
}
function walk ( start , end , fn ) { this . start = new Vec2 ( start ) ; this . end = new Vec2 ( end ) ; this . direction = calcDirection ( this . start , this . end ) ; // positive deltas go right and down this . cellStepDelta = { horizontal : 0 , vertical : 0 } this . tMax = new Vec2 ( ) ; this . tDelta = new Vec2 ( ) ; this . currentCoord = positionToCoordinate ( this . start , this . cellWidth , this . cellHeight ) ; this . endCoord = positionToCoordinate ( this . end , this . cellWidth , this . cellHeight ) ; this . initStepMath ( ) ; while ( ! this . isPastEnd ( ) ) { fn ( coord ( this . currentCoord ) ) ; if ( this . shouldMoveHorizontally ( ) ) { this . moveHorizontally ( ) ; } else { this . moveVertically ( ) ; } } }
Walk along a line through the grid.

@param {object} start - Start point of line, object with x/y properties.
@param {object} end - End point of line, object with x/y properties.
@param {function} fn - Callback to be invoked *synchronously* for each cell
visited with grid coordinate
{column: number, row: number} as the lone param.
Walk along a line through the grid .