src/context.js
function calcSortedIntersections(lines,y) {
    var xlist = [];
    for(var i=0; i<lines.length; i++) {
        var A = lines[i].start;
        var B = lines[i].end;
        if(A.y<y && B.y>=y || B.y<y && A.y>=y) {
            var xval = A.x + (y-A.y) / (B.y-A.y) * (B.x-A.x);
            xlist.push(xval);
        }
    }
    return xlist.sort(function(a,b) {  return a-b; });
}
function calcSortedIntersections(lines,y) {
    var xlist = [];
    for(var i=0; i<lines.length; i++) {
        var A = lines[i].start;
        var B = lines[i].end;
        if(A.y<y && B.y>=y || B.y<y && A.y>=y) {
            var xval = A.x + (y-A.y) / (B.y-A.y) * (B.x-A.x);
            xlist.push(xval);
        }
    }
    return xlist.sort(function(a,b) {  return a-b; });
}
function calcSortedIntersections ( lines , y ) { var xlist = [ ] ; for ( var i = 0 ; i < lines . length ; i ++ ) { var A = lines [ i ] . start ; var B = lines [ i ] . end ; if ( A . y < y && B . y >= y || B . y < y && A . y >= y ) { var xval = A . x + ( y - A . y ) / ( B . y - A . y ) * ( B . x - A . x ) ; xlist . push ( xval ) ; } } return xlist . sort ( function ( a , b ) { return a - b ; } ) ; }
Calculate Sorted Intersections

Adopted from http://alienryderflex.com/polygon

@see http://alienryderflex.com/polygon

@param {Array} lines An {@link Array} of Lines
@param {number} y

@ignore

@returns {Array}
Calculate Sorted Intersections