Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (28 sloc) 1.34 KB

node-clipper

A node.js wrapper for the Clipper polygon clipper (and helper) library

Project State

Please note that this very light wrapper was built for an internal project, so almost no effort has gone on to documentation of 1-to-1 binding of functions we haven't needed.

But we would be interested in expanding it over time and will happily accept pull requests to expand the bindings.

Bindings

Offset

See the clipper documentation for Offset) in order to get an idea of how this is used.

clipper = require('../build/Release/clipper')

/*a
  ## Offset
  * arguments: flattened_coordinate_path, offset
  * where: offset can be positive or negative (negative will go inside the polygon, positive will expand outside)
*/
flattened_coordinate_path = [0, 0, 0, 10, 10, 10, 10, 0]

// A negative offset gets an offset inside our Polygon:
inner_highlight_path = clipper.offset(flattened_coordinate_path, -2)
console.log(inner_highlight_path)
// returns [ [ 2, 2, 8, 2, 8, 8, 2, 8 ] ]

// A positive offset gets an offset outside our Polygon:
outter_highlight_path = clipper.offset(flattened_coordinate_path, 2)
console.log(outter_highlight_path)
// returns [ [ -2, 12, -2, -2, 12, -2, 12, 12 ] ]