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

hull-js.js

v1.0.10

Published

JavaScript library that builds concave hull (shape) by set of points

Downloads

73

Readme

Hull.js is a JavaScript library that builds concave hull by set of points.

Table of contents

Examples

See live examples here.

Usage

var points = [ [236, 126], [234, 115], [238, 109], [247, 102], ... ];
hull(points, 50); // returns points of the hull (in clockwise order)

Params

  • 1st param - array of coordinates in format: [[x1, y1], [x2, y2], ..., [xn, yn]].
  • 2nd param - concavity. 1 - thin shape. Infinity - convex hull. By default 20.
  • 3rd param - points format. For example: ['.lng', '.lat'] if you have {lng: x, lat: y} points. By default you can use [x, y] points.

How it works

Let's see step by step what happens when you call hull() function:

Limitations

This library relies on ES6. The ES6 features used are:

  • new Set(null), Set#add, Set#has.
  • let, const.
  • Math.trunc (if available).

You may use polyfills for Set and compile with babel to continue to support old browsers.

NPM package

Since version 1.0.7 this library is not hosted on npmjs.com, but you can use GitHub URL as a dependency, e.g.:

"dependencies": {
    "hull.js": "andriiheonia/hull#semver:^1.0.10"
}

Development

npm install     # install dependencies
npm test        # build dist file and run tests
npm run watch   # watch ./src dir and rebuild dist file

TypeScript

You can find TypeScript type definitions in src folder.

Contribute

If you want to contribute, just follow GitHub flow.

To-do

  • Think about polygons with holes.
  • Think about automatic concavity adjustment based on density.

Related papers

  • Implementation of a fast and efficient concave hull algorithm.
  • Computational Geometry: Convex Hulls.
  • Andrew's monotone chain convex hull algorithm.
  • Line Segment Intersection Algorithm.
  • Game Math: "Cross Product" of 2D Vectors.
  • Угол между двумя векторами.
  • Когда не нужна тригонометрия.

Changelog

1.0.10 - 07.11.2024

  • Fix vulnerability issue.

1.0.9 - 29.10.2024

  • Update NPM dependencies to address vulnerability issues.

1.0.8 - 31.05.2024

1.0.7 - 03.05.2024

Squash previous tiny releases into one bigger commit with the following minor changes:

  • Fix issue with formatting when users pass less than 4 points as an input.
  • Remove bower and travis files as they are deprecated.

1.0.2 — 26.09.2021

  • Clean up .gitignore.
  • Add "debug" folder to .npmignore to reduce tarball size.

1.0.1 — 24.10.2020

  • Fix that avoids hitting stack size limit on large arrays.

1.0.0 — 28.06.2019

  • Change language level to ES6.
  • Performance improvements.

0.2.11 — 05.05.2019

  • Minor changes: return the first point as the last point when fewer than 4 unique points are provided.

0.2.10 — 04.09.2016

  • Minor changes: fix missing "var" declaration.

0.2.9 — 28.07.2016

  • Fix modification of the initial array.
  • Add filtration of the duplicates.

0.2.8 — 01.04.2016

  • Add edgeSkipList to increase performance of the highly accurate shapes (with the small concavity number) + some refactoring.

0.2.7 — 01.05.2015

  • Minor changes: fix bower.json.

0.2.6 — 01.05.2015

  • Minor changes: fix bower.json.

0.2.5 — 01.05.2015

  • Minor changes: Bower support.

0.2.4 — 23.03.2015

  • Minor changes: copyrights.

0.2.3 — 04.02.2015

  • Minor changes: readme, package.json.

0.2.2 — 04.02.2015

  • Configurable point format, now you can use points like {x: 10, y: 10} and {lat: 52, lng: 82}.

0.2.1 — 21.10.2014

  • Minor changes: doc, package.json, etc.

0.2.0 — 20.10.2014

  • Second version with better performance inspired by this article.

0.1.0 — 06.09.2014

  • First version based on Delaunay triangulation.