Socket
Book a DemoInstallSign in
Socket

poly-bool

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poly-bool

Exact polygon boolean operations

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

polygon-boolean

A robust polygon Boolean library in under 20 lines of code! (Excluding dependencies) Work with any kind of polygon, results are accurate to machine precision, and under no circumstances will valid input ever crash or produce incorrect output.

Example

var polybool = require('polygon-boolean')

var a = [[[-1,-1], [-1,1], [1,1], [1,-1]]]
var b = [[[0, 0], [0,2], [2,2], [2,0]]]

console.log(polybool(a, b, 'sub'))

Output

[ [ [ 1, 1 ], [ 1, 0 ], [ 2, 0 ], [ 2, 2 ], [ 0, 2 ], [ 0, 1 ] ] ]

Install

npm i polygon-boolean

API

require('polygon-boolean')(a, b, op)

Computes a Boolean set operation between a and b

  • a,b are polygons represented by lists of loops of points
  • op is the operation to apply. Possible values include 'and, 'or', 'xor', 'sub', 'rsub'`

Returns A polygon encoding some boolean combination of the components of a and b

License

(c) 2015 Mikola Lysenko. MIT License

Keywords

polygon

FAQs

Package last updated on 01 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts