victory-vendor 36.5.1 → 36.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/es/d3-voronoi.js +6 -0
- package/lib/d3-voronoi.js +6 -0
- package/lib-vendor/d3-voronoi/LICENSE +50 -0
- package/lib-vendor/d3-voronoi/src/Beach.js +197 -0
- package/lib-vendor/d3-voronoi/src/Cell.js +140 -0
- package/lib-vendor/d3-voronoi/src/Circle.js +84 -0
- package/lib-vendor/d3-voronoi/src/Diagram.js +162 -0
- package/lib-vendor/d3-voronoi/src/Edge.js +176 -0
- package/lib-vendor/d3-voronoi/src/RedBlackTree.js +261 -0
- package/lib-vendor/d3-voronoi/src/constant.js +12 -0
- package/lib-vendor/d3-voronoi/src/index.js +15 -0
- package/lib-vendor/d3-voronoi/src/point.js +15 -0
- package/lib-vendor/d3-voronoi/src/voronoi.js +63 -0
- package/package.json +130 -8
- package/LICENSE.txt +0 -30
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# victory-vendor
|
|
2
|
+
|
|
3
|
+
## 36.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update source code with minor lint-based improvements (see [#2236](https://github.com/FormidableLabs/victory/issues/2236)). ([#2403](https://github.com/FormidableLabs/victory/pull/2403))
|
|
8
|
+
|
|
9
|
+
## 36.5.3 and earlier
|
|
10
|
+
|
|
11
|
+
Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
|
package/es/d3-voronoi.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
// `victory-vendor/d3-voronoi` (CommonJS)
|
|
3
|
+
// See upstream license: https://github.com/d3/d3-voronoi/blob/main/LICENSE
|
|
4
|
+
//
|
|
5
|
+
// Our CommonJS package relies on transpiled vendor files in `lib-vendor/d3-voronoi`
|
|
6
|
+
module.exports = require("../lib-vendor/d3-voronoi/src/index.js");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Copyright 2010-2016 Mike Bostock
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
+
are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
* Neither the name of the author nor the names of contributors may be used to
|
|
15
|
+
endorse or promote products derived from this software without specific prior
|
|
16
|
+
written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
22
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
25
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
Copyright (C) 2010-2013 Raymond Hill
|
|
30
|
+
https://github.com/gorhill/Javascript-Voronoi
|
|
31
|
+
|
|
32
|
+
Licensed under The MIT License
|
|
33
|
+
http://en.wikipedia.org/wiki/MIT_License
|
|
34
|
+
|
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
36
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
37
|
+
the Software without restriction, including without limitation the rights to
|
|
38
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
39
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
40
|
+
subject to the following conditions:
|
|
41
|
+
|
|
42
|
+
The above copyright notice and this permission notice shall be included in all
|
|
43
|
+
copies or substantial portions of the Software.
|
|
44
|
+
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
46
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
47
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
48
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
49
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
50
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addBeach = addBeach;
|
|
7
|
+
exports.removeBeach = removeBeach;
|
|
8
|
+
|
|
9
|
+
var _RedBlackTree = require("./RedBlackTree");
|
|
10
|
+
|
|
11
|
+
var _Cell = require("./Cell");
|
|
12
|
+
|
|
13
|
+
var _Circle = require("./Circle");
|
|
14
|
+
|
|
15
|
+
var _Edge = require("./Edge");
|
|
16
|
+
|
|
17
|
+
var _Diagram = require("./Diagram");
|
|
18
|
+
|
|
19
|
+
var beachPool = [];
|
|
20
|
+
|
|
21
|
+
function Beach() {
|
|
22
|
+
(0, _RedBlackTree.RedBlackNode)(this);
|
|
23
|
+
this.edge = this.site = this.circle = null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function createBeach(site) {
|
|
27
|
+
var beach = beachPool.pop() || new Beach();
|
|
28
|
+
beach.site = site;
|
|
29
|
+
return beach;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function detachBeach(beach) {
|
|
33
|
+
(0, _Circle.detachCircle)(beach);
|
|
34
|
+
|
|
35
|
+
_Diagram.beaches.remove(beach);
|
|
36
|
+
|
|
37
|
+
beachPool.push(beach);
|
|
38
|
+
(0, _RedBlackTree.RedBlackNode)(beach);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function removeBeach(beach) {
|
|
42
|
+
var circle = beach.circle,
|
|
43
|
+
x = circle.x,
|
|
44
|
+
y = circle.cy,
|
|
45
|
+
vertex = [x, y],
|
|
46
|
+
previous = beach.P,
|
|
47
|
+
next = beach.N,
|
|
48
|
+
disappearing = [beach];
|
|
49
|
+
detachBeach(beach);
|
|
50
|
+
var lArc = previous;
|
|
51
|
+
|
|
52
|
+
while (lArc.circle && Math.abs(x - lArc.circle.x) < _Diagram.epsilon && Math.abs(y - lArc.circle.cy) < _Diagram.epsilon) {
|
|
53
|
+
previous = lArc.P;
|
|
54
|
+
disappearing.unshift(lArc);
|
|
55
|
+
detachBeach(lArc);
|
|
56
|
+
lArc = previous;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
disappearing.unshift(lArc);
|
|
60
|
+
(0, _Circle.detachCircle)(lArc);
|
|
61
|
+
var rArc = next;
|
|
62
|
+
|
|
63
|
+
while (rArc.circle && Math.abs(x - rArc.circle.x) < _Diagram.epsilon && Math.abs(y - rArc.circle.cy) < _Diagram.epsilon) {
|
|
64
|
+
next = rArc.N;
|
|
65
|
+
disappearing.push(rArc);
|
|
66
|
+
detachBeach(rArc);
|
|
67
|
+
rArc = next;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
disappearing.push(rArc);
|
|
71
|
+
(0, _Circle.detachCircle)(rArc);
|
|
72
|
+
var nArcs = disappearing.length,
|
|
73
|
+
iArc;
|
|
74
|
+
|
|
75
|
+
for (iArc = 1; iArc < nArcs; ++iArc) {
|
|
76
|
+
rArc = disappearing[iArc];
|
|
77
|
+
lArc = disappearing[iArc - 1];
|
|
78
|
+
(0, _Edge.setEdgeEnd)(rArc.edge, lArc.site, rArc.site, vertex);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
lArc = disappearing[0];
|
|
82
|
+
rArc = disappearing[nArcs - 1];
|
|
83
|
+
rArc.edge = (0, _Edge.createEdge)(lArc.site, rArc.site, null, vertex);
|
|
84
|
+
(0, _Circle.attachCircle)(lArc);
|
|
85
|
+
(0, _Circle.attachCircle)(rArc);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function addBeach(site) {
|
|
89
|
+
var x = site[0],
|
|
90
|
+
directrix = site[1],
|
|
91
|
+
lArc,
|
|
92
|
+
rArc,
|
|
93
|
+
dxl,
|
|
94
|
+
dxr,
|
|
95
|
+
node = _Diagram.beaches._;
|
|
96
|
+
|
|
97
|
+
while (node) {
|
|
98
|
+
dxl = leftBreakPoint(node, directrix) - x;
|
|
99
|
+
if (dxl > _Diagram.epsilon) node = node.L;else {
|
|
100
|
+
dxr = x - rightBreakPoint(node, directrix);
|
|
101
|
+
|
|
102
|
+
if (dxr > _Diagram.epsilon) {
|
|
103
|
+
if (!node.R) {
|
|
104
|
+
lArc = node;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
node = node.R;
|
|
109
|
+
} else {
|
|
110
|
+
if (dxl > -_Diagram.epsilon) {
|
|
111
|
+
lArc = node.P;
|
|
112
|
+
rArc = node;
|
|
113
|
+
} else if (dxr > -_Diagram.epsilon) {
|
|
114
|
+
lArc = node;
|
|
115
|
+
rArc = node.N;
|
|
116
|
+
} else {
|
|
117
|
+
lArc = rArc = node;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
(0, _Cell.createCell)(site);
|
|
126
|
+
var newArc = createBeach(site);
|
|
127
|
+
|
|
128
|
+
_Diagram.beaches.insert(lArc, newArc);
|
|
129
|
+
|
|
130
|
+
if (!lArc && !rArc) return;
|
|
131
|
+
|
|
132
|
+
if (lArc === rArc) {
|
|
133
|
+
(0, _Circle.detachCircle)(lArc);
|
|
134
|
+
rArc = createBeach(lArc.site);
|
|
135
|
+
|
|
136
|
+
_Diagram.beaches.insert(newArc, rArc);
|
|
137
|
+
|
|
138
|
+
newArc.edge = rArc.edge = (0, _Edge.createEdge)(lArc.site, newArc.site);
|
|
139
|
+
(0, _Circle.attachCircle)(lArc);
|
|
140
|
+
(0, _Circle.attachCircle)(rArc);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (!rArc) {
|
|
145
|
+
// && lArc
|
|
146
|
+
newArc.edge = (0, _Edge.createEdge)(lArc.site, newArc.site);
|
|
147
|
+
return;
|
|
148
|
+
} // else lArc !== rArc
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
(0, _Circle.detachCircle)(lArc);
|
|
152
|
+
(0, _Circle.detachCircle)(rArc);
|
|
153
|
+
var lSite = lArc.site,
|
|
154
|
+
ax = lSite[0],
|
|
155
|
+
ay = lSite[1],
|
|
156
|
+
bx = site[0] - ax,
|
|
157
|
+
by = site[1] - ay,
|
|
158
|
+
rSite = rArc.site,
|
|
159
|
+
cx = rSite[0] - ax,
|
|
160
|
+
cy = rSite[1] - ay,
|
|
161
|
+
d = 2 * (bx * cy - by * cx),
|
|
162
|
+
hb = bx * bx + by * by,
|
|
163
|
+
hc = cx * cx + cy * cy,
|
|
164
|
+
vertex = [(cy * hb - by * hc) / d + ax, (bx * hc - cx * hb) / d + ay];
|
|
165
|
+
(0, _Edge.setEdgeEnd)(rArc.edge, lSite, rSite, vertex);
|
|
166
|
+
newArc.edge = (0, _Edge.createEdge)(lSite, site, null, vertex);
|
|
167
|
+
rArc.edge = (0, _Edge.createEdge)(site, rSite, null, vertex);
|
|
168
|
+
(0, _Circle.attachCircle)(lArc);
|
|
169
|
+
(0, _Circle.attachCircle)(rArc);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function leftBreakPoint(arc, directrix) {
|
|
173
|
+
var site = arc.site,
|
|
174
|
+
rfocx = site[0],
|
|
175
|
+
rfocy = site[1],
|
|
176
|
+
pby2 = rfocy - directrix;
|
|
177
|
+
if (!pby2) return rfocx;
|
|
178
|
+
var lArc = arc.P;
|
|
179
|
+
if (!lArc) return -Infinity;
|
|
180
|
+
site = lArc.site;
|
|
181
|
+
var lfocx = site[0],
|
|
182
|
+
lfocy = site[1],
|
|
183
|
+
plby2 = lfocy - directrix;
|
|
184
|
+
if (!plby2) return lfocx;
|
|
185
|
+
var hl = lfocx - rfocx,
|
|
186
|
+
aby2 = 1 / pby2 - 1 / plby2,
|
|
187
|
+
b = hl / plby2;
|
|
188
|
+
if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
|
|
189
|
+
return (rfocx + lfocx) / 2;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function rightBreakPoint(arc, directrix) {
|
|
193
|
+
var rArc = arc.N;
|
|
194
|
+
if (rArc) return leftBreakPoint(rArc, directrix);
|
|
195
|
+
var site = arc.site;
|
|
196
|
+
return site[1] === directrix ? site[0] : Infinity;
|
|
197
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cellHalfedgeEnd = cellHalfedgeEnd;
|
|
7
|
+
exports.cellHalfedgeStart = cellHalfedgeStart;
|
|
8
|
+
exports.clipCells = clipCells;
|
|
9
|
+
exports.createCell = createCell;
|
|
10
|
+
exports.sortCellHalfedges = sortCellHalfedges;
|
|
11
|
+
|
|
12
|
+
var _Edge = require("./Edge");
|
|
13
|
+
|
|
14
|
+
var _Diagram = require("./Diagram");
|
|
15
|
+
|
|
16
|
+
function createCell(site) {
|
|
17
|
+
return _Diagram.cells[site.index] = {
|
|
18
|
+
site: site,
|
|
19
|
+
halfedges: []
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function cellHalfedgeAngle(cell, edge) {
|
|
24
|
+
var site = cell.site,
|
|
25
|
+
va = edge.left,
|
|
26
|
+
vb = edge.right;
|
|
27
|
+
if (site === vb) vb = va, va = site;
|
|
28
|
+
if (vb) return Math.atan2(vb[1] - va[1], vb[0] - va[0]);
|
|
29
|
+
if (site === va) va = edge[1], vb = edge[0];else va = edge[0], vb = edge[1];
|
|
30
|
+
return Math.atan2(va[0] - vb[0], vb[1] - va[1]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function cellHalfedgeStart(cell, edge) {
|
|
34
|
+
return edge[+(edge.left !== cell.site)];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function cellHalfedgeEnd(cell, edge) {
|
|
38
|
+
return edge[+(edge.left === cell.site)];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function sortCellHalfedges() {
|
|
42
|
+
for (var i = 0, n = _Diagram.cells.length, cell, halfedges, j, m; i < n; ++i) {
|
|
43
|
+
if ((cell = _Diagram.cells[i]) && (m = (halfedges = cell.halfedges).length)) {
|
|
44
|
+
var index = new Array(m),
|
|
45
|
+
array = new Array(m);
|
|
46
|
+
|
|
47
|
+
for (j = 0; j < m; ++j) index[j] = j, array[j] = cellHalfedgeAngle(cell, _Diagram.edges[halfedges[j]]);
|
|
48
|
+
|
|
49
|
+
index.sort(function (i, j) {
|
|
50
|
+
return array[j] - array[i];
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
for (j = 0; j < m; ++j) array[j] = halfedges[index[j]];
|
|
54
|
+
|
|
55
|
+
for (j = 0; j < m; ++j) halfedges[j] = array[j];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function clipCells(x0, y0, x1, y1) {
|
|
61
|
+
var nCells = _Diagram.cells.length,
|
|
62
|
+
iCell,
|
|
63
|
+
cell,
|
|
64
|
+
site,
|
|
65
|
+
iHalfedge,
|
|
66
|
+
halfedges,
|
|
67
|
+
nHalfedges,
|
|
68
|
+
start,
|
|
69
|
+
startX,
|
|
70
|
+
startY,
|
|
71
|
+
end,
|
|
72
|
+
endX,
|
|
73
|
+
endY,
|
|
74
|
+
cover = true;
|
|
75
|
+
|
|
76
|
+
for (iCell = 0; iCell < nCells; ++iCell) {
|
|
77
|
+
if (cell = _Diagram.cells[iCell]) {
|
|
78
|
+
site = cell.site;
|
|
79
|
+
halfedges = cell.halfedges;
|
|
80
|
+
iHalfedge = halfedges.length; // Remove any dangling clipped edges.
|
|
81
|
+
|
|
82
|
+
while (iHalfedge--) {
|
|
83
|
+
if (!_Diagram.edges[halfedges[iHalfedge]]) {
|
|
84
|
+
halfedges.splice(iHalfedge, 1);
|
|
85
|
+
}
|
|
86
|
+
} // Insert any border edges as necessary.
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
iHalfedge = 0, nHalfedges = halfedges.length;
|
|
90
|
+
|
|
91
|
+
while (iHalfedge < nHalfedges) {
|
|
92
|
+
end = cellHalfedgeEnd(cell, _Diagram.edges[halfedges[iHalfedge]]), endX = end[0], endY = end[1];
|
|
93
|
+
start = cellHalfedgeStart(cell, _Diagram.edges[halfedges[++iHalfedge % nHalfedges]]), startX = start[0], startY = start[1];
|
|
94
|
+
|
|
95
|
+
if (Math.abs(endX - startX) > _Diagram.epsilon || Math.abs(endY - startY) > _Diagram.epsilon) {
|
|
96
|
+
halfedges.splice(iHalfedge, 0, _Diagram.edges.push((0, _Edge.createBorderEdge)(site, end, Math.abs(endX - x0) < _Diagram.epsilon && y1 - endY > _Diagram.epsilon ? [x0, Math.abs(startX - x0) < _Diagram.epsilon ? startY : y1] : Math.abs(endY - y1) < _Diagram.epsilon && x1 - endX > _Diagram.epsilon ? [Math.abs(startY - y1) < _Diagram.epsilon ? startX : x1, y1] : Math.abs(endX - x1) < _Diagram.epsilon && endY - y0 > _Diagram.epsilon ? [x1, Math.abs(startX - x1) < _Diagram.epsilon ? startY : y0] : Math.abs(endY - y0) < _Diagram.epsilon && endX - x0 > _Diagram.epsilon ? [Math.abs(startY - y0) < _Diagram.epsilon ? startX : x0, y0] : null)) - 1);
|
|
97
|
+
++nHalfedges;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (nHalfedges) cover = false;
|
|
102
|
+
}
|
|
103
|
+
} // If there weren’t any edges, have the closest site cover the extent.
|
|
104
|
+
// It doesn’t matter which corner of the extent we measure!
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
if (cover) {
|
|
108
|
+
var dx,
|
|
109
|
+
dy,
|
|
110
|
+
d2,
|
|
111
|
+
dc = Infinity;
|
|
112
|
+
|
|
113
|
+
for (iCell = 0, cover = null; iCell < nCells; ++iCell) {
|
|
114
|
+
if (cell = _Diagram.cells[iCell]) {
|
|
115
|
+
site = cell.site;
|
|
116
|
+
dx = site[0] - x0;
|
|
117
|
+
dy = site[1] - y0;
|
|
118
|
+
d2 = dx * dx + dy * dy;
|
|
119
|
+
if (d2 < dc) dc = d2, cover = cell;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (cover) {
|
|
124
|
+
var v00 = [x0, y0],
|
|
125
|
+
v01 = [x0, y1],
|
|
126
|
+
v11 = [x1, y1],
|
|
127
|
+
v10 = [x1, y0];
|
|
128
|
+
cover.halfedges.push(_Diagram.edges.push((0, _Edge.createBorderEdge)(site = cover.site, v00, v01)) - 1, _Diagram.edges.push((0, _Edge.createBorderEdge)(site, v01, v11)) - 1, _Diagram.edges.push((0, _Edge.createBorderEdge)(site, v11, v10)) - 1, _Diagram.edges.push((0, _Edge.createBorderEdge)(site, v10, v00)) - 1);
|
|
129
|
+
}
|
|
130
|
+
} // Lastly delete any cells with no edges; these were entirely clipped.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
for (iCell = 0; iCell < nCells; ++iCell) {
|
|
134
|
+
if (cell = _Diagram.cells[iCell]) {
|
|
135
|
+
if (!cell.halfedges.length) {
|
|
136
|
+
delete _Diagram.cells[iCell];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attachCircle = attachCircle;
|
|
7
|
+
exports.detachCircle = detachCircle;
|
|
8
|
+
exports.firstCircle = void 0;
|
|
9
|
+
|
|
10
|
+
var _RedBlackTree = require("./RedBlackTree");
|
|
11
|
+
|
|
12
|
+
var _Diagram = require("./Diagram");
|
|
13
|
+
|
|
14
|
+
var circlePool = [];
|
|
15
|
+
var firstCircle;
|
|
16
|
+
exports.firstCircle = firstCircle;
|
|
17
|
+
|
|
18
|
+
function Circle() {
|
|
19
|
+
(0, _RedBlackTree.RedBlackNode)(this);
|
|
20
|
+
this.x = this.y = this.arc = this.site = this.cy = null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function attachCircle(arc) {
|
|
24
|
+
var lArc = arc.P,
|
|
25
|
+
rArc = arc.N;
|
|
26
|
+
if (!lArc || !rArc) return;
|
|
27
|
+
var lSite = lArc.site,
|
|
28
|
+
cSite = arc.site,
|
|
29
|
+
rSite = rArc.site;
|
|
30
|
+
if (lSite === rSite) return;
|
|
31
|
+
var bx = cSite[0],
|
|
32
|
+
by = cSite[1],
|
|
33
|
+
ax = lSite[0] - bx,
|
|
34
|
+
ay = lSite[1] - by,
|
|
35
|
+
cx = rSite[0] - bx,
|
|
36
|
+
cy = rSite[1] - by;
|
|
37
|
+
var d = 2 * (ax * cy - ay * cx);
|
|
38
|
+
if (d >= -_Diagram.epsilon2) return;
|
|
39
|
+
var ha = ax * ax + ay * ay,
|
|
40
|
+
hc = cx * cx + cy * cy,
|
|
41
|
+
x = (cy * ha - ay * hc) / d,
|
|
42
|
+
y = (ax * hc - cx * ha) / d;
|
|
43
|
+
var circle = circlePool.pop() || new Circle();
|
|
44
|
+
circle.arc = arc;
|
|
45
|
+
circle.site = cSite;
|
|
46
|
+
circle.x = x + bx;
|
|
47
|
+
circle.y = (circle.cy = y + by) + Math.sqrt(x * x + y * y); // y bottom
|
|
48
|
+
|
|
49
|
+
arc.circle = circle;
|
|
50
|
+
var before = null,
|
|
51
|
+
node = _Diagram.circles._;
|
|
52
|
+
|
|
53
|
+
while (node) {
|
|
54
|
+
if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) {
|
|
55
|
+
if (node.L) node = node.L;else {
|
|
56
|
+
before = node.P;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
if (node.R) node = node.R;else {
|
|
61
|
+
before = node;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_Diagram.circles.insert(before, circle);
|
|
68
|
+
|
|
69
|
+
if (!before) exports.firstCircle = firstCircle = circle;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function detachCircle(arc) {
|
|
73
|
+
var circle = arc.circle;
|
|
74
|
+
|
|
75
|
+
if (circle) {
|
|
76
|
+
if (!circle.P) exports.firstCircle = firstCircle = circle.N;
|
|
77
|
+
|
|
78
|
+
_Diagram.circles.remove(circle);
|
|
79
|
+
|
|
80
|
+
circlePool.push(circle);
|
|
81
|
+
(0, _RedBlackTree.RedBlackNode)(circle);
|
|
82
|
+
arc.circle = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.circles = exports.cells = exports.beaches = void 0;
|
|
7
|
+
exports.default = Diagram;
|
|
8
|
+
exports.epsilon2 = exports.epsilon = exports.edges = void 0;
|
|
9
|
+
|
|
10
|
+
var _Beach = require("./Beach");
|
|
11
|
+
|
|
12
|
+
var _Cell = require("./Cell");
|
|
13
|
+
|
|
14
|
+
var _Circle = require("./Circle");
|
|
15
|
+
|
|
16
|
+
var _Edge = require("./Edge");
|
|
17
|
+
|
|
18
|
+
var _RedBlackTree = _interopRequireDefault(require("./RedBlackTree"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
var epsilon = 1e-6;
|
|
23
|
+
exports.epsilon = epsilon;
|
|
24
|
+
var epsilon2 = 1e-12;
|
|
25
|
+
exports.epsilon2 = epsilon2;
|
|
26
|
+
var beaches;
|
|
27
|
+
exports.beaches = beaches;
|
|
28
|
+
var cells;
|
|
29
|
+
exports.cells = cells;
|
|
30
|
+
var circles;
|
|
31
|
+
exports.circles = circles;
|
|
32
|
+
var edges;
|
|
33
|
+
exports.edges = edges;
|
|
34
|
+
|
|
35
|
+
function triangleArea(a, b, c) {
|
|
36
|
+
return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function lexicographic(a, b) {
|
|
40
|
+
return b[1] - a[1] || b[0] - a[0];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Diagram(sites, extent) {
|
|
44
|
+
var site = sites.sort(lexicographic).pop(),
|
|
45
|
+
x,
|
|
46
|
+
y,
|
|
47
|
+
circle;
|
|
48
|
+
exports.edges = edges = [];
|
|
49
|
+
exports.cells = cells = new Array(sites.length);
|
|
50
|
+
exports.beaches = beaches = new _RedBlackTree.default();
|
|
51
|
+
exports.circles = circles = new _RedBlackTree.default();
|
|
52
|
+
|
|
53
|
+
while (true) {
|
|
54
|
+
circle = _Circle.firstCircle;
|
|
55
|
+
|
|
56
|
+
if (site && (!circle || site[1] < circle.y || site[1] === circle.y && site[0] < circle.x)) {
|
|
57
|
+
if (site[0] !== x || site[1] !== y) {
|
|
58
|
+
(0, _Beach.addBeach)(site);
|
|
59
|
+
x = site[0], y = site[1];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
site = sites.pop();
|
|
63
|
+
} else if (circle) {
|
|
64
|
+
(0, _Beach.removeBeach)(circle.arc);
|
|
65
|
+
} else {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
(0, _Cell.sortCellHalfedges)();
|
|
71
|
+
|
|
72
|
+
if (extent) {
|
|
73
|
+
var x0 = +extent[0][0],
|
|
74
|
+
y0 = +extent[0][1],
|
|
75
|
+
x1 = +extent[1][0],
|
|
76
|
+
y1 = +extent[1][1];
|
|
77
|
+
(0, _Edge.clipEdges)(x0, y0, x1, y1);
|
|
78
|
+
(0, _Cell.clipCells)(x0, y0, x1, y1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.edges = edges;
|
|
82
|
+
this.cells = cells;
|
|
83
|
+
exports.beaches = beaches = exports.circles = circles = exports.edges = edges = exports.cells = cells = null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Diagram.prototype = {
|
|
87
|
+
constructor: Diagram,
|
|
88
|
+
polygons: function () {
|
|
89
|
+
var edges = this.edges;
|
|
90
|
+
return this.cells.map(function (cell) {
|
|
91
|
+
var polygon = cell.halfedges.map(function (i) {
|
|
92
|
+
return (0, _Cell.cellHalfedgeStart)(cell, edges[i]);
|
|
93
|
+
});
|
|
94
|
+
polygon.data = cell.site.data;
|
|
95
|
+
return polygon;
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
triangles: function () {
|
|
99
|
+
var triangles = [],
|
|
100
|
+
edges = this.edges;
|
|
101
|
+
this.cells.forEach(function (cell, i) {
|
|
102
|
+
if (!(m = (halfedges = cell.halfedges).length)) return;
|
|
103
|
+
var site = cell.site,
|
|
104
|
+
halfedges,
|
|
105
|
+
j = -1,
|
|
106
|
+
m,
|
|
107
|
+
s0,
|
|
108
|
+
e1 = edges[halfedges[m - 1]],
|
|
109
|
+
s1 = e1.left === site ? e1.right : e1.left;
|
|
110
|
+
|
|
111
|
+
while (++j < m) {
|
|
112
|
+
s0 = s1;
|
|
113
|
+
e1 = edges[halfedges[j]];
|
|
114
|
+
s1 = e1.left === site ? e1.right : e1.left;
|
|
115
|
+
|
|
116
|
+
if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
|
|
117
|
+
triangles.push([site.data, s0.data, s1.data]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return triangles;
|
|
122
|
+
},
|
|
123
|
+
links: function () {
|
|
124
|
+
return this.edges.filter(function (edge) {
|
|
125
|
+
return edge.right;
|
|
126
|
+
}).map(function (edge) {
|
|
127
|
+
return {
|
|
128
|
+
source: edge.left.data,
|
|
129
|
+
target: edge.right.data
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
find: function (x, y, radius) {
|
|
134
|
+
var that = this,
|
|
135
|
+
i0,
|
|
136
|
+
i1 = that._found || 0,
|
|
137
|
+
n = that.cells.length,
|
|
138
|
+
cell; // Use the previously-found cell, or start with an arbitrary one.
|
|
139
|
+
|
|
140
|
+
while (!(cell = that.cells[i1])) if (++i1 >= n) return null;
|
|
141
|
+
|
|
142
|
+
var dx = x - cell.site[0],
|
|
143
|
+
dy = y - cell.site[1],
|
|
144
|
+
d2 = dx * dx + dy * dy; // Traverse the half-edges to find a closer cell, if any.
|
|
145
|
+
|
|
146
|
+
do {
|
|
147
|
+
cell = that.cells[i0 = i1], i1 = null;
|
|
148
|
+
cell.halfedges.forEach(function (e) {
|
|
149
|
+
var edge = that.edges[e],
|
|
150
|
+
v = edge.left;
|
|
151
|
+
if ((v === cell.site || !v) && !(v = edge.right)) return;
|
|
152
|
+
var vx = x - v[0],
|
|
153
|
+
vy = y - v[1],
|
|
154
|
+
v2 = vx * vx + vy * vy;
|
|
155
|
+
if (v2 < d2) d2 = v2, i1 = v.index;
|
|
156
|
+
});
|
|
157
|
+
} while (i1 !== null);
|
|
158
|
+
|
|
159
|
+
that._found = i0;
|
|
160
|
+
return radius == null || d2 <= radius * radius ? cell.site : null;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.clipEdges = clipEdges;
|
|
7
|
+
exports.createBorderEdge = createBorderEdge;
|
|
8
|
+
exports.createEdge = createEdge;
|
|
9
|
+
exports.setEdgeEnd = setEdgeEnd;
|
|
10
|
+
|
|
11
|
+
var _Diagram = require("./Diagram");
|
|
12
|
+
|
|
13
|
+
function createEdge(left, right, v0, v1) {
|
|
14
|
+
var edge = [null, null],
|
|
15
|
+
index = _Diagram.edges.push(edge) - 1;
|
|
16
|
+
edge.left = left;
|
|
17
|
+
edge.right = right;
|
|
18
|
+
if (v0) setEdgeEnd(edge, left, right, v0);
|
|
19
|
+
if (v1) setEdgeEnd(edge, right, left, v1);
|
|
20
|
+
|
|
21
|
+
_Diagram.cells[left.index].halfedges.push(index);
|
|
22
|
+
|
|
23
|
+
_Diagram.cells[right.index].halfedges.push(index);
|
|
24
|
+
|
|
25
|
+
return edge;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function createBorderEdge(left, v0, v1) {
|
|
29
|
+
var edge = [v0, v1];
|
|
30
|
+
edge.left = left;
|
|
31
|
+
return edge;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function setEdgeEnd(edge, left, right, vertex) {
|
|
35
|
+
if (!edge[0] && !edge[1]) {
|
|
36
|
+
edge[0] = vertex;
|
|
37
|
+
edge.left = left;
|
|
38
|
+
edge.right = right;
|
|
39
|
+
} else if (edge.left === right) {
|
|
40
|
+
edge[1] = vertex;
|
|
41
|
+
} else {
|
|
42
|
+
edge[0] = vertex;
|
|
43
|
+
}
|
|
44
|
+
} // Liang–Barsky line clipping.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function clipEdge(edge, x0, y0, x1, y1) {
|
|
48
|
+
var a = edge[0],
|
|
49
|
+
b = edge[1],
|
|
50
|
+
ax = a[0],
|
|
51
|
+
ay = a[1],
|
|
52
|
+
bx = b[0],
|
|
53
|
+
by = b[1],
|
|
54
|
+
t0 = 0,
|
|
55
|
+
t1 = 1,
|
|
56
|
+
dx = bx - ax,
|
|
57
|
+
dy = by - ay,
|
|
58
|
+
r;
|
|
59
|
+
r = x0 - ax;
|
|
60
|
+
if (!dx && r > 0) return;
|
|
61
|
+
r /= dx;
|
|
62
|
+
|
|
63
|
+
if (dx < 0) {
|
|
64
|
+
if (r < t0) return;
|
|
65
|
+
if (r < t1) t1 = r;
|
|
66
|
+
} else if (dx > 0) {
|
|
67
|
+
if (r > t1) return;
|
|
68
|
+
if (r > t0) t0 = r;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
r = x1 - ax;
|
|
72
|
+
if (!dx && r < 0) return;
|
|
73
|
+
r /= dx;
|
|
74
|
+
|
|
75
|
+
if (dx < 0) {
|
|
76
|
+
if (r > t1) return;
|
|
77
|
+
if (r > t0) t0 = r;
|
|
78
|
+
} else if (dx > 0) {
|
|
79
|
+
if (r < t0) return;
|
|
80
|
+
if (r < t1) t1 = r;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
r = y0 - ay;
|
|
84
|
+
if (!dy && r > 0) return;
|
|
85
|
+
r /= dy;
|
|
86
|
+
|
|
87
|
+
if (dy < 0) {
|
|
88
|
+
if (r < t0) return;
|
|
89
|
+
if (r < t1) t1 = r;
|
|
90
|
+
} else if (dy > 0) {
|
|
91
|
+
if (r > t1) return;
|
|
92
|
+
if (r > t0) t0 = r;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
r = y1 - ay;
|
|
96
|
+
if (!dy && r < 0) return;
|
|
97
|
+
r /= dy;
|
|
98
|
+
|
|
99
|
+
if (dy < 0) {
|
|
100
|
+
if (r > t1) return;
|
|
101
|
+
if (r > t0) t0 = r;
|
|
102
|
+
} else if (dy > 0) {
|
|
103
|
+
if (r < t0) return;
|
|
104
|
+
if (r < t1) t1 = r;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!(t0 > 0) && !(t1 < 1)) return true; // TODO Better check?
|
|
108
|
+
|
|
109
|
+
if (t0 > 0) edge[0] = [ax + t0 * dx, ay + t0 * dy];
|
|
110
|
+
if (t1 < 1) edge[1] = [ax + t1 * dx, ay + t1 * dy];
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function connectEdge(edge, x0, y0, x1, y1) {
|
|
115
|
+
var v1 = edge[1];
|
|
116
|
+
if (v1) return true;
|
|
117
|
+
var v0 = edge[0],
|
|
118
|
+
left = edge.left,
|
|
119
|
+
right = edge.right,
|
|
120
|
+
lx = left[0],
|
|
121
|
+
ly = left[1],
|
|
122
|
+
rx = right[0],
|
|
123
|
+
ry = right[1],
|
|
124
|
+
fx = (lx + rx) / 2,
|
|
125
|
+
fy = (ly + ry) / 2,
|
|
126
|
+
fm,
|
|
127
|
+
fb;
|
|
128
|
+
|
|
129
|
+
if (ry === ly) {
|
|
130
|
+
if (fx < x0 || fx >= x1) return;
|
|
131
|
+
|
|
132
|
+
if (lx > rx) {
|
|
133
|
+
if (!v0) v0 = [fx, y0];else if (v0[1] >= y1) return;
|
|
134
|
+
v1 = [fx, y1];
|
|
135
|
+
} else {
|
|
136
|
+
if (!v0) v0 = [fx, y1];else if (v0[1] < y0) return;
|
|
137
|
+
v1 = [fx, y0];
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
fm = (lx - rx) / (ry - ly);
|
|
141
|
+
fb = fy - fm * fx;
|
|
142
|
+
|
|
143
|
+
if (fm < -1 || fm > 1) {
|
|
144
|
+
if (lx > rx) {
|
|
145
|
+
if (!v0) v0 = [(y0 - fb) / fm, y0];else if (v0[1] >= y1) return;
|
|
146
|
+
v1 = [(y1 - fb) / fm, y1];
|
|
147
|
+
} else {
|
|
148
|
+
if (!v0) v0 = [(y1 - fb) / fm, y1];else if (v0[1] < y0) return;
|
|
149
|
+
v1 = [(y0 - fb) / fm, y0];
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
if (ly < ry) {
|
|
153
|
+
if (!v0) v0 = [x0, fm * x0 + fb];else if (v0[0] >= x1) return;
|
|
154
|
+
v1 = [x1, fm * x1 + fb];
|
|
155
|
+
} else {
|
|
156
|
+
if (!v0) v0 = [x1, fm * x1 + fb];else if (v0[0] < x0) return;
|
|
157
|
+
v1 = [x0, fm * x0 + fb];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
edge[0] = v0;
|
|
163
|
+
edge[1] = v1;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function clipEdges(x0, y0, x1, y1) {
|
|
168
|
+
var i = _Diagram.edges.length,
|
|
169
|
+
edge;
|
|
170
|
+
|
|
171
|
+
while (i--) {
|
|
172
|
+
if (!connectEdge(edge = _Diagram.edges[i], x0, y0, x1, y1) || !clipEdge(edge, x0, y0, x1, y1) || !(Math.abs(edge[0][0] - edge[1][0]) > _Diagram.epsilon || Math.abs(edge[0][1] - edge[1][1]) > _Diagram.epsilon)) {
|
|
173
|
+
delete _Diagram.edges[i];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RedBlackNode = RedBlackNode;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
|
|
9
|
+
function RedBlackTree() {
|
|
10
|
+
this._ = null; // root node
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function RedBlackNode(node) {
|
|
14
|
+
node.U = // parent node
|
|
15
|
+
node.C = // color - true for red, false for black
|
|
16
|
+
node.L = // left node
|
|
17
|
+
node.R = // right node
|
|
18
|
+
node.P = // previous node
|
|
19
|
+
node.N = null; // next node
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
RedBlackTree.prototype = {
|
|
23
|
+
constructor: RedBlackTree,
|
|
24
|
+
insert: function (after, node) {
|
|
25
|
+
var parent, grandpa, uncle;
|
|
26
|
+
|
|
27
|
+
if (after) {
|
|
28
|
+
node.P = after;
|
|
29
|
+
node.N = after.N;
|
|
30
|
+
if (after.N) after.N.P = node;
|
|
31
|
+
after.N = node;
|
|
32
|
+
|
|
33
|
+
if (after.R) {
|
|
34
|
+
after = after.R;
|
|
35
|
+
|
|
36
|
+
while (after.L) after = after.L;
|
|
37
|
+
|
|
38
|
+
after.L = node;
|
|
39
|
+
} else {
|
|
40
|
+
after.R = node;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
parent = after;
|
|
44
|
+
} else if (this._) {
|
|
45
|
+
after = RedBlackFirst(this._);
|
|
46
|
+
node.P = null;
|
|
47
|
+
node.N = after;
|
|
48
|
+
after.P = after.L = node;
|
|
49
|
+
parent = after;
|
|
50
|
+
} else {
|
|
51
|
+
node.P = node.N = null;
|
|
52
|
+
this._ = node;
|
|
53
|
+
parent = null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
node.L = node.R = null;
|
|
57
|
+
node.U = parent;
|
|
58
|
+
node.C = true;
|
|
59
|
+
after = node;
|
|
60
|
+
|
|
61
|
+
while (parent && parent.C) {
|
|
62
|
+
grandpa = parent.U;
|
|
63
|
+
|
|
64
|
+
if (parent === grandpa.L) {
|
|
65
|
+
uncle = grandpa.R;
|
|
66
|
+
|
|
67
|
+
if (uncle && uncle.C) {
|
|
68
|
+
parent.C = uncle.C = false;
|
|
69
|
+
grandpa.C = true;
|
|
70
|
+
after = grandpa;
|
|
71
|
+
} else {
|
|
72
|
+
if (after === parent.R) {
|
|
73
|
+
RedBlackRotateLeft(this, parent);
|
|
74
|
+
after = parent;
|
|
75
|
+
parent = after.U;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
parent.C = false;
|
|
79
|
+
grandpa.C = true;
|
|
80
|
+
RedBlackRotateRight(this, grandpa);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
uncle = grandpa.L;
|
|
84
|
+
|
|
85
|
+
if (uncle && uncle.C) {
|
|
86
|
+
parent.C = uncle.C = false;
|
|
87
|
+
grandpa.C = true;
|
|
88
|
+
after = grandpa;
|
|
89
|
+
} else {
|
|
90
|
+
if (after === parent.L) {
|
|
91
|
+
RedBlackRotateRight(this, parent);
|
|
92
|
+
after = parent;
|
|
93
|
+
parent = after.U;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
parent.C = false;
|
|
97
|
+
grandpa.C = true;
|
|
98
|
+
RedBlackRotateLeft(this, grandpa);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
parent = after.U;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this._.C = false;
|
|
106
|
+
},
|
|
107
|
+
remove: function (node) {
|
|
108
|
+
if (node.N) node.N.P = node.P;
|
|
109
|
+
if (node.P) node.P.N = node.N;
|
|
110
|
+
node.N = node.P = null;
|
|
111
|
+
var parent = node.U,
|
|
112
|
+
sibling,
|
|
113
|
+
left = node.L,
|
|
114
|
+
right = node.R,
|
|
115
|
+
next,
|
|
116
|
+
red;
|
|
117
|
+
if (!left) next = right;else if (!right) next = left;else next = RedBlackFirst(right);
|
|
118
|
+
|
|
119
|
+
if (parent) {
|
|
120
|
+
if (parent.L === node) parent.L = next;else parent.R = next;
|
|
121
|
+
} else {
|
|
122
|
+
this._ = next;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (left && right) {
|
|
126
|
+
red = next.C;
|
|
127
|
+
next.C = node.C;
|
|
128
|
+
next.L = left;
|
|
129
|
+
left.U = next;
|
|
130
|
+
|
|
131
|
+
if (next !== right) {
|
|
132
|
+
parent = next.U;
|
|
133
|
+
next.U = node.U;
|
|
134
|
+
node = next.R;
|
|
135
|
+
parent.L = node;
|
|
136
|
+
next.R = right;
|
|
137
|
+
right.U = next;
|
|
138
|
+
} else {
|
|
139
|
+
next.U = parent;
|
|
140
|
+
parent = next;
|
|
141
|
+
node = next.R;
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
red = node.C;
|
|
145
|
+
node = next;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (node) node.U = parent;
|
|
149
|
+
if (red) return;
|
|
150
|
+
|
|
151
|
+
if (node && node.C) {
|
|
152
|
+
node.C = false;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
do {
|
|
157
|
+
if (node === this._) break;
|
|
158
|
+
|
|
159
|
+
if (node === parent.L) {
|
|
160
|
+
sibling = parent.R;
|
|
161
|
+
|
|
162
|
+
if (sibling.C) {
|
|
163
|
+
sibling.C = false;
|
|
164
|
+
parent.C = true;
|
|
165
|
+
RedBlackRotateLeft(this, parent);
|
|
166
|
+
sibling = parent.R;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
|
|
170
|
+
if (!sibling.R || !sibling.R.C) {
|
|
171
|
+
sibling.L.C = false;
|
|
172
|
+
sibling.C = true;
|
|
173
|
+
RedBlackRotateRight(this, sibling);
|
|
174
|
+
sibling = parent.R;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
sibling.C = parent.C;
|
|
178
|
+
parent.C = sibling.R.C = false;
|
|
179
|
+
RedBlackRotateLeft(this, parent);
|
|
180
|
+
node = this._;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
sibling = parent.L;
|
|
185
|
+
|
|
186
|
+
if (sibling.C) {
|
|
187
|
+
sibling.C = false;
|
|
188
|
+
parent.C = true;
|
|
189
|
+
RedBlackRotateRight(this, parent);
|
|
190
|
+
sibling = parent.L;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
|
|
194
|
+
if (!sibling.L || !sibling.L.C) {
|
|
195
|
+
sibling.R.C = false;
|
|
196
|
+
sibling.C = true;
|
|
197
|
+
RedBlackRotateLeft(this, sibling);
|
|
198
|
+
sibling = parent.L;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
sibling.C = parent.C;
|
|
202
|
+
parent.C = sibling.L.C = false;
|
|
203
|
+
RedBlackRotateRight(this, parent);
|
|
204
|
+
node = this._;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
sibling.C = true;
|
|
210
|
+
node = parent;
|
|
211
|
+
parent = parent.U;
|
|
212
|
+
} while (!node.C);
|
|
213
|
+
|
|
214
|
+
if (node) node.C = false;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
function RedBlackRotateLeft(tree, node) {
|
|
219
|
+
var p = node,
|
|
220
|
+
q = node.R,
|
|
221
|
+
parent = p.U;
|
|
222
|
+
|
|
223
|
+
if (parent) {
|
|
224
|
+
if (parent.L === p) parent.L = q;else parent.R = q;
|
|
225
|
+
} else {
|
|
226
|
+
tree._ = q;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
q.U = parent;
|
|
230
|
+
p.U = q;
|
|
231
|
+
p.R = q.L;
|
|
232
|
+
if (p.R) p.R.U = p;
|
|
233
|
+
q.L = p;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function RedBlackRotateRight(tree, node) {
|
|
237
|
+
var p = node,
|
|
238
|
+
q = node.L,
|
|
239
|
+
parent = p.U;
|
|
240
|
+
|
|
241
|
+
if (parent) {
|
|
242
|
+
if (parent.L === p) parent.L = q;else parent.R = q;
|
|
243
|
+
} else {
|
|
244
|
+
tree._ = q;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
q.U = parent;
|
|
248
|
+
p.U = q;
|
|
249
|
+
p.L = q.R;
|
|
250
|
+
if (p.L) p.L.U = p;
|
|
251
|
+
q.R = p;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function RedBlackFirst(node) {
|
|
255
|
+
while (node.L) node = node.L;
|
|
256
|
+
|
|
257
|
+
return node;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
var _default = RedBlackTree;
|
|
261
|
+
exports.default = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "voronoi", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _voronoi.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _voronoi = _interopRequireDefault(require("./voronoi"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
|
|
8
|
+
var _constant = _interopRequireDefault(require("./constant"));
|
|
9
|
+
|
|
10
|
+
var _point = require("./point");
|
|
11
|
+
|
|
12
|
+
var _Diagram = _interopRequireWildcard(require("./Diagram"));
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _default() {
|
|
21
|
+
var x = _point.x,
|
|
22
|
+
y = _point.y,
|
|
23
|
+
extent = null;
|
|
24
|
+
|
|
25
|
+
function voronoi(data) {
|
|
26
|
+
return new _Diagram.default(data.map(function (d, i) {
|
|
27
|
+
var s = [Math.round(x(d, i, data) / _Diagram.epsilon) * _Diagram.epsilon, Math.round(y(d, i, data) / _Diagram.epsilon) * _Diagram.epsilon];
|
|
28
|
+
s.index = i;
|
|
29
|
+
s.data = d;
|
|
30
|
+
return s;
|
|
31
|
+
}), extent);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
voronoi.polygons = function (data) {
|
|
35
|
+
return voronoi(data).polygons();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
voronoi.links = function (data) {
|
|
39
|
+
return voronoi(data).links();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
voronoi.triangles = function (data) {
|
|
43
|
+
return voronoi(data).triangles();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
voronoi.x = function (_) {
|
|
47
|
+
return arguments.length ? (x = typeof _ === "function" ? _ : (0, _constant.default)(+_), voronoi) : x;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
voronoi.y = function (_) {
|
|
51
|
+
return arguments.length ? (y = typeof _ === "function" ? _ : (0, _constant.default)(+_), voronoi) : y;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
voronoi.extent = function (_) {
|
|
55
|
+
return arguments.length ? (extent = _ == null ? null : [[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]], voronoi) : extent && [[extent[0][0], extent[0][1]], [extent[1][0], extent[1][1]]];
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
voronoi.size = function (_) {
|
|
59
|
+
return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi) : extent && [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return voronoi;
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-vendor",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.6.0",
|
|
4
4
|
"description": "Vendored dependencies for Victory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
"default": "./lib/d3-*.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"version": "yarn run build",
|
|
28
|
-
"build": "node ./scripts/build.js"
|
|
29
|
-
},
|
|
30
26
|
"dependencies": {
|
|
31
27
|
"@types/d3-array": "^3.0.3",
|
|
32
28
|
"@types/d3-ease": "^3.0.0",
|
|
@@ -44,9 +40,135 @@
|
|
|
44
40
|
"d3-timer": "^3.0.1"
|
|
45
41
|
},
|
|
46
42
|
"devDependencies": {
|
|
43
|
+
"d3-color": "^3.1.0",
|
|
44
|
+
"d3-format": "^3.1.0",
|
|
45
|
+
"d3-path": "^3.0.1",
|
|
46
|
+
"d3-time-format": "^4.1.0",
|
|
47
|
+
"d3-voronoi": "^1.1.4",
|
|
48
|
+
"internmap": "^2.0.3",
|
|
47
49
|
"execa": "^6.1.0",
|
|
48
50
|
"rimraf": "^3.0.2"
|
|
49
51
|
},
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
"wireit": {
|
|
53
|
+
"build": {
|
|
54
|
+
"command": "node ./scripts/build.js",
|
|
55
|
+
"files": [
|
|
56
|
+
"scripts/build.js",
|
|
57
|
+
"node_modules/**"
|
|
58
|
+
],
|
|
59
|
+
"output": [
|
|
60
|
+
"es/**",
|
|
61
|
+
"lib/**",
|
|
62
|
+
"lib-vendor/**",
|
|
63
|
+
"d3-*"
|
|
64
|
+
],
|
|
65
|
+
"packageLocks": [
|
|
66
|
+
"pnpm-lock.yaml"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"build:lib:esm": {
|
|
70
|
+
"dependencies": [
|
|
71
|
+
"build"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"build:lib:cjs": {
|
|
75
|
+
"dependencies": [
|
|
76
|
+
"build"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"build:dist": {
|
|
80
|
+
"dependencies": [
|
|
81
|
+
"build"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"build:dist:dev": {
|
|
85
|
+
"dependencies": [
|
|
86
|
+
"build"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"build:dist:min": {
|
|
90
|
+
"dependencies": [
|
|
91
|
+
"build"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
"types:check": {
|
|
95
|
+
"command": "echo \"No types to check here\"",
|
|
96
|
+
"files": [],
|
|
97
|
+
"output": []
|
|
98
|
+
},
|
|
99
|
+
"types:create": {
|
|
100
|
+
"dependencies": [
|
|
101
|
+
"build"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"format": {
|
|
105
|
+
"command": "nps format:pkg",
|
|
106
|
+
"files": [
|
|
107
|
+
"scripts/**",
|
|
108
|
+
"*.json",
|
|
109
|
+
"../../.prettierignore",
|
|
110
|
+
"../../.prettierrc.json"
|
|
111
|
+
],
|
|
112
|
+
"output": [],
|
|
113
|
+
"packageLocks": [
|
|
114
|
+
"pnpm-lock.yaml"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"format:fix": {
|
|
118
|
+
"command": "pnpm run format || nps format:pkg:fix",
|
|
119
|
+
"files": [
|
|
120
|
+
"scripts/**",
|
|
121
|
+
"*.json",
|
|
122
|
+
"../../.prettierignore",
|
|
123
|
+
"../../.prettierrc.json"
|
|
124
|
+
],
|
|
125
|
+
"output": [],
|
|
126
|
+
"packageLocks": [
|
|
127
|
+
"pnpm-lock.yaml"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"lint": {
|
|
131
|
+
"command": "nps \"lint:base scripts\"",
|
|
132
|
+
"files": [
|
|
133
|
+
"scripts/**",
|
|
134
|
+
"../../.eslintrc.js"
|
|
135
|
+
],
|
|
136
|
+
"output": [],
|
|
137
|
+
"packageLocks": [
|
|
138
|
+
"pnpm-lock.yaml"
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
"lint:fix": {
|
|
142
|
+
"command": "pnpm run lint || nps \"lint:base --fix scripts\"",
|
|
143
|
+
"files": [
|
|
144
|
+
"scripts/**",
|
|
145
|
+
"../../.eslintrc.js"
|
|
146
|
+
],
|
|
147
|
+
"output": [],
|
|
148
|
+
"packageLocks": [
|
|
149
|
+
"pnpm-lock.yaml"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"jest": {
|
|
153
|
+
"command": "echo victory-vendor has no tests",
|
|
154
|
+
"files": [],
|
|
155
|
+
"output": []
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"scripts": {
|
|
159
|
+
"build": "wireit",
|
|
160
|
+
"build:lib": "wireit",
|
|
161
|
+
"build:lib:esm": "wireit",
|
|
162
|
+
"build:lib:cjs": "wireit",
|
|
163
|
+
"build:dist": "wireit",
|
|
164
|
+
"build:dist:dev": "wireit",
|
|
165
|
+
"build:dist:min": "wireit",
|
|
166
|
+
"types:check": "wireit",
|
|
167
|
+
"types:create": "wireit",
|
|
168
|
+
"format": "wireit",
|
|
169
|
+
"format:fix": "wireit",
|
|
170
|
+
"lint": "wireit",
|
|
171
|
+
"lint:fix": "wireit",
|
|
172
|
+
"jest": "wireit"
|
|
173
|
+
}
|
|
174
|
+
}
|
package/LICENSE.txt
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015-2020 Formidable Labs.
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2016-2020 Alexey Svetliakov <https://github.com/asvetliakov>,
|
|
6
|
-
snerks <https://github.com/snerks>, Krzysztof Cebula <https://github.com
|
|
7
|
-
Havret>, Vitaliy Polyanskiy <https://github.com/alreadyExisted>, James Lismore
|
|
8
|
-
<https://github.com/jlismore>, Stack Builders <https://github.com
|
|
9
|
-
stackbuilders>, Esteban Ibarra <https://github.com/ibarrae>, Dominic Lee
|
|
10
|
-
<https://github.com/dominictwlee>, Dave Vedder <https://github.com
|
|
11
|
-
veddermatic>, Alec Flett <https://github.com/alecf> and potentially other
|
|
12
|
-
DefinitelyTyped contributors.
|
|
13
|
-
|
|
14
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
in the Software without restriction, including without limitation the rights
|
|
17
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
furnished to do so, subject to the following conditions:
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
|
|
29
|
-
The above copyright notice and this permission notice shall be included in all
|
|
30
|
-
copies or substantial portions of the Software.
|