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

polyclip-ts

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyclip-ts

Apply boolean polygon clipping operations (intersection, union, difference, xor) to your Polygons & MultiPolygons.

  • 0.16.7
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is polyclip-ts?

The polyclip-ts package is a TypeScript library for performing polygon clipping operations. It allows you to perform boolean operations on polygons such as union, intersection, difference, and XOR. This is useful in computational geometry, computer graphics, and GIS applications.

What are polyclip-ts's main functionalities?

Union of Polygons

This feature allows you to compute the union of two or more polygons. The code sample demonstrates how to use the `union` function to combine two overlapping squares into a single polygon.

const { union } = require('polyclip-ts');
const polygon1 = [[0, 0], [2, 0], [2, 2], [0, 2]];
const polygon2 = [[1, 1], [3, 1], [3, 3], [1, 3]];
const result = union([polygon1, polygon2]);
console.log(result);

Intersection of Polygons

This feature allows you to find the intersection area of two polygons. The code sample shows how to use the `intersection` function to find the overlapping area of two squares.

const { intersection } = require('polyclip-ts');
const polygon1 = [[0, 0], [2, 0], [2, 2], [0, 2]];
const polygon2 = [[1, 1], [3, 1], [3, 3], [1, 3]];
const result = intersection([polygon1, polygon2]);
console.log(result);

Difference of Polygons

This feature allows you to compute the difference between two polygons. The code sample demonstrates how to use the `difference` function to subtract one square from another.

const { difference } = require('polyclip-ts');
const polygon1 = [[0, 0], [2, 0], [2, 2], [0, 2]];
const polygon2 = [[1, 1], [3, 1], [3, 3], [1, 3]];
const result = difference(polygon1, polygon2);
console.log(result);

XOR of Polygons

This feature allows you to compute the exclusive OR (XOR) of two polygons. The code sample shows how to use the `xor` function to find the non-overlapping areas of two squares.

const { xor } = require('polyclip-ts');
const polygon1 = [[0, 0], [2, 0], [2, 2], [0, 2]];
const polygon2 = [[1, 1], [3, 1], [3, 3], [1, 3]];
const result = xor([polygon1, polygon2]);
console.log(result);

Other packages similar to polyclip-ts

Keywords

FAQs

Package last updated on 24 Nov 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