Home

Awesome

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

Examples

See live examples <a target="_blank" href="http://andriiheonia.github.io/hull/">here</a>.

Usage

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

Params

How it works

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

<ol> <li> <div>Hull.js takes your source points of the shape:</div> <div><img src="https://raw.githubusercontent.com/AndriiHeonia/hull/master/readme-imgs/0.png" /></div> </li> <li> <div>Builds convex hull:</div> <div><img src="https://raw.githubusercontent.com/AndriiHeonia/hull/master/readme-imgs/1.png" /></div> </li> <li> <div>After that, the edges flex inward (according to the `concavity` param). For example:</div> <div> <img src="https://raw.githubusercontent.com/AndriiHeonia/hull/master/readme-imgs/2_1.png" /> `concavity = 80`<br/> <img src="https://raw.githubusercontent.com/AndriiHeonia/hull/master/readme-imgs/2_2.png" /> `concavity = 40`<br/> <img src="https://raw.githubusercontent.com/AndriiHeonia/hull/master/readme-imgs/2_3.png" /> `concavity = 20` </div> </li> </ol>

Limitations

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

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

NPM package

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

"dependencies": {
    "hull.js": "andriiheonia/hull"
}

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 <a href="https://docs.github.com/en/get-started/using-github/github-flow" target="_blank">GitHub flow</a>.

To-do

Related papers

Changelog

<details> <summary>Expand</summary>

1.0.9 - 29.10.2024

1.0.8 - 31.05.2024

1.0.7 - 03.05.2024

Squashes few previous small releases into one bigger commit with the following minor changes:

1.0.2 — 26.09.2021

1.0.1 — 24.10.2020

1.0.0 — 28.06.2019

0.2.11 — 05.05.2019

0.2.10 — 04.09.2016

0.2.9 — 28.07.2016

0.2.8 — 01.04.2016

0.2.7 — 01.05.2015

0.2.6 — 01.05.2015

0.2.5 — 01.05.2015

0.2.4 — 23.03.2015

0.2.3 — 04.02.2015

0.2.2 — 04.02.2015

0.2.1 — 21.10.2014

0.2.0 — 20.10.2014

0.1.0 — 06.09.2014

</details>