This package implements algorithm of equidistant offset of polygon. It relies on the flatten-js library and its polygon model, which is multi polygon comprised from a number of islands and holes. See this interactive notebook for more details.
Algorithm is based on the idea of morphological offset, when each edge of the polygon is mapped to its offset, and then boolean operation performed between original contour and offset edges. When offset value is positive, offset edges are unified with original contour, when negative - they are subtracted from original contour.
Follow me on Twitter @alex_bol_
npm install --save @flatten-js/polygon-offset
The package @flatten-js/core is peer dependency of this package and have to be installed separately:
npm install --save @flatten-js/core
let offsetPolygon =
// Create polygonlet shapes =;let polygon = ;polygon;// Apply polygon offsetlet offsetPolygon = polygon;
See Offset Polygon interactive notebook to explore this algorithm.