index.js
function (start, stop, line) {
        var sum = 0;
        var slice = [];

        for (var i = 0; i < line.length - 1; i++) {
            var p0 = line[i];
            var p1 = line[i + 1];
            var d = this.distance(p0, p1);

            sum += d;

            if (sum > start && slice.length === 0) {
                slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
            }

            if (sum >= stop) {
                slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
                return slice;
            }

            if (sum > start) slice.push(p1);
        }

        return slice;
    }
function (start, stop, line) {
        var sum = 0;
        var slice = [];

        for (var i = 0; i < line.length - 1; i++) {
            var p0 = line[i];
            var p1 = line[i + 1];
            var d = this.distance(p0, p1);

            sum += d;

            if (sum > start && slice.length === 0) {
                slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
            }

            if (sum >= stop) {
                slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
                return slice;
            }

            if (sum > start) slice.push(p1);
        }

        return slice;
    }
function ( start , stop , line ) { var sum = 0 ; var slice = [ ] ; for ( var i = 0 ; i < line . length - 1 ; i ++ ) { var p0 = line [ i ] ; var p1 = line [ i + 1 ] ; var d = this . distance ( p0 , p1 ) ; sum += d ; if ( sum > start && slice . length === 0 ) { slice . push ( interpolate ( p0 , p1 , ( start - ( sum - d ) ) / d ) ) ; } if ( sum >= stop ) { slice . push ( interpolate ( p0 , p1 , ( stop - ( sum - d ) ) / d ) ) ; return slice ; } if ( sum > start ) slice . push ( p1 ) ; } return slice ; }
Returns a part of the given line between the start and the stop points indicated by distance along the line.

@param {number} start distance
@param {number} stop distance
@param {Array<Array<number>>} line
@returns {Array<Array<number>>} line part of a line
@example
var line2 = ruler.lineSliceAlong(10, 20, line1);
//=line2
Returns a part of the given line between the start and the stop points indicated by distance along the line .