@mui/x-charts-vendor 7.12.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/README.md +76 -0
- package/d3-color.d.ts +5 -0
- package/d3-color.js +7 -0
- package/d3-delaunay.d.ts +5 -0
- package/d3-delaunay.js +7 -0
- package/d3-interpolate.d.ts +5 -0
- package/d3-interpolate.js +7 -0
- package/d3-scale.d.ts +5 -0
- package/d3-scale.js +7 -0
- package/d3-shape.d.ts +5 -0
- package/d3-shape.js +7 -0
- package/d3-time.d.ts +5 -0
- package/d3-time.js +7 -0
- package/es/d3-array.js +6 -0
- package/es/d3-color.js +6 -0
- package/es/d3-delaunay.js +6 -0
- package/es/d3-format.js +6 -0
- package/es/d3-interpolate.js +6 -0
- package/es/d3-path.js +6 -0
- package/es/d3-scale.js +6 -0
- package/es/d3-shape.js +6 -0
- package/es/d3-time-format.js +6 -0
- package/es/d3-time.js +6 -0
- package/es/delaunator.js +6 -0
- package/es/internmap.js +6 -0
- package/es/robust-predicates.js +6 -0
- package/lib/d3-array.js +6 -0
- package/lib/d3-color.js +6 -0
- package/lib/d3-delaunay.js +6 -0
- package/lib/d3-format.js +6 -0
- package/lib/d3-interpolate.js +6 -0
- package/lib/d3-path.js +6 -0
- package/lib/d3-scale.js +6 -0
- package/lib/d3-shape.js +6 -0
- package/lib/d3-time-format.js +6 -0
- package/lib/d3-time.js +6 -0
- package/lib/delaunator.js +6 -0
- package/lib/internmap.js +6 -0
- package/lib/robust-predicates.js +6 -0
- package/lib-vendor/d3-array/LICENSE +13 -0
- package/lib-vendor/d3-array/dist/d3-array.js +1349 -0
- package/lib-vendor/d3-array/dist/d3-array.min.js +777 -0
- package/lib-vendor/d3-array/src/array.js +9 -0
- package/lib-vendor/d3-array/src/ascending.js +9 -0
- package/lib-vendor/d3-array/src/bin.js +126 -0
- package/lib-vendor/d3-array/src/bisect.js +15 -0
- package/lib-vendor/d3-array/src/bisector.js +59 -0
- package/lib-vendor/d3-array/src/blur.js +122 -0
- package/lib-vendor/d3-array/src/constant.js +9 -0
- package/lib-vendor/d3-array/src/count.js +24 -0
- package/lib-vendor/d3-array/src/cross.js +35 -0
- package/lib-vendor/d3-array/src/cumsum.js +11 -0
- package/lib-vendor/d3-array/src/descending.js +9 -0
- package/lib-vendor/d3-array/src/deviation.js +12 -0
- package/lib-vendor/d3-array/src/difference.js +16 -0
- package/lib-vendor/d3-array/src/disjoint.js +24 -0
- package/lib-vendor/d3-array/src/every.js +16 -0
- package/lib-vendor/d3-array/src/extent.js +35 -0
- package/lib-vendor/d3-array/src/filter.js +17 -0
- package/lib-vendor/d3-array/src/fsum.js +77 -0
- package/lib-vendor/d3-array/src/greatest.js +31 -0
- package/lib-vendor/d3-array/src/greatestIndex.js +23 -0
- package/lib-vendor/d3-array/src/group.js +67 -0
- package/lib-vendor/d3-array/src/groupSort.js +15 -0
- package/lib-vendor/d3-array/src/identity.js +9 -0
- package/lib-vendor/d3-array/src/index.js +539 -0
- package/lib-vendor/d3-array/src/intersection.js +23 -0
- package/lib-vendor/d3-array/src/least.js +31 -0
- package/lib-vendor/d3-array/src/leastIndex.js +23 -0
- package/lib-vendor/d3-array/src/map.js +11 -0
- package/lib-vendor/d3-array/src/max.js +24 -0
- package/lib-vendor/d3-array/src/maxIndex.js +26 -0
- package/lib-vendor/d3-array/src/mean.js +25 -0
- package/lib-vendor/d3-array/src/median.js +16 -0
- package/lib-vendor/d3-array/src/merge.js +14 -0
- package/lib-vendor/d3-array/src/min.js +24 -0
- package/lib-vendor/d3-array/src/minIndex.js +26 -0
- package/lib-vendor/d3-array/src/mode.js +33 -0
- package/lib-vendor/d3-array/src/nice.js +23 -0
- package/lib-vendor/d3-array/src/number.js +26 -0
- package/lib-vendor/d3-array/src/pairs.js +21 -0
- package/lib-vendor/d3-array/src/permute.js +9 -0
- package/lib-vendor/d3-array/src/quantile.js +55 -0
- package/lib-vendor/d3-array/src/quickselect.js +47 -0
- package/lib-vendor/d3-array/src/range.js +16 -0
- package/lib-vendor/d3-array/src/rank.js +30 -0
- package/lib-vendor/d3-array/src/reduce.js +28 -0
- package/lib-vendor/d3-array/src/reverse.js +10 -0
- package/lib-vendor/d3-array/src/scan.js +12 -0
- package/lib-vendor/d3-array/src/shuffle.js +20 -0
- package/lib-vendor/d3-array/src/some.js +16 -0
- package/lib-vendor/d3-array/src/sort.js +45 -0
- package/lib-vendor/d3-array/src/subset.js +11 -0
- package/lib-vendor/d3-array/src/sum.js +24 -0
- package/lib-vendor/d3-array/src/superset.js +28 -0
- package/lib-vendor/d3-array/src/threshold/freedmanDiaconis.js +14 -0
- package/lib-vendor/d3-array/src/threshold/scott.js +14 -0
- package/lib-vendor/d3-array/src/threshold/sturges.js +11 -0
- package/lib-vendor/d3-array/src/ticks.js +60 -0
- package/lib-vendor/d3-array/src/transpose.js +20 -0
- package/lib-vendor/d3-array/src/union.js +16 -0
- package/lib-vendor/d3-array/src/variance.js +31 -0
- package/lib-vendor/d3-array/src/zip.js +11 -0
- package/lib-vendor/d3-color/LICENSE +13 -0
- package/lib-vendor/d3-color/dist/d3-color.js +532 -0
- package/lib-vendor/d3-color/dist/d3-color.min.js +446 -0
- package/lib-vendor/d3-color/src/color.js +366 -0
- package/lib-vendor/d3-color/src/cubehelix.js +61 -0
- package/lib-vendor/d3-color/src/define.js +16 -0
- package/lib-vendor/d3-color/src/index.js +59 -0
- package/lib-vendor/d3-color/src/lab.js +117 -0
- package/lib-vendor/d3-color/src/math.js +8 -0
- package/lib-vendor/d3-delaunay/LICENSE +14 -0
- package/lib-vendor/d3-delaunay/dist/d3-delaunay.js +1398 -0
- package/lib-vendor/d3-delaunay/dist/d3-delaunay.min.js +853 -0
- package/lib-vendor/d3-delaunay/src/delaunay.js +282 -0
- package/lib-vendor/d3-delaunay/src/index.js +20 -0
- package/lib-vendor/d3-delaunay/src/path.js +43 -0
- package/lib-vendor/d3-delaunay/src/polygon.js +24 -0
- package/lib-vendor/d3-delaunay/src/voronoi.js +390 -0
- package/lib-vendor/d3-format/LICENSE +13 -0
- package/lib-vendor/d3-format/dist/d3-format.js +313 -0
- package/lib-vendor/d3-format/dist/d3-format.min.js +193 -0
- package/lib-vendor/d3-format/src/defaultLocale.js +23 -0
- package/lib-vendor/d3-format/src/exponent.js +10 -0
- package/lib-vendor/d3-format/src/formatDecimal.js +23 -0
- package/lib-vendor/d3-format/src/formatGroup.js +22 -0
- package/lib-vendor/d3-format/src/formatNumerals.js +13 -0
- package/lib-vendor/d3-format/src/formatPrefixAuto.js +18 -0
- package/lib-vendor/d3-format/src/formatRounded.js +14 -0
- package/lib-vendor/d3-format/src/formatSpecifier.js +42 -0
- package/lib-vendor/d3-format/src/formatTrim.js +25 -0
- package/lib-vendor/d3-format/src/formatTypes.js +25 -0
- package/lib-vendor/d3-format/src/identity.js +9 -0
- package/lib-vendor/d3-format/src/index.js +68 -0
- package/lib-vendor/d3-format/src/locale.js +152 -0
- package/lib-vendor/d3-format/src/precisionFixed.js +11 -0
- package/lib-vendor/d3-format/src/precisionPrefix.js +11 -0
- package/lib-vendor/d3-format/src/precisionRound.js +12 -0
- package/lib-vendor/d3-interpolate/LICENSE +13 -0
- package/lib-vendor/d3-interpolate/dist/d3-interpolate.js +543 -0
- package/lib-vendor/d3-interpolate/dist/d3-interpolate.min.js +362 -0
- package/lib-vendor/d3-interpolate/src/array.js +28 -0
- package/lib-vendor/d3-interpolate/src/basis.js +23 -0
- package/lib-vendor/d3-interpolate/src/basisClosed.js +18 -0
- package/lib-vendor/d3-interpolate/src/color.js +33 -0
- package/lib-vendor/d3-interpolate/src/constant.js +8 -0
- package/lib-vendor/d3-interpolate/src/cubehelix.js +32 -0
- package/lib-vendor/d3-interpolate/src/date.js +12 -0
- package/lib-vendor/d3-interpolate/src/discrete.js +12 -0
- package/lib-vendor/d3-interpolate/src/hcl.js +27 -0
- package/lib-vendor/d3-interpolate/src/hsl.js +27 -0
- package/lib-vendor/d3-interpolate/src/hue.js +14 -0
- package/lib-vendor/d3-interpolate/src/index.js +191 -0
- package/lib-vendor/d3-interpolate/src/lab.js +22 -0
- package/lib-vendor/d3-interpolate/src/number.js +11 -0
- package/lib-vendor/d3-interpolate/src/numberArray.js +20 -0
- package/lib-vendor/d3-interpolate/src/object.js +26 -0
- package/lib-vendor/d3-interpolate/src/piecewise.js +20 -0
- package/lib-vendor/d3-interpolate/src/quantize.js +11 -0
- package/lib-vendor/d3-interpolate/src/rgb.js +59 -0
- package/lib-vendor/d3-interpolate/src/round.js +11 -0
- package/lib-vendor/d3-interpolate/src/string.js +75 -0
- package/lib-vendor/d3-interpolate/src/transform/decompose.js +31 -0
- package/lib-vendor/d3-interpolate/src/transform/index.js +83 -0
- package/lib-vendor/d3-interpolate/src/transform/parse.js +25 -0
- package/lib-vendor/d3-interpolate/src/value.js +23 -0
- package/lib-vendor/d3-interpolate/src/zoom.js +66 -0
- package/lib-vendor/d3-path/LICENSE +13 -0
- package/lib-vendor/d3-path/dist/d3-path.js +161 -0
- package/lib-vendor/d3-path/dist/d3-path.min.js +92 -0
- package/lib-vendor/d3-path/src/index.js +24 -0
- package/lib-vendor/d3-path/src/path.js +158 -0
- package/lib-vendor/d3-scale/LICENSE +13 -0
- package/lib-vendor/d3-scale/dist/d3-scale.js +944 -0
- package/lib-vendor/d3-scale/dist/d3-scale.min.js +690 -0
- package/lib-vendor/d3-scale/src/band.js +87 -0
- package/lib-vendor/d3-scale/src/colors.js +11 -0
- package/lib-vendor/d3-scale/src/constant.js +11 -0
- package/lib-vendor/d3-scale/src/continuous.js +116 -0
- package/lib-vendor/d3-scale/src/diverging.js +91 -0
- package/lib-vendor/d3-scale/src/identity.js +27 -0
- package/lib-vendor/d3-scale/src/index.js +193 -0
- package/lib-vendor/d3-scale/src/init.js +38 -0
- package/lib-vendor/d3-scale/src/linear.js +67 -0
- package/lib-vendor/d3-scale/src/log.js +123 -0
- package/lib-vendor/d3-scale/src/nice.js +21 -0
- package/lib-vendor/d3-scale/src/number.js +9 -0
- package/lib-vendor/d3-scale/src/ordinal.js +44 -0
- package/lib-vendor/d3-scale/src/pow.js +44 -0
- package/lib-vendor/d3-scale/src/quantile.js +48 -0
- package/lib-vendor/d3-scale/src/quantize.js +46 -0
- package/lib-vendor/d3-scale/src/radial.js +53 -0
- package/lib-vendor/d3-scale/src/sequential.js +90 -0
- package/lib-vendor/d3-scale/src/sequentialQuantile.js +38 -0
- package/lib-vendor/d3-scale/src/symlog.js +35 -0
- package/lib-vendor/d3-scale/src/threshold.js +34 -0
- package/lib-vendor/d3-scale/src/tickFormat.js +37 -0
- package/lib-vendor/d3-scale/src/time.js +62 -0
- package/lib-vendor/d3-scale/src/utcTime.js +13 -0
- package/lib-vendor/d3-shape/LICENSE +13 -0
- package/lib-vendor/d3-shape/dist/d3-shape.js +2004 -0
- package/lib-vendor/d3-shape/dist/d3-shape.min.js +1389 -0
- package/lib-vendor/d3-shape/src/arc.js +250 -0
- package/lib-vendor/d3-shape/src/area.js +98 -0
- package/lib-vendor/d3-shape/src/areaRadial.js +42 -0
- package/lib-vendor/d3-shape/src/array.js +12 -0
- package/lib-vendor/d3-shape/src/constant.js +11 -0
- package/lib-vendor/d3-shape/src/curve/basis.js +62 -0
- package/lib-vendor/d3-shape/src/curve/basisClosed.js +70 -0
- package/lib-vendor/d3-shape/src/curve/basisOpen.js +54 -0
- package/lib-vendor/d3-shape/src/curve/bump.js +81 -0
- package/lib-vendor/d3-shape/src/curve/bundle.js +50 -0
- package/lib-vendor/d3-shape/src/curve/cardinal.js +69 -0
- package/lib-vendor/d3-shape/src/curve/cardinalClosed.js +76 -0
- package/lib-vendor/d3-shape/src/curve/cardinalOpen.js +60 -0
- package/lib-vendor/d3-shape/src/curve/catmullRom.js +92 -0
- package/lib-vendor/d3-shape/src/curve/catmullRomClosed.js +83 -0
- package/lib-vendor/d3-shape/src/curve/catmullRomOpen.js +67 -0
- package/lib-vendor/d3-shape/src/curve/linear.js +42 -0
- package/lib-vendor/d3-shape/src/curve/linearClosed.js +28 -0
- package/lib-vendor/d3-shape/src/curve/monotone.js +121 -0
- package/lib-vendor/d3-shape/src/curve/natural.js +67 -0
- package/lib-vendor/d3-shape/src/curve/radial.js +37 -0
- package/lib-vendor/d3-shape/src/curve/step.js +63 -0
- package/lib-vendor/d3-shape/src/descending.js +9 -0
- package/lib-vendor/d3-shape/src/identity.js +9 -0
- package/lib-vendor/d3-shape/src/index.js +436 -0
- package/lib-vendor/d3-shape/src/line.js +52 -0
- package/lib-vendor/d3-shape/src/lineRadial.js +24 -0
- package/lib-vendor/d3-shape/src/link.js +70 -0
- package/lib-vendor/d3-shape/src/math.js +26 -0
- package/lib-vendor/d3-shape/src/noop.js +7 -0
- package/lib-vendor/d3-shape/src/offset/diverging.js +20 -0
- package/lib-vendor/d3-shape/src/offset/expand.js +16 -0
- package/lib-vendor/d3-shape/src/offset/none.js +15 -0
- package/lib-vendor/d3-shape/src/offset/silhouette.js +16 -0
- package/lib-vendor/d3-shape/src/offset/wiggle.js +30 -0
- package/lib-vendor/d3-shape/src/order/appearance.js +23 -0
- package/lib-vendor/d3-shape/src/order/ascending.js +23 -0
- package/lib-vendor/d3-shape/src/order/descending.js +11 -0
- package/lib-vendor/d3-shape/src/order/insideOut.js +31 -0
- package/lib-vendor/d3-shape/src/order/none.js +12 -0
- package/lib-vendor/d3-shape/src/order/reverse.js +11 -0
- package/lib-vendor/d3-shape/src/path.js +22 -0
- package/lib-vendor/d3-shape/src/pie.js +79 -0
- package/lib-vendor/d3-shape/src/point.js +13 -0
- package/lib-vendor/d3-shape/src/pointRadial.js +9 -0
- package/lib-vendor/d3-shape/src/stack.js +55 -0
- package/lib-vendor/d3-shape/src/symbol/asterisk.js +21 -0
- package/lib-vendor/d3-shape/src/symbol/circle.js +14 -0
- package/lib-vendor/d3-shape/src/symbol/cross.js +25 -0
- package/lib-vendor/d3-shape/src/symbol/diamond.js +20 -0
- package/lib-vendor/d3-shape/src/symbol/diamond2.js +17 -0
- package/lib-vendor/d3-shape/src/symbol/plus.js +16 -0
- package/lib-vendor/d3-shape/src/symbol/square.js +14 -0
- package/lib-vendor/d3-shape/src/symbol/square2.js +17 -0
- package/lib-vendor/d3-shape/src/symbol/star.js +28 -0
- package/lib-vendor/d3-shape/src/symbol/times.js +16 -0
- package/lib-vendor/d3-shape/src/symbol/triangle.js +17 -0
- package/lib-vendor/d3-shape/src/symbol/triangle2.js +19 -0
- package/lib-vendor/d3-shape/src/symbol/wye.js +32 -0
- package/lib-vendor/d3-shape/src/symbol.js +50 -0
- package/lib-vendor/d3-time/LICENSE +13 -0
- package/lib-vendor/d3-time/dist/d3-time.js +367 -0
- package/lib-vendor/d3-time/dist/d3-time.min.js +190 -0
- package/lib-vendor/d3-time/src/day.js +30 -0
- package/lib-vendor/d3-time/src/duration.js +13 -0
- package/lib-vendor/d3-time/src/hour.js +28 -0
- package/lib-vendor/d3-time/src/index.js +417 -0
- package/lib-vendor/d3-time/src/interval.js +61 -0
- package/lib-vendor/d3-time/src/millisecond.js +29 -0
- package/lib-vendor/d3-time/src/minute.js +28 -0
- package/lib-vendor/d3-time/src/month.js +29 -0
- package/lib-vendor/d3-time/src/second.js +18 -0
- package/lib-vendor/d3-time/src/ticks.js +41 -0
- package/lib-vendor/d3-time/src/week.js +56 -0
- package/lib-vendor/d3-time/src/year.js +51 -0
- package/lib-vendor/d3-time-format/LICENSE +13 -0
- package/lib-vendor/d3-time-format/dist/d3-time-format.js +648 -0
- package/lib-vendor/d3-time-format/dist/d3-time-format.min.js +528 -0
- package/lib-vendor/d3-time-format/src/defaultLocale.js +32 -0
- package/lib-vendor/d3-time-format/src/index.js +60 -0
- package/lib-vendor/d3-time-format/src/isoFormat.js +13 -0
- package/lib-vendor/d3-time-format/src/isoParse.js +14 -0
- package/lib-vendor/d3-time-format/src/locale.js +606 -0
- package/lib-vendor/delaunator/LICENSE +15 -0
- package/lib-vendor/delaunator/delaunator.js +688 -0
- package/lib-vendor/delaunator/delaunator.min.js +316 -0
- package/lib-vendor/delaunator/index.js +440 -0
- package/lib-vendor/internmap/LICENSE +13 -0
- package/lib-vendor/internmap/dist/internmap.js +93 -0
- package/lib-vendor/internmap/dist/internmap.min.js +81 -0
- package/lib-vendor/internmap/src/index.js +87 -0
- package/lib-vendor/robust-predicates/LICENSE +24 -0
- package/lib-vendor/robust-predicates/esm/incircle.js +667 -0
- package/lib-vendor/robust-predicates/esm/insphere.js +693 -0
- package/lib-vendor/robust-predicates/esm/orient2d.js +174 -0
- package/lib-vendor/robust-predicates/esm/orient3d.js +422 -0
- package/lib-vendor/robust-predicates/esm/util.js +147 -0
- package/lib-vendor/robust-predicates/index.js +57 -0
- package/lib-vendor/robust-predicates/umd/incircle.js +798 -0
- package/lib-vendor/robust-predicates/umd/incircle.min.js +170 -0
- package/lib-vendor/robust-predicates/umd/insphere.js +828 -0
- package/lib-vendor/robust-predicates/umd/insphere.min.js +223 -0
- package/lib-vendor/robust-predicates/umd/orient2d.js +260 -0
- package/lib-vendor/robust-predicates/umd/orient2d.min.js +69 -0
- package/lib-vendor/robust-predicates/umd/orient3d.js +550 -0
- package/lib-vendor/robust-predicates/umd/orient3d.min.js +133 -0
- package/lib-vendor/robust-predicates/umd/predicates.js +2073 -0
- package/lib-vendor/robust-predicates/umd/predicates.min.js +468 -0
- package/package.json +63 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _index = _interopRequireDefault(require("../../../lib-vendor/delaunator/index.js"));
|
|
9
|
+
var _path = _interopRequireDefault(require("./path.js"));
|
|
10
|
+
var _polygon = _interopRequireDefault(require("./polygon.js"));
|
|
11
|
+
var _voronoi = _interopRequireDefault(require("./voronoi.js"));
|
|
12
|
+
const tau = 2 * Math.PI,
|
|
13
|
+
pow = Math.pow;
|
|
14
|
+
function pointX(p) {
|
|
15
|
+
return p[0];
|
|
16
|
+
}
|
|
17
|
+
function pointY(p) {
|
|
18
|
+
return p[1];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// A triangulation is collinear if all its triangles have a non-null area
|
|
22
|
+
function collinear(d) {
|
|
23
|
+
const {
|
|
24
|
+
triangles,
|
|
25
|
+
coords
|
|
26
|
+
} = d;
|
|
27
|
+
for (let i = 0; i < triangles.length; i += 3) {
|
|
28
|
+
const a = 2 * triangles[i],
|
|
29
|
+
b = 2 * triangles[i + 1],
|
|
30
|
+
c = 2 * triangles[i + 2],
|
|
31
|
+
cross = (coords[c] - coords[a]) * (coords[b + 1] - coords[a + 1]) - (coords[b] - coords[a]) * (coords[c + 1] - coords[a + 1]);
|
|
32
|
+
if (cross > 1e-10) return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
function jitter(x, y, r) {
|
|
37
|
+
return [x + Math.sin(x + y) * r, y + Math.cos(x - y) * r];
|
|
38
|
+
}
|
|
39
|
+
class Delaunay {
|
|
40
|
+
static from(points, fx = pointX, fy = pointY, that) {
|
|
41
|
+
return new Delaunay("length" in points ? flatArray(points, fx, fy, that) : Float64Array.from(flatIterable(points, fx, fy, that)));
|
|
42
|
+
}
|
|
43
|
+
constructor(points) {
|
|
44
|
+
this._delaunator = new _index.default(points);
|
|
45
|
+
this.inedges = new Int32Array(points.length / 2);
|
|
46
|
+
this._hullIndex = new Int32Array(points.length / 2);
|
|
47
|
+
this.points = this._delaunator.coords;
|
|
48
|
+
this._init();
|
|
49
|
+
}
|
|
50
|
+
update() {
|
|
51
|
+
this._delaunator.update();
|
|
52
|
+
this._init();
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
_init() {
|
|
56
|
+
const d = this._delaunator,
|
|
57
|
+
points = this.points;
|
|
58
|
+
|
|
59
|
+
// check for collinear
|
|
60
|
+
if (d.hull && d.hull.length > 2 && collinear(d)) {
|
|
61
|
+
this.collinear = Int32Array.from({
|
|
62
|
+
length: points.length / 2
|
|
63
|
+
}, (_, i) => i).sort((i, j) => points[2 * i] - points[2 * j] || points[2 * i + 1] - points[2 * j + 1]); // for exact neighbors
|
|
64
|
+
const e = this.collinear[0],
|
|
65
|
+
f = this.collinear[this.collinear.length - 1],
|
|
66
|
+
bounds = [points[2 * e], points[2 * e + 1], points[2 * f], points[2 * f + 1]],
|
|
67
|
+
r = 1e-8 * Math.hypot(bounds[3] - bounds[1], bounds[2] - bounds[0]);
|
|
68
|
+
for (let i = 0, n = points.length / 2; i < n; ++i) {
|
|
69
|
+
const p = jitter(points[2 * i], points[2 * i + 1], r);
|
|
70
|
+
points[2 * i] = p[0];
|
|
71
|
+
points[2 * i + 1] = p[1];
|
|
72
|
+
}
|
|
73
|
+
this._delaunator = new _index.default(points);
|
|
74
|
+
} else {
|
|
75
|
+
delete this.collinear;
|
|
76
|
+
}
|
|
77
|
+
const halfedges = this.halfedges = this._delaunator.halfedges;
|
|
78
|
+
const hull = this.hull = this._delaunator.hull;
|
|
79
|
+
const triangles = this.triangles = this._delaunator.triangles;
|
|
80
|
+
const inedges = this.inedges.fill(-1);
|
|
81
|
+
const hullIndex = this._hullIndex.fill(-1);
|
|
82
|
+
|
|
83
|
+
// Compute an index from each point to an (arbitrary) incoming halfedge
|
|
84
|
+
// Used to give the first neighbor of each point; for this reason,
|
|
85
|
+
// on the hull we give priority to exterior halfedges
|
|
86
|
+
for (let e = 0, n = halfedges.length; e < n; ++e) {
|
|
87
|
+
const p = triangles[e % 3 === 2 ? e - 2 : e + 1];
|
|
88
|
+
if (halfedges[e] === -1 || inedges[p] === -1) inedges[p] = e;
|
|
89
|
+
}
|
|
90
|
+
for (let i = 0, n = hull.length; i < n; ++i) {
|
|
91
|
+
hullIndex[hull[i]] = i;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// degenerate case: 1 or 2 (distinct) points
|
|
95
|
+
if (hull.length <= 2 && hull.length > 0) {
|
|
96
|
+
this.triangles = new Int32Array(3).fill(-1);
|
|
97
|
+
this.halfedges = new Int32Array(3).fill(-1);
|
|
98
|
+
this.triangles[0] = hull[0];
|
|
99
|
+
inedges[hull[0]] = 1;
|
|
100
|
+
if (hull.length === 2) {
|
|
101
|
+
inedges[hull[1]] = 0;
|
|
102
|
+
this.triangles[1] = hull[1];
|
|
103
|
+
this.triangles[2] = hull[1];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
voronoi(bounds) {
|
|
108
|
+
return new _voronoi.default(this, bounds);
|
|
109
|
+
}
|
|
110
|
+
*neighbors(i) {
|
|
111
|
+
const {
|
|
112
|
+
inedges,
|
|
113
|
+
hull,
|
|
114
|
+
_hullIndex,
|
|
115
|
+
halfedges,
|
|
116
|
+
triangles,
|
|
117
|
+
collinear
|
|
118
|
+
} = this;
|
|
119
|
+
|
|
120
|
+
// degenerate case with several collinear points
|
|
121
|
+
if (collinear) {
|
|
122
|
+
const l = collinear.indexOf(i);
|
|
123
|
+
if (l > 0) yield collinear[l - 1];
|
|
124
|
+
if (l < collinear.length - 1) yield collinear[l + 1];
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const e0 = inedges[i];
|
|
128
|
+
if (e0 === -1) return; // coincident point
|
|
129
|
+
let e = e0,
|
|
130
|
+
p0 = -1;
|
|
131
|
+
do {
|
|
132
|
+
yield p0 = triangles[e];
|
|
133
|
+
e = e % 3 === 2 ? e - 2 : e + 1;
|
|
134
|
+
if (triangles[e] !== i) return; // bad triangulation
|
|
135
|
+
e = halfedges[e];
|
|
136
|
+
if (e === -1) {
|
|
137
|
+
const p = hull[(_hullIndex[i] + 1) % hull.length];
|
|
138
|
+
if (p !== p0) yield p;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
} while (e !== e0);
|
|
142
|
+
}
|
|
143
|
+
find(x, y, i = 0) {
|
|
144
|
+
if ((x = +x, x !== x) || (y = +y, y !== y)) return -1;
|
|
145
|
+
const i0 = i;
|
|
146
|
+
let c;
|
|
147
|
+
while ((c = this._step(i, x, y)) >= 0 && c !== i && c !== i0) i = c;
|
|
148
|
+
return c;
|
|
149
|
+
}
|
|
150
|
+
_step(i, x, y) {
|
|
151
|
+
const {
|
|
152
|
+
inedges,
|
|
153
|
+
hull,
|
|
154
|
+
_hullIndex,
|
|
155
|
+
halfedges,
|
|
156
|
+
triangles,
|
|
157
|
+
points
|
|
158
|
+
} = this;
|
|
159
|
+
if (inedges[i] === -1 || !points.length) return (i + 1) % (points.length >> 1);
|
|
160
|
+
let c = i;
|
|
161
|
+
let dc = pow(x - points[i * 2], 2) + pow(y - points[i * 2 + 1], 2);
|
|
162
|
+
const e0 = inedges[i];
|
|
163
|
+
let e = e0;
|
|
164
|
+
do {
|
|
165
|
+
let t = triangles[e];
|
|
166
|
+
const dt = pow(x - points[t * 2], 2) + pow(y - points[t * 2 + 1], 2);
|
|
167
|
+
if (dt < dc) dc = dt, c = t;
|
|
168
|
+
e = e % 3 === 2 ? e - 2 : e + 1;
|
|
169
|
+
if (triangles[e] !== i) break; // bad triangulation
|
|
170
|
+
e = halfedges[e];
|
|
171
|
+
if (e === -1) {
|
|
172
|
+
e = hull[(_hullIndex[i] + 1) % hull.length];
|
|
173
|
+
if (e !== t) {
|
|
174
|
+
if (pow(x - points[e * 2], 2) + pow(y - points[e * 2 + 1], 2) < dc) return e;
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
} while (e !== e0);
|
|
179
|
+
return c;
|
|
180
|
+
}
|
|
181
|
+
render(context) {
|
|
182
|
+
const buffer = context == null ? context = new _path.default() : undefined;
|
|
183
|
+
const {
|
|
184
|
+
points,
|
|
185
|
+
halfedges,
|
|
186
|
+
triangles
|
|
187
|
+
} = this;
|
|
188
|
+
for (let i = 0, n = halfedges.length; i < n; ++i) {
|
|
189
|
+
const j = halfedges[i];
|
|
190
|
+
if (j < i) continue;
|
|
191
|
+
const ti = triangles[i] * 2;
|
|
192
|
+
const tj = triangles[j] * 2;
|
|
193
|
+
context.moveTo(points[ti], points[ti + 1]);
|
|
194
|
+
context.lineTo(points[tj], points[tj + 1]);
|
|
195
|
+
}
|
|
196
|
+
this.renderHull(context);
|
|
197
|
+
return buffer && buffer.value();
|
|
198
|
+
}
|
|
199
|
+
renderPoints(context, r) {
|
|
200
|
+
if (r === undefined && (!context || typeof context.moveTo !== "function")) r = context, context = null;
|
|
201
|
+
r = r == undefined ? 2 : +r;
|
|
202
|
+
const buffer = context == null ? context = new _path.default() : undefined;
|
|
203
|
+
const {
|
|
204
|
+
points
|
|
205
|
+
} = this;
|
|
206
|
+
for (let i = 0, n = points.length; i < n; i += 2) {
|
|
207
|
+
const x = points[i],
|
|
208
|
+
y = points[i + 1];
|
|
209
|
+
context.moveTo(x + r, y);
|
|
210
|
+
context.arc(x, y, r, 0, tau);
|
|
211
|
+
}
|
|
212
|
+
return buffer && buffer.value();
|
|
213
|
+
}
|
|
214
|
+
renderHull(context) {
|
|
215
|
+
const buffer = context == null ? context = new _path.default() : undefined;
|
|
216
|
+
const {
|
|
217
|
+
hull,
|
|
218
|
+
points
|
|
219
|
+
} = this;
|
|
220
|
+
const h = hull[0] * 2,
|
|
221
|
+
n = hull.length;
|
|
222
|
+
context.moveTo(points[h], points[h + 1]);
|
|
223
|
+
for (let i = 1; i < n; ++i) {
|
|
224
|
+
const h = 2 * hull[i];
|
|
225
|
+
context.lineTo(points[h], points[h + 1]);
|
|
226
|
+
}
|
|
227
|
+
context.closePath();
|
|
228
|
+
return buffer && buffer.value();
|
|
229
|
+
}
|
|
230
|
+
hullPolygon() {
|
|
231
|
+
const polygon = new _polygon.default();
|
|
232
|
+
this.renderHull(polygon);
|
|
233
|
+
return polygon.value();
|
|
234
|
+
}
|
|
235
|
+
renderTriangle(i, context) {
|
|
236
|
+
const buffer = context == null ? context = new _path.default() : undefined;
|
|
237
|
+
const {
|
|
238
|
+
points,
|
|
239
|
+
triangles
|
|
240
|
+
} = this;
|
|
241
|
+
const t0 = triangles[i *= 3] * 2;
|
|
242
|
+
const t1 = triangles[i + 1] * 2;
|
|
243
|
+
const t2 = triangles[i + 2] * 2;
|
|
244
|
+
context.moveTo(points[t0], points[t0 + 1]);
|
|
245
|
+
context.lineTo(points[t1], points[t1 + 1]);
|
|
246
|
+
context.lineTo(points[t2], points[t2 + 1]);
|
|
247
|
+
context.closePath();
|
|
248
|
+
return buffer && buffer.value();
|
|
249
|
+
}
|
|
250
|
+
*trianglePolygons() {
|
|
251
|
+
const {
|
|
252
|
+
triangles
|
|
253
|
+
} = this;
|
|
254
|
+
for (let i = 0, n = triangles.length / 3; i < n; ++i) {
|
|
255
|
+
yield this.trianglePolygon(i);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
trianglePolygon(i) {
|
|
259
|
+
const polygon = new _polygon.default();
|
|
260
|
+
this.renderTriangle(i, polygon);
|
|
261
|
+
return polygon.value();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.default = Delaunay;
|
|
265
|
+
function flatArray(points, fx, fy, that) {
|
|
266
|
+
const n = points.length;
|
|
267
|
+
const array = new Float64Array(n * 2);
|
|
268
|
+
for (let i = 0; i < n; ++i) {
|
|
269
|
+
const p = points[i];
|
|
270
|
+
array[i * 2] = fx.call(that, p, i, points);
|
|
271
|
+
array[i * 2 + 1] = fy.call(that, p, i, points);
|
|
272
|
+
}
|
|
273
|
+
return array;
|
|
274
|
+
}
|
|
275
|
+
function* flatIterable(points, fx, fy, that) {
|
|
276
|
+
let i = 0;
|
|
277
|
+
for (const p of points) {
|
|
278
|
+
yield fx.call(that, p, i, points);
|
|
279
|
+
yield fy.call(that, p, i, points);
|
|
280
|
+
++i;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "Delaunay", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _delaunay.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "Voronoi", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _voronoi.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _delaunay = _interopRequireDefault(require("./delaunay.js"));
|
|
20
|
+
var _voronoi = _interopRequireDefault(require("./voronoi.js"));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const epsilon = 1e-6;
|
|
8
|
+
class Path {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._x0 = this._y0 =
|
|
11
|
+
// start of current subpath
|
|
12
|
+
this._x1 = this._y1 = null; // end of current subpath
|
|
13
|
+
this._ = "";
|
|
14
|
+
}
|
|
15
|
+
moveTo(x, y) {
|
|
16
|
+
this._ += `M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}`;
|
|
17
|
+
}
|
|
18
|
+
closePath() {
|
|
19
|
+
if (this._x1 !== null) {
|
|
20
|
+
this._x1 = this._x0, this._y1 = this._y0;
|
|
21
|
+
this._ += "Z";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
lineTo(x, y) {
|
|
25
|
+
this._ += `L${this._x1 = +x},${this._y1 = +y}`;
|
|
26
|
+
}
|
|
27
|
+
arc(x, y, r) {
|
|
28
|
+
x = +x, y = +y, r = +r;
|
|
29
|
+
const x0 = x + r;
|
|
30
|
+
const y0 = y;
|
|
31
|
+
if (r < 0) throw new Error("negative radius");
|
|
32
|
+
if (this._x1 === null) this._ += `M${x0},${y0}`;else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) this._ += "L" + x0 + "," + y0;
|
|
33
|
+
if (!r) return;
|
|
34
|
+
this._ += `A${r},${r},0,1,1,${x - r},${y}A${r},${r},0,1,1,${this._x1 = x0},${this._y1 = y0}`;
|
|
35
|
+
}
|
|
36
|
+
rect(x, y, w, h) {
|
|
37
|
+
this._ += `M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${+w}v${+h}h${-w}Z`;
|
|
38
|
+
}
|
|
39
|
+
value() {
|
|
40
|
+
return this._ || null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = Path;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class Polygon {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._ = [];
|
|
10
|
+
}
|
|
11
|
+
moveTo(x, y) {
|
|
12
|
+
this._.push([x, y]);
|
|
13
|
+
}
|
|
14
|
+
closePath() {
|
|
15
|
+
this._.push(this._[0].slice());
|
|
16
|
+
}
|
|
17
|
+
lineTo(x, y) {
|
|
18
|
+
this._.push([x, y]);
|
|
19
|
+
}
|
|
20
|
+
value() {
|
|
21
|
+
return this._.length ? this._ : null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = Polygon;
|