npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gpc.js

v1.0.1

Published

A port of General Polygon Clipper

Downloads

3

Readme

GPC.js

A Port of the General Polygon Clipper library by the University of Manchester (http://www.cs.man.ac.uk/~toby/gpc/)

This module exports a single data type, Polygon, which can represent euclidean polygons of arbitrary complexity and perform binary set operations on them. Polygons are not directly constructable with new; new Polygon instances can be created with Polygon.fromPoints() or Polygon.fromVertices(), described below. Polygons are also immutable; all geometric operations return new Polygon instances as their results.

API

  • readonly isEmpty: boolean Indicates whether the polygon has non-zero area.
  • readonly isHole: boolean Indicates whether the polygon has negative area / is the boundary of a hole in a complex polygon.
  • bounds: { minx: number, maxx: number, miny: number, maxy: number } Returns the minimal coordinate-aligned rectangular bounding box for the polygon.
  • equals(obj: Polygon): boolean Determine whether two polygons have the same vertex set, including the categorization of vertices as belonging to positive boundaries or holes.
  • toVertices(): { bounds: { x: number, y: number }[][], holes: { x: number, y: number }[][] } Exports a description of the polygon as a set of vanilla JS objects. bounds is a list of lists of vertices representing the boundaries of positive-area sub-polygons, while holes is a list of lists of vertices representing the boundaries of interior holes.
  • static fromVertices({ bounds, holes }: { bounds: Vertex[][], holes: Vertex[][] }): Polygon Creates a complex polygon from an object of the same shape as returned by toVertices(). A Vertex can be an onject of the form { x: number, y: number } or a two-element array of [x, y].
  • static fromPoints(points: Vertex[]): Polygon Creates a simple polygon from a list of vertices, where a Vertex can be an onject of the form { x: number, y: number } or a two-element array of [x, y].
  • static intersection(...p: Polygon[]): Polygon Computes the geometric set intersection of a list of Polygons.
  • intersection(...p: Polygon[]): Polygon Computes the geometric set intersection of this with a list of additional Polygons.
  • static union(...p: Polygon[]): Polygon Computes the geometric set union of a list of Polygons.
  • union(...p: Polygon[]): Polygon Computes the geometric set union of this with a list of additional Polygons.
  • static xor(...p: Polygon[]): Polygon Computes the geometric symmetric set difference of a list of Polygons.
  • xor(...p: Polygon[]): Polygon Computes the geometric symmetric set difference of this with a list of additional Polygons.
  • static difference(first: Polygon, ...p: Polygon[]): Polygon Computes the geometric set difference of the first Polygon with a list of additional Polygons.
  • difference(...p: Polygon[]): Polygon Computes the geometric set difference of this with a list of additional Polygons.