Modernize voronoi (#557)

Voronoi.js modernization by @SaltyQuetzals
* Changed Voronoi generator to be more class-based, added mediocre documentation.
* Added spaces to JSDoc links so text doesn't bleed into URL
* Found delaunator docs, very helpful in writing function documentation.
This commit is contained in:
Gabriel Britain 2021-02-04 08:51:29 -05:00 committed by GitHub
parent ed33864e07
commit 7b91151179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 123 additions and 69 deletions

View file

@ -12,7 +12,7 @@ document.title += " v" + version;
// Switches to disable/enable logging features
const INFO = 0;
const TIME = 0;
const TIME = 1;
const WARN = 1;
const ERROR = 1;
@ -610,7 +610,7 @@ function calculateVoronoi(graph, points) {
TIME && console.timeEnd("calculateDelaunay");
TIME && console.time("calculateVoronoi");
const voronoi = Voronoi(delaunay, allPoints, n);
const voronoi = new Voronoi(delaunay, allPoints, n);
graph.cells = voronoi.cells;
graph.cells.i = n < 65535 ? Uint16Array.from(d3.range(n)) : Uint32Array.from(d3.range(n)); // array of indexes
graph.vertices = voronoi.vertices;