Home

Awesome

lineclip

Build Status Coverage Status

A very fast JavaScript library for clipping polylines and polygons by a bounding box.

lineclip(
    [[-10, 10], [10, 10], [10, -10]], // line
    [0, 0, 20, 20]); // bbox
// returns [[[0, 10], [10, 10], [10, 0]]]

API

lineclip.polyline(points, bbox[, result])

Returns an array of clipped lines.

lineclip is an alias to lineclip.polyline.

lineclip.polygon(points, bbox)

Returns a clipped polygon.

Install

Install with NPM:

npm install lineclip

To build a browser-compatible version, clone the repository locally, then run:

npm install -g browserify
browserify -s lineclip index.js > lineclip.js

Changelog

1.1.5 (Sep 23, 2015)

1.1.4 (Sep 22, 2015)

1.1.3 (Sep 12, 2015)

1.1.2 (Sep 11, 2015)

1.1.1 (Sep 11, 2015)

1.1.0 (Sep 11, 2015)

1.0.1 (Sep 11, 2015)

1.0.0 (Sep 8, 2015)