$ npm install lineclip
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]]]
points
— an array of [x, y]
pointsbbox
— a bounding box as [xmin, ymin, xmax, ymax]
result
— an array to append the results toReturns an array of clipped lines.
lineclip
is an alias to lineclip.polyline
.
Returns a clipped polygon.
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
[[]]
instead of []
.lineclip.polygon
).© 2010 - cnpmjs.org x YWFE | Home | YWFE