Skip to content

Commit

Permalink
Static from.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock authored and mourner committed Feb 2, 2020
1 parent 75edf35 commit 778acc9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/delaunay.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ function jitter(x, y, r) {
return [x + Math.sin(x + y) * r, y + Math.cos(x - y) * r];
}

export default Object.assign(class Delaunay {
export default class Delaunay {
static from(points, fx = pointX, fy = pointY, that) {
return new Delaunay("length" in points
? flatArray(points, fx, fy, that)
: Float64Array.from(flatIterable(points, fx, fy, that)));
}
constructor(points) {
this._delaunator = new Delaunator(points);
this.inedges = new Int32Array(points.length / 2);
Expand Down Expand Up @@ -216,13 +221,7 @@ export default Object.assign(class Delaunay {
this.renderTriangle(i, polygon);
return polygon.value();
}
}, {
from(points, fx = pointX, fy = pointY, that) {
return new Delaunay("length" in points
? flatArray(points, fx, fy, that)
: Float64Array.from(flatIterable(points, fx, fy, that)));
}
});
}

function flatArray(points, fx, fy, that) {
const n = points.length;
Expand Down

0 comments on commit 778acc9

Please sign in to comment.