polygon.clip
Implementation of the Greiner-Kai "efficient clipping of arbitrary polygons" paper
install
npm install poygon.clip
use
signature
Polygon#clip(clippingPolygon, mode)
Where mode is 'difference'
or 'union'
example
Lets clip two squares
var Polygon = Vec2 = ; var subject = ; var clip = ; // union is an array of Polygonsvar union = subjectclipclip 'union'; console;
In this case, there will only be one polygon in the union
array, and it will define the upper corner of the subject polygon
[[100, 90], [100,100], [90, 100], [90,90]]
license
MIT