New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

polybooljs

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polybooljs

Boolean operations on polygons (union, intersection, difference, xor)

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
225K
increased by4.71%
Maintainers
1
Weekly downloads
 
Created

What is polybooljs?

PolyBoolJS is a JavaScript library for performing boolean operations on polygons. It allows you to combine, subtract, intersect, and perform other operations on polygons, making it useful for computational geometry tasks.

What are polybooljs's main functionalities?

Union

This feature allows you to combine two polygons into one. The code sample demonstrates how to create two polygons and then combine them using the union operation.

const PolyBool = require('polybooljs');
const poly1 = { regions: [[[0, 0], [100, 0], [100, 100], [0, 100]]], inverted: false };
const poly2 = { regions: [[[50, 50], [150, 50], [150, 150], [50, 150]]], inverted: false };
const union = PolyBool.union(poly1, poly2);
console.log(union);

Intersect

This feature allows you to find the intersection of two polygons. The code sample demonstrates how to create two polygons and then find their intersection.

const PolyBool = require('polybooljs');
const poly1 = { regions: [[[0, 0], [100, 0], [100, 100], [0, 100]]], inverted: false };
const poly2 = { regions: [[[50, 50], [150, 50], [150, 150], [50, 150]]], inverted: false };
const intersect = PolyBool.intersect(poly1, poly2);
console.log(intersect);

Difference

This feature allows you to subtract one polygon from another. The code sample demonstrates how to create two polygons and then subtract the second polygon from the first.

const PolyBool = require('polybooljs');
const poly1 = { regions: [[[0, 0], [100, 0], [100, 100], [0, 100]]], inverted: false };
const poly2 = { regions: [[[50, 50], [150, 50], [150, 150], [50, 150]]], inverted: false };
const difference = PolyBool.difference(poly1, poly2);
console.log(difference);

XOR

This feature allows you to perform an exclusive OR (XOR) operation on two polygons. The code sample demonstrates how to create two polygons and then perform the XOR operation on them.

const PolyBool = require('polybooljs');
const poly1 = { regions: [[[0, 0], [100, 0], [100, 100], [0, 100]]], inverted: false };
const poly2 = { regions: [[[50, 50], [150, 50], [150, 150], [50, 150]]], inverted: false };
const xor = PolyBool.xor(poly1, poly2);
console.log(xor);

Other packages similar to polybooljs

Keywords

FAQs

Package last updated on 18 Mar 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc