lib/layout/ManhattanLayout.js
function getBendpoints(a, b, directions) {
  directions = directions || 'h:h';

  if (!isValidDirections(directions)) {
    throw new Error(
      'unknown directions: <' + directions + '>: ' +
      'must be specified as <start>:<end> ' +
      'with start/end in { h,v,t,r,b,l }'
    );
  }

  // compute explicit directions, involving trbl dockings
  // using a three segmented layouting algorithm
  if (isExplicitDirections(directions)) {
    var startSegment = getStartSegment(a, b, directions),
        endSegment = getEndSegment(a, b, directions),
        midSegment = getMidSegment(startSegment, endSegment);

    return [].concat(
      startSegment.waypoints,
      midSegment.waypoints,
      endSegment.waypoints
    );
  }

  // handle simple [hv]:[hv] cases that can be easily computed
  return getSimpleBendpoints(a, b, directions);
}
function getBendpoints(a, b, directions) {
  directions = directions || 'h:h';

  if (!isValidDirections(directions)) {
    throw new Error(
      'unknown directions: <' + directions + '>: ' +
      'must be specified as <start>:<end> ' +
      'with start/end in { h,v,t,r,b,l }'
    );
  }

  // compute explicit directions, involving trbl dockings
  // using a three segmented layouting algorithm
  if (isExplicitDirections(directions)) {
    var startSegment = getStartSegment(a, b, directions),
        endSegment = getEndSegment(a, b, directions),
        midSegment = getMidSegment(startSegment, endSegment);

    return [].concat(
      startSegment.waypoints,
      midSegment.waypoints,
      endSegment.waypoints
    );
  }

  // handle simple [hv]:[hv] cases that can be easily computed
  return getSimpleBendpoints(a, b, directions);
}
function getBendpoints ( a , b , directions ) { directions = directions || 'h:h' ; if ( ! isValidDirections ( directions ) ) { throw new Error ( 'unknown directions: <' + directions + '>: ' + 'must be specified as <start>:<end> ' + 'with start/end in { h,v,t,r,b,l }' ) ; } // compute explicit directions, involving trbl dockings // using a three segmented layouting algorithm if ( isExplicitDirections ( directions ) ) { var startSegment = getStartSegment ( a , b , directions ) , endSegment = getEndSegment ( a , b , directions ) , midSegment = getMidSegment ( startSegment , endSegment ) ; return [ ] . concat ( startSegment . waypoints , midSegment . waypoints , endSegment . waypoints ) ; } // handle simple [hv]:[hv] cases that can be easily computed return getSimpleBendpoints ( a , b , directions ) ; }
Returns the mid points for a manhattan connection between two points.

@example h:h (horizontal:horizontal)

[a]----[x]
|
[x]----[b]

@example h:v (horizontal:vertical)

[a]----[x]
|
[b]

@example h:r (horizontal:right)

[a]----[x]
|
[b]-[x]

@param  {Point} a
@param  {Point} b
@param  {String} directions

@return {Array<Point>}
Returns the mid points for a manhattan connection between two points .