JavaScript library that builds concave hull by a set of points
Hull.js is a JavaScript library that builds concave hull by a set of points.
See live examples here.
var points = [ [236, 126], [234, 115], [238, 109], [247, 102], ... ];
hull(points, 50); // returns points of the hull (in clockwise order)
[[x1, y1], [x2, y2], ..., [xn, yn]]
.1
- thin shape. Infinity
- convex hull. By default 20
.['.lng', '.lat']
if you have {lng: x, lat: y}
points. By default you can use [x, y]
points.Let's see step by step what happens when you call hull()
function:
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.
This library is hosted on GitHub Packages. To install it using NPM, you should have an .npmrc
file next to your package.json
with the following content:
@andriiheonia:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
And include hull
library as a dependency to your package.json
:
"@andriiheonia/hull": "^1.0.8"
For more details see GitHub instruction.
If for some reason you don't want to use GitHub Packages, you can use GitHub URL as a dependency, e.g.:
"@andriiheonia/hull": "andriiheonia/hull"
npm install # install dependencies
npm test # build dist file and run tests
npm run watch # watch ./src dir and rebuild dist file
You can find TypeScript type definitions in src
folder.
If you want to get involved with Hull.js development, just use github flow and feel free to contribute!
concavity
adjustment based on density.This release squashes former 1.0.3, 1.0.4, 1.0.5 and 1.0.6 releases into one reasonable commit with the following minor changes:
concavity
number) + some refactoring.{x: 10, y: 10}
and {lat: 52, lng: 82}
.