inline-style-editor 1.0.1 → 1.0.2
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/dist/inline-style-editor.js +3 -2
- package/dist/inline-style-editor.js.map +1 -0
- package/dist/inline-style-editor.mjs +37 -1144
- package/dist/inline-style-editor.mjs.map +1 -0
- package/package.json +1 -2
- package/src/util/boxesContour.js +23 -14
- package/stats.html +1 -1
- package/test.html +353 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function noop$
|
|
1
|
+
function noop$1() { }
|
|
2
2
|
function run(fn) {
|
|
3
3
|
return fn();
|
|
4
4
|
}
|
|
@@ -261,7 +261,7 @@ function init(component, options, instance, create_fragment, not_equal, props, a
|
|
|
261
261
|
ctx: null,
|
|
262
262
|
// state
|
|
263
263
|
props,
|
|
264
|
-
update: noop$
|
|
264
|
+
update: noop$1,
|
|
265
265
|
not_equal,
|
|
266
266
|
bound: blank_object(),
|
|
267
267
|
// lifecycle
|
|
@@ -320,7 +320,7 @@ function init(component, options, instance, create_fragment, not_equal, props, a
|
|
|
320
320
|
class SvelteComponent {
|
|
321
321
|
$destroy() {
|
|
322
322
|
destroy_component(this, 1);
|
|
323
|
-
this.$destroy = noop$
|
|
323
|
+
this.$destroy = noop$1;
|
|
324
324
|
}
|
|
325
325
|
$on(type, callback) {
|
|
326
326
|
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
|
|
@@ -1290,12 +1290,12 @@ function zero() {
|
|
|
1290
1290
|
return 0;
|
|
1291
1291
|
}
|
|
1292
1292
|
|
|
1293
|
-
function number
|
|
1293
|
+
function number(x) {
|
|
1294
1294
|
return x === null ? NaN : +x;
|
|
1295
1295
|
}
|
|
1296
1296
|
|
|
1297
1297
|
bisector(ascending$1);
|
|
1298
|
-
bisector(number
|
|
1298
|
+
bisector(number).center;
|
|
1299
1299
|
|
|
1300
1300
|
function count(values, valueof) {
|
|
1301
1301
|
let count = 0;
|
|
@@ -1346,48 +1346,6 @@ function extent(values, valueof) {
|
|
|
1346
1346
|
return [min, max];
|
|
1347
1347
|
}
|
|
1348
1348
|
|
|
1349
|
-
// https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Modules/mathmodule.c#L1423
|
|
1350
|
-
class Adder {
|
|
1351
|
-
constructor() {
|
|
1352
|
-
this._partials = new Float64Array(32);
|
|
1353
|
-
this._n = 0;
|
|
1354
|
-
}
|
|
1355
|
-
add(x) {
|
|
1356
|
-
const p = this._partials;
|
|
1357
|
-
let i = 0;
|
|
1358
|
-
for (let j = 0; j < this._n && j < 32; j++) {
|
|
1359
|
-
const y = p[j],
|
|
1360
|
-
hi = x + y,
|
|
1361
|
-
lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x);
|
|
1362
|
-
if (lo) p[i++] = lo;
|
|
1363
|
-
x = hi;
|
|
1364
|
-
}
|
|
1365
|
-
p[i] = x;
|
|
1366
|
-
this._n = i + 1;
|
|
1367
|
-
return this;
|
|
1368
|
-
}
|
|
1369
|
-
valueOf() {
|
|
1370
|
-
const p = this._partials;
|
|
1371
|
-
let n = this._n, x, y, lo, hi = 0;
|
|
1372
|
-
if (n > 0) {
|
|
1373
|
-
hi = p[--n];
|
|
1374
|
-
while (n > 0) {
|
|
1375
|
-
x = hi;
|
|
1376
|
-
y = p[--n];
|
|
1377
|
-
hi = x + y;
|
|
1378
|
-
lo = y - (hi - x);
|
|
1379
|
-
if (lo) break;
|
|
1380
|
-
}
|
|
1381
|
-
if (n > 0 && ((lo < 0 && p[n - 1] < 0) || (lo > 0 && p[n - 1] > 0))) {
|
|
1382
|
-
y = lo * 2;
|
|
1383
|
-
x = hi + y;
|
|
1384
|
-
if (y == x - hi) hi = x;
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
return hi;
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
1349
|
var e10 = Math.sqrt(50),
|
|
1392
1350
|
e5 = Math.sqrt(10),
|
|
1393
1351
|
e2 = Math.sqrt(2);
|
|
@@ -1447,16 +1405,6 @@ function thresholdSturges(values) {
|
|
|
1447
1405
|
return Math.ceil(Math.log(count(values)) / Math.LN2) + 1;
|
|
1448
1406
|
}
|
|
1449
1407
|
|
|
1450
|
-
function* flatten(arrays) {
|
|
1451
|
-
for (const array of arrays) {
|
|
1452
|
-
yield* array;
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
function merge(arrays) {
|
|
1457
|
-
return Array.from(flatten(arrays));
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
1408
|
var array = Array.prototype;
|
|
1461
1409
|
|
|
1462
1410
|
var slice = array.slice;
|
|
@@ -1501,7 +1449,7 @@ function within(p, q, r) {
|
|
|
1501
1449
|
return p <= q && q <= r || r <= q && q <= p;
|
|
1502
1450
|
}
|
|
1503
1451
|
|
|
1504
|
-
function noop
|
|
1452
|
+
function noop() {}
|
|
1505
1453
|
|
|
1506
1454
|
var cases = [
|
|
1507
1455
|
[],
|
|
@@ -1690,1078 +1638,12 @@ function contours() {
|
|
|
1690
1638
|
};
|
|
1691
1639
|
|
|
1692
1640
|
contours.smooth = function(_) {
|
|
1693
|
-
return arguments.length ? (smooth = _ ? smoothLinear : noop
|
|
1641
|
+
return arguments.length ? (smooth = _ ? smoothLinear : noop, contours) : smooth === smoothLinear;
|
|
1694
1642
|
};
|
|
1695
1643
|
|
|
1696
1644
|
return contours;
|
|
1697
1645
|
}
|
|
1698
1646
|
|
|
1699
|
-
var epsilon = 1e-6;
|
|
1700
|
-
var pi = Math.PI;
|
|
1701
|
-
var tau = pi * 2;
|
|
1702
|
-
|
|
1703
|
-
var degrees = 180 / pi;
|
|
1704
|
-
var radians = pi / 180;
|
|
1705
|
-
|
|
1706
|
-
var abs = Math.abs;
|
|
1707
|
-
var cos = Math.cos;
|
|
1708
|
-
var sin = Math.sin;
|
|
1709
|
-
var sqrt = Math.sqrt;
|
|
1710
|
-
|
|
1711
|
-
function noop() {}
|
|
1712
|
-
|
|
1713
|
-
function streamGeometry(geometry, stream) {
|
|
1714
|
-
if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
|
|
1715
|
-
streamGeometryType[geometry.type](geometry, stream);
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
var streamObjectType = {
|
|
1720
|
-
Feature: function(object, stream) {
|
|
1721
|
-
streamGeometry(object.geometry, stream);
|
|
1722
|
-
},
|
|
1723
|
-
FeatureCollection: function(object, stream) {
|
|
1724
|
-
var features = object.features, i = -1, n = features.length;
|
|
1725
|
-
while (++i < n) streamGeometry(features[i].geometry, stream);
|
|
1726
|
-
}
|
|
1727
|
-
};
|
|
1728
|
-
|
|
1729
|
-
var streamGeometryType = {
|
|
1730
|
-
Sphere: function(object, stream) {
|
|
1731
|
-
stream.sphere();
|
|
1732
|
-
},
|
|
1733
|
-
Point: function(object, stream) {
|
|
1734
|
-
object = object.coordinates;
|
|
1735
|
-
stream.point(object[0], object[1], object[2]);
|
|
1736
|
-
},
|
|
1737
|
-
MultiPoint: function(object, stream) {
|
|
1738
|
-
var coordinates = object.coordinates, i = -1, n = coordinates.length;
|
|
1739
|
-
while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]);
|
|
1740
|
-
},
|
|
1741
|
-
LineString: function(object, stream) {
|
|
1742
|
-
streamLine(object.coordinates, stream, 0);
|
|
1743
|
-
},
|
|
1744
|
-
MultiLineString: function(object, stream) {
|
|
1745
|
-
var coordinates = object.coordinates, i = -1, n = coordinates.length;
|
|
1746
|
-
while (++i < n) streamLine(coordinates[i], stream, 0);
|
|
1747
|
-
},
|
|
1748
|
-
Polygon: function(object, stream) {
|
|
1749
|
-
streamPolygon(object.coordinates, stream);
|
|
1750
|
-
},
|
|
1751
|
-
MultiPolygon: function(object, stream) {
|
|
1752
|
-
var coordinates = object.coordinates, i = -1, n = coordinates.length;
|
|
1753
|
-
while (++i < n) streamPolygon(coordinates[i], stream);
|
|
1754
|
-
},
|
|
1755
|
-
GeometryCollection: function(object, stream) {
|
|
1756
|
-
var geometries = object.geometries, i = -1, n = geometries.length;
|
|
1757
|
-
while (++i < n) streamGeometry(geometries[i], stream);
|
|
1758
|
-
}
|
|
1759
|
-
};
|
|
1760
|
-
|
|
1761
|
-
function streamLine(coordinates, stream, closed) {
|
|
1762
|
-
var i = -1, n = coordinates.length - closed, coordinate;
|
|
1763
|
-
stream.lineStart();
|
|
1764
|
-
while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);
|
|
1765
|
-
stream.lineEnd();
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
function streamPolygon(coordinates, stream) {
|
|
1769
|
-
var i = -1, n = coordinates.length;
|
|
1770
|
-
stream.polygonStart();
|
|
1771
|
-
while (++i < n) streamLine(coordinates[i], stream, 1);
|
|
1772
|
-
stream.polygonEnd();
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
function geoStream(object, stream) {
|
|
1776
|
-
if (object && streamObjectType.hasOwnProperty(object.type)) {
|
|
1777
|
-
streamObjectType[object.type](object, stream);
|
|
1778
|
-
} else {
|
|
1779
|
-
streamGeometry(object, stream);
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
new Adder();
|
|
1784
|
-
|
|
1785
|
-
// hello?
|
|
1786
|
-
|
|
1787
|
-
new Adder();
|
|
1788
|
-
|
|
1789
|
-
function rotationIdentity(lambda, phi) {
|
|
1790
|
-
return [abs(lambda) > pi ? lambda + Math.round(-lambda / tau) * tau : lambda, phi];
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
rotationIdentity.invert = rotationIdentity;
|
|
1794
|
-
|
|
1795
|
-
function clipBuffer() {
|
|
1796
|
-
var lines = [],
|
|
1797
|
-
line;
|
|
1798
|
-
return {
|
|
1799
|
-
point: function(x, y, m) {
|
|
1800
|
-
line.push([x, y, m]);
|
|
1801
|
-
},
|
|
1802
|
-
lineStart: function() {
|
|
1803
|
-
lines.push(line = []);
|
|
1804
|
-
},
|
|
1805
|
-
lineEnd: noop,
|
|
1806
|
-
rejoin: function() {
|
|
1807
|
-
if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
|
|
1808
|
-
},
|
|
1809
|
-
result: function() {
|
|
1810
|
-
var result = lines;
|
|
1811
|
-
lines = [];
|
|
1812
|
-
line = null;
|
|
1813
|
-
return result;
|
|
1814
|
-
}
|
|
1815
|
-
};
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
function pointEqual(a, b) {
|
|
1819
|
-
return abs(a[0] - b[0]) < epsilon && abs(a[1] - b[1]) < epsilon;
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
function Intersection(point, points, other, entry) {
|
|
1823
|
-
this.x = point;
|
|
1824
|
-
this.z = points;
|
|
1825
|
-
this.o = other; // another intersection
|
|
1826
|
-
this.e = entry; // is an entry?
|
|
1827
|
-
this.v = false; // visited
|
|
1828
|
-
this.n = this.p = null; // next & previous
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
// A generalized polygon clipping algorithm: given a polygon that has been cut
|
|
1832
|
-
// into its visible line segments, and rejoins the segments by interpolating
|
|
1833
|
-
// along the clip edge.
|
|
1834
|
-
function clipRejoin(segments, compareIntersection, startInside, interpolate, stream) {
|
|
1835
|
-
var subject = [],
|
|
1836
|
-
clip = [],
|
|
1837
|
-
i,
|
|
1838
|
-
n;
|
|
1839
|
-
|
|
1840
|
-
segments.forEach(function(segment) {
|
|
1841
|
-
if ((n = segment.length - 1) <= 0) return;
|
|
1842
|
-
var n, p0 = segment[0], p1 = segment[n], x;
|
|
1843
|
-
|
|
1844
|
-
if (pointEqual(p0, p1)) {
|
|
1845
|
-
if (!p0[2] && !p1[2]) {
|
|
1846
|
-
stream.lineStart();
|
|
1847
|
-
for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);
|
|
1848
|
-
stream.lineEnd();
|
|
1849
|
-
return;
|
|
1850
|
-
}
|
|
1851
|
-
// handle degenerate cases by moving the point
|
|
1852
|
-
p1[0] += 2 * epsilon;
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
subject.push(x = new Intersection(p0, segment, null, true));
|
|
1856
|
-
clip.push(x.o = new Intersection(p0, null, x, false));
|
|
1857
|
-
subject.push(x = new Intersection(p1, segment, null, false));
|
|
1858
|
-
clip.push(x.o = new Intersection(p1, null, x, true));
|
|
1859
|
-
});
|
|
1860
|
-
|
|
1861
|
-
if (!subject.length) return;
|
|
1862
|
-
|
|
1863
|
-
clip.sort(compareIntersection);
|
|
1864
|
-
link(subject);
|
|
1865
|
-
link(clip);
|
|
1866
|
-
|
|
1867
|
-
for (i = 0, n = clip.length; i < n; ++i) {
|
|
1868
|
-
clip[i].e = startInside = !startInside;
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
|
-
var start = subject[0],
|
|
1872
|
-
points,
|
|
1873
|
-
point;
|
|
1874
|
-
|
|
1875
|
-
while (1) {
|
|
1876
|
-
// Find first unvisited intersection.
|
|
1877
|
-
var current = start,
|
|
1878
|
-
isSubject = true;
|
|
1879
|
-
while (current.v) if ((current = current.n) === start) return;
|
|
1880
|
-
points = current.z;
|
|
1881
|
-
stream.lineStart();
|
|
1882
|
-
do {
|
|
1883
|
-
current.v = current.o.v = true;
|
|
1884
|
-
if (current.e) {
|
|
1885
|
-
if (isSubject) {
|
|
1886
|
-
for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);
|
|
1887
|
-
} else {
|
|
1888
|
-
interpolate(current.x, current.n.x, 1, stream);
|
|
1889
|
-
}
|
|
1890
|
-
current = current.n;
|
|
1891
|
-
} else {
|
|
1892
|
-
if (isSubject) {
|
|
1893
|
-
points = current.p.z;
|
|
1894
|
-
for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);
|
|
1895
|
-
} else {
|
|
1896
|
-
interpolate(current.x, current.p.x, -1, stream);
|
|
1897
|
-
}
|
|
1898
|
-
current = current.p;
|
|
1899
|
-
}
|
|
1900
|
-
current = current.o;
|
|
1901
|
-
points = current.z;
|
|
1902
|
-
isSubject = !isSubject;
|
|
1903
|
-
} while (!current.v);
|
|
1904
|
-
stream.lineEnd();
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
function link(array) {
|
|
1909
|
-
if (!(n = array.length)) return;
|
|
1910
|
-
var n,
|
|
1911
|
-
i = 0,
|
|
1912
|
-
a = array[0],
|
|
1913
|
-
b;
|
|
1914
|
-
while (++i < n) {
|
|
1915
|
-
a.n = b = array[i];
|
|
1916
|
-
b.p = a;
|
|
1917
|
-
a = b;
|
|
1918
|
-
}
|
|
1919
|
-
a.n = b = array[0];
|
|
1920
|
-
b.p = a;
|
|
1921
|
-
}
|
|
1922
|
-
|
|
1923
|
-
function clipLine(a, b, x0, y0, x1, y1) {
|
|
1924
|
-
var ax = a[0],
|
|
1925
|
-
ay = a[1],
|
|
1926
|
-
bx = b[0],
|
|
1927
|
-
by = b[1],
|
|
1928
|
-
t0 = 0,
|
|
1929
|
-
t1 = 1,
|
|
1930
|
-
dx = bx - ax,
|
|
1931
|
-
dy = by - ay,
|
|
1932
|
-
r;
|
|
1933
|
-
|
|
1934
|
-
r = x0 - ax;
|
|
1935
|
-
if (!dx && r > 0) return;
|
|
1936
|
-
r /= dx;
|
|
1937
|
-
if (dx < 0) {
|
|
1938
|
-
if (r < t0) return;
|
|
1939
|
-
if (r < t1) t1 = r;
|
|
1940
|
-
} else if (dx > 0) {
|
|
1941
|
-
if (r > t1) return;
|
|
1942
|
-
if (r > t0) t0 = r;
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
r = x1 - ax;
|
|
1946
|
-
if (!dx && r < 0) return;
|
|
1947
|
-
r /= dx;
|
|
1948
|
-
if (dx < 0) {
|
|
1949
|
-
if (r > t1) return;
|
|
1950
|
-
if (r > t0) t0 = r;
|
|
1951
|
-
} else if (dx > 0) {
|
|
1952
|
-
if (r < t0) return;
|
|
1953
|
-
if (r < t1) t1 = r;
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
r = y0 - ay;
|
|
1957
|
-
if (!dy && r > 0) return;
|
|
1958
|
-
r /= dy;
|
|
1959
|
-
if (dy < 0) {
|
|
1960
|
-
if (r < t0) return;
|
|
1961
|
-
if (r < t1) t1 = r;
|
|
1962
|
-
} else if (dy > 0) {
|
|
1963
|
-
if (r > t1) return;
|
|
1964
|
-
if (r > t0) t0 = r;
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
r = y1 - ay;
|
|
1968
|
-
if (!dy && r < 0) return;
|
|
1969
|
-
r /= dy;
|
|
1970
|
-
if (dy < 0) {
|
|
1971
|
-
if (r > t1) return;
|
|
1972
|
-
if (r > t0) t0 = r;
|
|
1973
|
-
} else if (dy > 0) {
|
|
1974
|
-
if (r < t0) return;
|
|
1975
|
-
if (r < t1) t1 = r;
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy;
|
|
1979
|
-
if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy;
|
|
1980
|
-
return true;
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
|
-
var clipMax = 1e9, clipMin = -clipMax;
|
|
1984
|
-
|
|
1985
|
-
// TODO Use d3-polygon’s polygonContains here for the ring check?
|
|
1986
|
-
// TODO Eliminate duplicate buffering in clipBuffer and polygon.push?
|
|
1987
|
-
|
|
1988
|
-
function clipRectangle(x0, y0, x1, y1) {
|
|
1989
|
-
|
|
1990
|
-
function visible(x, y) {
|
|
1991
|
-
return x0 <= x && x <= x1 && y0 <= y && y <= y1;
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
function interpolate(from, to, direction, stream) {
|
|
1995
|
-
var a = 0, a1 = 0;
|
|
1996
|
-
if (from == null
|
|
1997
|
-
|| (a = corner(from, direction)) !== (a1 = corner(to, direction))
|
|
1998
|
-
|| comparePoint(from, to) < 0 ^ direction > 0) {
|
|
1999
|
-
do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
|
|
2000
|
-
while ((a = (a + direction + 4) % 4) !== a1);
|
|
2001
|
-
} else {
|
|
2002
|
-
stream.point(to[0], to[1]);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
function corner(p, direction) {
|
|
2007
|
-
return abs(p[0] - x0) < epsilon ? direction > 0 ? 0 : 3
|
|
2008
|
-
: abs(p[0] - x1) < epsilon ? direction > 0 ? 2 : 1
|
|
2009
|
-
: abs(p[1] - y0) < epsilon ? direction > 0 ? 1 : 0
|
|
2010
|
-
: direction > 0 ? 3 : 2; // abs(p[1] - y1) < epsilon
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
function compareIntersection(a, b) {
|
|
2014
|
-
return comparePoint(a.x, b.x);
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
function comparePoint(a, b) {
|
|
2018
|
-
var ca = corner(a, 1),
|
|
2019
|
-
cb = corner(b, 1);
|
|
2020
|
-
return ca !== cb ? ca - cb
|
|
2021
|
-
: ca === 0 ? b[1] - a[1]
|
|
2022
|
-
: ca === 1 ? a[0] - b[0]
|
|
2023
|
-
: ca === 2 ? a[1] - b[1]
|
|
2024
|
-
: b[0] - a[0];
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
return function(stream) {
|
|
2028
|
-
var activeStream = stream,
|
|
2029
|
-
bufferStream = clipBuffer(),
|
|
2030
|
-
segments,
|
|
2031
|
-
polygon,
|
|
2032
|
-
ring,
|
|
2033
|
-
x__, y__, v__, // first point
|
|
2034
|
-
x_, y_, v_, // previous point
|
|
2035
|
-
first,
|
|
2036
|
-
clean;
|
|
2037
|
-
|
|
2038
|
-
var clipStream = {
|
|
2039
|
-
point: point,
|
|
2040
|
-
lineStart: lineStart,
|
|
2041
|
-
lineEnd: lineEnd,
|
|
2042
|
-
polygonStart: polygonStart,
|
|
2043
|
-
polygonEnd: polygonEnd
|
|
2044
|
-
};
|
|
2045
|
-
|
|
2046
|
-
function point(x, y) {
|
|
2047
|
-
if (visible(x, y)) activeStream.point(x, y);
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
function polygonInside() {
|
|
2051
|
-
var winding = 0;
|
|
2052
|
-
|
|
2053
|
-
for (var i = 0, n = polygon.length; i < n; ++i) {
|
|
2054
|
-
for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {
|
|
2055
|
-
a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];
|
|
2056
|
-
if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; }
|
|
2057
|
-
else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; }
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2061
|
-
return winding;
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
// Buffer geometry within a polygon and then clip it en masse.
|
|
2065
|
-
function polygonStart() {
|
|
2066
|
-
activeStream = bufferStream, segments = [], polygon = [], clean = true;
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
function polygonEnd() {
|
|
2070
|
-
var startInside = polygonInside(),
|
|
2071
|
-
cleanInside = clean && startInside,
|
|
2072
|
-
visible = (segments = merge(segments)).length;
|
|
2073
|
-
if (cleanInside || visible) {
|
|
2074
|
-
stream.polygonStart();
|
|
2075
|
-
if (cleanInside) {
|
|
2076
|
-
stream.lineStart();
|
|
2077
|
-
interpolate(null, null, 1, stream);
|
|
2078
|
-
stream.lineEnd();
|
|
2079
|
-
}
|
|
2080
|
-
if (visible) {
|
|
2081
|
-
clipRejoin(segments, compareIntersection, startInside, interpolate, stream);
|
|
2082
|
-
}
|
|
2083
|
-
stream.polygonEnd();
|
|
2084
|
-
}
|
|
2085
|
-
activeStream = stream, segments = polygon = ring = null;
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
function lineStart() {
|
|
2089
|
-
clipStream.point = linePoint;
|
|
2090
|
-
if (polygon) polygon.push(ring = []);
|
|
2091
|
-
first = true;
|
|
2092
|
-
v_ = false;
|
|
2093
|
-
x_ = y_ = NaN;
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
// TODO rather than special-case polygons, simply handle them separately.
|
|
2097
|
-
// Ideally, coincident intersection points should be jittered to avoid
|
|
2098
|
-
// clipping issues.
|
|
2099
|
-
function lineEnd() {
|
|
2100
|
-
if (segments) {
|
|
2101
|
-
linePoint(x__, y__);
|
|
2102
|
-
if (v__ && v_) bufferStream.rejoin();
|
|
2103
|
-
segments.push(bufferStream.result());
|
|
2104
|
-
}
|
|
2105
|
-
clipStream.point = point;
|
|
2106
|
-
if (v_) activeStream.lineEnd();
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
function linePoint(x, y) {
|
|
2110
|
-
var v = visible(x, y);
|
|
2111
|
-
if (polygon) ring.push([x, y]);
|
|
2112
|
-
if (first) {
|
|
2113
|
-
x__ = x, y__ = y, v__ = v;
|
|
2114
|
-
first = false;
|
|
2115
|
-
if (v) {
|
|
2116
|
-
activeStream.lineStart();
|
|
2117
|
-
activeStream.point(x, y);
|
|
2118
|
-
}
|
|
2119
|
-
} else {
|
|
2120
|
-
if (v && v_) activeStream.point(x, y);
|
|
2121
|
-
else {
|
|
2122
|
-
var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))],
|
|
2123
|
-
b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];
|
|
2124
|
-
if (clipLine(a, b, x0, y0, x1, y1)) {
|
|
2125
|
-
if (!v_) {
|
|
2126
|
-
activeStream.lineStart();
|
|
2127
|
-
activeStream.point(a[0], a[1]);
|
|
2128
|
-
}
|
|
2129
|
-
activeStream.point(b[0], b[1]);
|
|
2130
|
-
if (!v) activeStream.lineEnd();
|
|
2131
|
-
clean = false;
|
|
2132
|
-
} else if (v) {
|
|
2133
|
-
activeStream.lineStart();
|
|
2134
|
-
activeStream.point(x, y);
|
|
2135
|
-
clean = false;
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
x_ = x, y_ = y, v_ = v;
|
|
2140
|
-
}
|
|
2141
|
-
|
|
2142
|
-
return clipStream;
|
|
2143
|
-
};
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
var identity = x => x;
|
|
2147
|
-
|
|
2148
|
-
var areaSum = new Adder(),
|
|
2149
|
-
areaRingSum = new Adder(),
|
|
2150
|
-
x00$2,
|
|
2151
|
-
y00$2,
|
|
2152
|
-
x0$3,
|
|
2153
|
-
y0$3;
|
|
2154
|
-
|
|
2155
|
-
var areaStream = {
|
|
2156
|
-
point: noop,
|
|
2157
|
-
lineStart: noop,
|
|
2158
|
-
lineEnd: noop,
|
|
2159
|
-
polygonStart: function() {
|
|
2160
|
-
areaStream.lineStart = areaRingStart;
|
|
2161
|
-
areaStream.lineEnd = areaRingEnd;
|
|
2162
|
-
},
|
|
2163
|
-
polygonEnd: function() {
|
|
2164
|
-
areaStream.lineStart = areaStream.lineEnd = areaStream.point = noop;
|
|
2165
|
-
areaSum.add(abs(areaRingSum));
|
|
2166
|
-
areaRingSum = new Adder();
|
|
2167
|
-
},
|
|
2168
|
-
result: function() {
|
|
2169
|
-
var area = areaSum / 2;
|
|
2170
|
-
areaSum = new Adder();
|
|
2171
|
-
return area;
|
|
2172
|
-
}
|
|
2173
|
-
};
|
|
2174
|
-
|
|
2175
|
-
function areaRingStart() {
|
|
2176
|
-
areaStream.point = areaPointFirst;
|
|
2177
|
-
}
|
|
2178
|
-
|
|
2179
|
-
function areaPointFirst(x, y) {
|
|
2180
|
-
areaStream.point = areaPoint;
|
|
2181
|
-
x00$2 = x0$3 = x, y00$2 = y0$3 = y;
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
function areaPoint(x, y) {
|
|
2185
|
-
areaRingSum.add(y0$3 * x - x0$3 * y);
|
|
2186
|
-
x0$3 = x, y0$3 = y;
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
function areaRingEnd() {
|
|
2190
|
-
areaPoint(x00$2, y00$2);
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
var x0$2 = Infinity,
|
|
2194
|
-
y0$2 = x0$2,
|
|
2195
|
-
x1 = -x0$2,
|
|
2196
|
-
y1 = x1;
|
|
2197
|
-
|
|
2198
|
-
var boundsStream = {
|
|
2199
|
-
point: boundsPoint,
|
|
2200
|
-
lineStart: noop,
|
|
2201
|
-
lineEnd: noop,
|
|
2202
|
-
polygonStart: noop,
|
|
2203
|
-
polygonEnd: noop,
|
|
2204
|
-
result: function() {
|
|
2205
|
-
var bounds = [[x0$2, y0$2], [x1, y1]];
|
|
2206
|
-
x1 = y1 = -(y0$2 = x0$2 = Infinity);
|
|
2207
|
-
return bounds;
|
|
2208
|
-
}
|
|
2209
|
-
};
|
|
2210
|
-
|
|
2211
|
-
function boundsPoint(x, y) {
|
|
2212
|
-
if (x < x0$2) x0$2 = x;
|
|
2213
|
-
if (x > x1) x1 = x;
|
|
2214
|
-
if (y < y0$2) y0$2 = y;
|
|
2215
|
-
if (y > y1) y1 = y;
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
// TODO Enforce positive area for exterior, negative area for interior?
|
|
2219
|
-
|
|
2220
|
-
var X0 = 0,
|
|
2221
|
-
Y0 = 0,
|
|
2222
|
-
Z0 = 0,
|
|
2223
|
-
X1 = 0,
|
|
2224
|
-
Y1 = 0,
|
|
2225
|
-
Z1 = 0,
|
|
2226
|
-
X2 = 0,
|
|
2227
|
-
Y2 = 0,
|
|
2228
|
-
Z2 = 0,
|
|
2229
|
-
x00$1,
|
|
2230
|
-
y00$1,
|
|
2231
|
-
x0$1,
|
|
2232
|
-
y0$1;
|
|
2233
|
-
|
|
2234
|
-
var centroidStream = {
|
|
2235
|
-
point: centroidPoint,
|
|
2236
|
-
lineStart: centroidLineStart,
|
|
2237
|
-
lineEnd: centroidLineEnd,
|
|
2238
|
-
polygonStart: function() {
|
|
2239
|
-
centroidStream.lineStart = centroidRingStart;
|
|
2240
|
-
centroidStream.lineEnd = centroidRingEnd;
|
|
2241
|
-
},
|
|
2242
|
-
polygonEnd: function() {
|
|
2243
|
-
centroidStream.point = centroidPoint;
|
|
2244
|
-
centroidStream.lineStart = centroidLineStart;
|
|
2245
|
-
centroidStream.lineEnd = centroidLineEnd;
|
|
2246
|
-
},
|
|
2247
|
-
result: function() {
|
|
2248
|
-
var centroid = Z2 ? [X2 / Z2, Y2 / Z2]
|
|
2249
|
-
: Z1 ? [X1 / Z1, Y1 / Z1]
|
|
2250
|
-
: Z0 ? [X0 / Z0, Y0 / Z0]
|
|
2251
|
-
: [NaN, NaN];
|
|
2252
|
-
X0 = Y0 = Z0 =
|
|
2253
|
-
X1 = Y1 = Z1 =
|
|
2254
|
-
X2 = Y2 = Z2 = 0;
|
|
2255
|
-
return centroid;
|
|
2256
|
-
}
|
|
2257
|
-
};
|
|
2258
|
-
|
|
2259
|
-
function centroidPoint(x, y) {
|
|
2260
|
-
X0 += x;
|
|
2261
|
-
Y0 += y;
|
|
2262
|
-
++Z0;
|
|
2263
|
-
}
|
|
2264
|
-
|
|
2265
|
-
function centroidLineStart() {
|
|
2266
|
-
centroidStream.point = centroidPointFirstLine;
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
function centroidPointFirstLine(x, y) {
|
|
2270
|
-
centroidStream.point = centroidPointLine;
|
|
2271
|
-
centroidPoint(x0$1 = x, y0$1 = y);
|
|
2272
|
-
}
|
|
2273
|
-
|
|
2274
|
-
function centroidPointLine(x, y) {
|
|
2275
|
-
var dx = x - x0$1, dy = y - y0$1, z = sqrt(dx * dx + dy * dy);
|
|
2276
|
-
X1 += z * (x0$1 + x) / 2;
|
|
2277
|
-
Y1 += z * (y0$1 + y) / 2;
|
|
2278
|
-
Z1 += z;
|
|
2279
|
-
centroidPoint(x0$1 = x, y0$1 = y);
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
function centroidLineEnd() {
|
|
2283
|
-
centroidStream.point = centroidPoint;
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
function centroidRingStart() {
|
|
2287
|
-
centroidStream.point = centroidPointFirstRing;
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
function centroidRingEnd() {
|
|
2291
|
-
centroidPointRing(x00$1, y00$1);
|
|
2292
|
-
}
|
|
2293
|
-
|
|
2294
|
-
function centroidPointFirstRing(x, y) {
|
|
2295
|
-
centroidStream.point = centroidPointRing;
|
|
2296
|
-
centroidPoint(x00$1 = x0$1 = x, y00$1 = y0$1 = y);
|
|
2297
|
-
}
|
|
2298
|
-
|
|
2299
|
-
function centroidPointRing(x, y) {
|
|
2300
|
-
var dx = x - x0$1,
|
|
2301
|
-
dy = y - y0$1,
|
|
2302
|
-
z = sqrt(dx * dx + dy * dy);
|
|
2303
|
-
|
|
2304
|
-
X1 += z * (x0$1 + x) / 2;
|
|
2305
|
-
Y1 += z * (y0$1 + y) / 2;
|
|
2306
|
-
Z1 += z;
|
|
2307
|
-
|
|
2308
|
-
z = y0$1 * x - x0$1 * y;
|
|
2309
|
-
X2 += z * (x0$1 + x);
|
|
2310
|
-
Y2 += z * (y0$1 + y);
|
|
2311
|
-
Z2 += z * 3;
|
|
2312
|
-
centroidPoint(x0$1 = x, y0$1 = y);
|
|
2313
|
-
}
|
|
2314
|
-
|
|
2315
|
-
function PathContext(context) {
|
|
2316
|
-
this._context = context;
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
PathContext.prototype = {
|
|
2320
|
-
_radius: 4.5,
|
|
2321
|
-
pointRadius: function(_) {
|
|
2322
|
-
return this._radius = _, this;
|
|
2323
|
-
},
|
|
2324
|
-
polygonStart: function() {
|
|
2325
|
-
this._line = 0;
|
|
2326
|
-
},
|
|
2327
|
-
polygonEnd: function() {
|
|
2328
|
-
this._line = NaN;
|
|
2329
|
-
},
|
|
2330
|
-
lineStart: function() {
|
|
2331
|
-
this._point = 0;
|
|
2332
|
-
},
|
|
2333
|
-
lineEnd: function() {
|
|
2334
|
-
if (this._line === 0) this._context.closePath();
|
|
2335
|
-
this._point = NaN;
|
|
2336
|
-
},
|
|
2337
|
-
point: function(x, y) {
|
|
2338
|
-
switch (this._point) {
|
|
2339
|
-
case 0: {
|
|
2340
|
-
this._context.moveTo(x, y);
|
|
2341
|
-
this._point = 1;
|
|
2342
|
-
break;
|
|
2343
|
-
}
|
|
2344
|
-
case 1: {
|
|
2345
|
-
this._context.lineTo(x, y);
|
|
2346
|
-
break;
|
|
2347
|
-
}
|
|
2348
|
-
default: {
|
|
2349
|
-
this._context.moveTo(x + this._radius, y);
|
|
2350
|
-
this._context.arc(x, y, this._radius, 0, tau);
|
|
2351
|
-
break;
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
},
|
|
2355
|
-
result: noop
|
|
2356
|
-
};
|
|
2357
|
-
|
|
2358
|
-
var lengthSum = new Adder(),
|
|
2359
|
-
lengthRing,
|
|
2360
|
-
x00,
|
|
2361
|
-
y00,
|
|
2362
|
-
x0,
|
|
2363
|
-
y0;
|
|
2364
|
-
|
|
2365
|
-
var lengthStream = {
|
|
2366
|
-
point: noop,
|
|
2367
|
-
lineStart: function() {
|
|
2368
|
-
lengthStream.point = lengthPointFirst;
|
|
2369
|
-
},
|
|
2370
|
-
lineEnd: function() {
|
|
2371
|
-
if (lengthRing) lengthPoint(x00, y00);
|
|
2372
|
-
lengthStream.point = noop;
|
|
2373
|
-
},
|
|
2374
|
-
polygonStart: function() {
|
|
2375
|
-
lengthRing = true;
|
|
2376
|
-
},
|
|
2377
|
-
polygonEnd: function() {
|
|
2378
|
-
lengthRing = null;
|
|
2379
|
-
},
|
|
2380
|
-
result: function() {
|
|
2381
|
-
var length = +lengthSum;
|
|
2382
|
-
lengthSum = new Adder();
|
|
2383
|
-
return length;
|
|
2384
|
-
}
|
|
2385
|
-
};
|
|
2386
|
-
|
|
2387
|
-
function lengthPointFirst(x, y) {
|
|
2388
|
-
lengthStream.point = lengthPoint;
|
|
2389
|
-
x00 = x0 = x, y00 = y0 = y;
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2392
|
-
function lengthPoint(x, y) {
|
|
2393
|
-
x0 -= x, y0 -= y;
|
|
2394
|
-
lengthSum.add(sqrt(x0 * x0 + y0 * y0));
|
|
2395
|
-
x0 = x, y0 = y;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
function PathString() {
|
|
2399
|
-
this._string = [];
|
|
2400
|
-
}
|
|
2401
|
-
|
|
2402
|
-
PathString.prototype = {
|
|
2403
|
-
_radius: 4.5,
|
|
2404
|
-
_circle: circle(4.5),
|
|
2405
|
-
pointRadius: function(_) {
|
|
2406
|
-
if ((_ = +_) !== this._radius) this._radius = _, this._circle = null;
|
|
2407
|
-
return this;
|
|
2408
|
-
},
|
|
2409
|
-
polygonStart: function() {
|
|
2410
|
-
this._line = 0;
|
|
2411
|
-
},
|
|
2412
|
-
polygonEnd: function() {
|
|
2413
|
-
this._line = NaN;
|
|
2414
|
-
},
|
|
2415
|
-
lineStart: function() {
|
|
2416
|
-
this._point = 0;
|
|
2417
|
-
},
|
|
2418
|
-
lineEnd: function() {
|
|
2419
|
-
if (this._line === 0) this._string.push("Z");
|
|
2420
|
-
this._point = NaN;
|
|
2421
|
-
},
|
|
2422
|
-
point: function(x, y) {
|
|
2423
|
-
switch (this._point) {
|
|
2424
|
-
case 0: {
|
|
2425
|
-
this._string.push("M", x, ",", y);
|
|
2426
|
-
this._point = 1;
|
|
2427
|
-
break;
|
|
2428
|
-
}
|
|
2429
|
-
case 1: {
|
|
2430
|
-
this._string.push("L", x, ",", y);
|
|
2431
|
-
break;
|
|
2432
|
-
}
|
|
2433
|
-
default: {
|
|
2434
|
-
if (this._circle == null) this._circle = circle(this._radius);
|
|
2435
|
-
this._string.push("M", x, ",", y, this._circle);
|
|
2436
|
-
break;
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
},
|
|
2440
|
-
result: function() {
|
|
2441
|
-
if (this._string.length) {
|
|
2442
|
-
var result = this._string.join("");
|
|
2443
|
-
this._string = [];
|
|
2444
|
-
return result;
|
|
2445
|
-
} else {
|
|
2446
|
-
return null;
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
};
|
|
2450
|
-
|
|
2451
|
-
function circle(radius) {
|
|
2452
|
-
return "m0," + radius
|
|
2453
|
-
+ "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius
|
|
2454
|
-
+ "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius
|
|
2455
|
-
+ "z";
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
function geoPath(projection, context) {
|
|
2459
|
-
var pointRadius = 4.5,
|
|
2460
|
-
projectionStream,
|
|
2461
|
-
contextStream;
|
|
2462
|
-
|
|
2463
|
-
function path(object) {
|
|
2464
|
-
if (object) {
|
|
2465
|
-
if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
|
|
2466
|
-
geoStream(object, projectionStream(contextStream));
|
|
2467
|
-
}
|
|
2468
|
-
return contextStream.result();
|
|
2469
|
-
}
|
|
2470
|
-
|
|
2471
|
-
path.area = function(object) {
|
|
2472
|
-
geoStream(object, projectionStream(areaStream));
|
|
2473
|
-
return areaStream.result();
|
|
2474
|
-
};
|
|
2475
|
-
|
|
2476
|
-
path.measure = function(object) {
|
|
2477
|
-
geoStream(object, projectionStream(lengthStream));
|
|
2478
|
-
return lengthStream.result();
|
|
2479
|
-
};
|
|
2480
|
-
|
|
2481
|
-
path.bounds = function(object) {
|
|
2482
|
-
geoStream(object, projectionStream(boundsStream));
|
|
2483
|
-
return boundsStream.result();
|
|
2484
|
-
};
|
|
2485
|
-
|
|
2486
|
-
path.centroid = function(object) {
|
|
2487
|
-
geoStream(object, projectionStream(centroidStream));
|
|
2488
|
-
return centroidStream.result();
|
|
2489
|
-
};
|
|
2490
|
-
|
|
2491
|
-
path.projection = function(_) {
|
|
2492
|
-
return arguments.length ? (projectionStream = _ == null ? (projection = null, identity) : (projection = _).stream, path) : projection;
|
|
2493
|
-
};
|
|
2494
|
-
|
|
2495
|
-
path.context = function(_) {
|
|
2496
|
-
if (!arguments.length) return context;
|
|
2497
|
-
contextStream = _ == null ? (context = null, new PathString) : new PathContext(context = _);
|
|
2498
|
-
if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
|
|
2499
|
-
return path;
|
|
2500
|
-
};
|
|
2501
|
-
|
|
2502
|
-
path.pointRadius = function(_) {
|
|
2503
|
-
if (!arguments.length) return pointRadius;
|
|
2504
|
-
pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_);
|
|
2505
|
-
return path;
|
|
2506
|
-
};
|
|
2507
|
-
|
|
2508
|
-
return path.projection(projection).context(context);
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
|
-
function transformer(methods) {
|
|
2512
|
-
return function(stream) {
|
|
2513
|
-
var s = new TransformStream;
|
|
2514
|
-
for (var key in methods) s[key] = methods[key];
|
|
2515
|
-
s.stream = stream;
|
|
2516
|
-
return s;
|
|
2517
|
-
};
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
function TransformStream() {}
|
|
2521
|
-
|
|
2522
|
-
TransformStream.prototype = {
|
|
2523
|
-
constructor: TransformStream,
|
|
2524
|
-
point: function(x, y) { this.stream.point(x, y); },
|
|
2525
|
-
sphere: function() { this.stream.sphere(); },
|
|
2526
|
-
lineStart: function() { this.stream.lineStart(); },
|
|
2527
|
-
lineEnd: function() { this.stream.lineEnd(); },
|
|
2528
|
-
polygonStart: function() { this.stream.polygonStart(); },
|
|
2529
|
-
polygonEnd: function() { this.stream.polygonEnd(); }
|
|
2530
|
-
};
|
|
2531
|
-
|
|
2532
|
-
function fit(projection, fitBounds, object) {
|
|
2533
|
-
var clip = projection.clipExtent && projection.clipExtent();
|
|
2534
|
-
projection.scale(150).translate([0, 0]);
|
|
2535
|
-
if (clip != null) projection.clipExtent(null);
|
|
2536
|
-
geoStream(object, projection.stream(boundsStream));
|
|
2537
|
-
fitBounds(boundsStream.result());
|
|
2538
|
-
if (clip != null) projection.clipExtent(clip);
|
|
2539
|
-
return projection;
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
function fitExtent(projection, extent, object) {
|
|
2543
|
-
return fit(projection, function(b) {
|
|
2544
|
-
var w = extent[1][0] - extent[0][0],
|
|
2545
|
-
h = extent[1][1] - extent[0][1],
|
|
2546
|
-
k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])),
|
|
2547
|
-
x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2,
|
|
2548
|
-
y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
|
|
2549
|
-
projection.scale(150 * k).translate([x, y]);
|
|
2550
|
-
}, object);
|
|
2551
|
-
}
|
|
2552
|
-
|
|
2553
|
-
function fitSize(projection, size, object) {
|
|
2554
|
-
return fitExtent(projection, [[0, 0], size], object);
|
|
2555
|
-
}
|
|
2556
|
-
|
|
2557
|
-
function fitWidth(projection, width, object) {
|
|
2558
|
-
return fit(projection, function(b) {
|
|
2559
|
-
var w = +width,
|
|
2560
|
-
k = w / (b[1][0] - b[0][0]),
|
|
2561
|
-
x = (w - k * (b[1][0] + b[0][0])) / 2,
|
|
2562
|
-
y = -k * b[0][1];
|
|
2563
|
-
projection.scale(150 * k).translate([x, y]);
|
|
2564
|
-
}, object);
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
|
-
function fitHeight(projection, height, object) {
|
|
2568
|
-
return fit(projection, function(b) {
|
|
2569
|
-
var h = +height,
|
|
2570
|
-
k = h / (b[1][1] - b[0][1]),
|
|
2571
|
-
x = -k * b[0][0],
|
|
2572
|
-
y = (h - k * (b[1][1] + b[0][1])) / 2;
|
|
2573
|
-
projection.scale(150 * k).translate([x, y]);
|
|
2574
|
-
}, object);
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
function equirectangularRaw(lambda, phi) {
|
|
2578
|
-
return [lambda, phi];
|
|
2579
|
-
}
|
|
2580
|
-
|
|
2581
|
-
equirectangularRaw.invert = equirectangularRaw;
|
|
2582
|
-
|
|
2583
|
-
function geoIdentity() {
|
|
2584
|
-
var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, // scale, translate and reflect
|
|
2585
|
-
alpha = 0, ca, sa, // angle
|
|
2586
|
-
x0 = null, y0, x1, y1, // clip extent
|
|
2587
|
-
kx = 1, ky = 1,
|
|
2588
|
-
transform = transformer({
|
|
2589
|
-
point: function(x, y) {
|
|
2590
|
-
var p = projection([x, y]);
|
|
2591
|
-
this.stream.point(p[0], p[1]);
|
|
2592
|
-
}
|
|
2593
|
-
}),
|
|
2594
|
-
postclip = identity,
|
|
2595
|
-
cache,
|
|
2596
|
-
cacheStream;
|
|
2597
|
-
|
|
2598
|
-
function reset() {
|
|
2599
|
-
kx = k * sx;
|
|
2600
|
-
ky = k * sy;
|
|
2601
|
-
cache = cacheStream = null;
|
|
2602
|
-
return projection;
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2605
|
-
function projection (p) {
|
|
2606
|
-
var x = p[0] * kx, y = p[1] * ky;
|
|
2607
|
-
if (alpha) {
|
|
2608
|
-
var t = y * ca - x * sa;
|
|
2609
|
-
x = x * ca + y * sa;
|
|
2610
|
-
y = t;
|
|
2611
|
-
}
|
|
2612
|
-
return [x + tx, y + ty];
|
|
2613
|
-
}
|
|
2614
|
-
projection.invert = function(p) {
|
|
2615
|
-
var x = p[0] - tx, y = p[1] - ty;
|
|
2616
|
-
if (alpha) {
|
|
2617
|
-
var t = y * ca + x * sa;
|
|
2618
|
-
x = x * ca - y * sa;
|
|
2619
|
-
y = t;
|
|
2620
|
-
}
|
|
2621
|
-
return [x / kx, y / ky];
|
|
2622
|
-
};
|
|
2623
|
-
projection.stream = function(stream) {
|
|
2624
|
-
return cache && cacheStream === stream ? cache : cache = transform(postclip(cacheStream = stream));
|
|
2625
|
-
};
|
|
2626
|
-
projection.postclip = function(_) {
|
|
2627
|
-
return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;
|
|
2628
|
-
};
|
|
2629
|
-
projection.clipExtent = function(_) {
|
|
2630
|
-
return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
|
|
2631
|
-
};
|
|
2632
|
-
projection.scale = function(_) {
|
|
2633
|
-
return arguments.length ? (k = +_, reset()) : k;
|
|
2634
|
-
};
|
|
2635
|
-
projection.translate = function(_) {
|
|
2636
|
-
return arguments.length ? (tx = +_[0], ty = +_[1], reset()) : [tx, ty];
|
|
2637
|
-
};
|
|
2638
|
-
projection.angle = function(_) {
|
|
2639
|
-
return arguments.length ? (alpha = _ % 360 * radians, sa = sin(alpha), ca = cos(alpha), reset()) : alpha * degrees;
|
|
2640
|
-
};
|
|
2641
|
-
projection.reflectX = function(_) {
|
|
2642
|
-
return arguments.length ? (sx = _ ? -1 : 1, reset()) : sx < 0;
|
|
2643
|
-
};
|
|
2644
|
-
projection.reflectY = function(_) {
|
|
2645
|
-
return arguments.length ? (sy = _ ? -1 : 1, reset()) : sy < 0;
|
|
2646
|
-
};
|
|
2647
|
-
projection.fitExtent = function(extent, object) {
|
|
2648
|
-
return fitExtent(projection, extent, object);
|
|
2649
|
-
};
|
|
2650
|
-
projection.fitSize = function(size, object) {
|
|
2651
|
-
return fitSize(projection, size, object);
|
|
2652
|
-
};
|
|
2653
|
-
projection.fitWidth = function(width, object) {
|
|
2654
|
-
return fitWidth(projection, width, object);
|
|
2655
|
-
};
|
|
2656
|
-
projection.fitHeight = function(height, object) {
|
|
2657
|
-
return fitHeight(projection, height, object);
|
|
2658
|
-
};
|
|
2659
|
-
|
|
2660
|
-
return projection;
|
|
2661
|
-
}
|
|
2662
|
-
|
|
2663
|
-
var parseSvgPath = parse;
|
|
2664
|
-
|
|
2665
|
-
/**
|
|
2666
|
-
* expected argument lengths
|
|
2667
|
-
* @type {Object}
|
|
2668
|
-
*/
|
|
2669
|
-
|
|
2670
|
-
var length = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0};
|
|
2671
|
-
|
|
2672
|
-
/**
|
|
2673
|
-
* segment pattern
|
|
2674
|
-
* @type {RegExp}
|
|
2675
|
-
*/
|
|
2676
|
-
|
|
2677
|
-
var segment = /([astvzqmhlc])([^astvzqmhlc]*)/ig;
|
|
2678
|
-
|
|
2679
|
-
/**
|
|
2680
|
-
* parse an svg path data string. Generates an Array
|
|
2681
|
-
* of commands where each command is an Array of the
|
|
2682
|
-
* form `[command, arg1, arg2, ...]`
|
|
2683
|
-
*
|
|
2684
|
-
* @param {String} path
|
|
2685
|
-
* @return {Array}
|
|
2686
|
-
*/
|
|
2687
|
-
|
|
2688
|
-
function parse(path) {
|
|
2689
|
-
var data = [];
|
|
2690
|
-
path.replace(segment, function(_, command, args){
|
|
2691
|
-
var type = command.toLowerCase();
|
|
2692
|
-
args = parseValues(args);
|
|
2693
|
-
|
|
2694
|
-
// overloaded moveTo
|
|
2695
|
-
if (type == 'm' && args.length > 2) {
|
|
2696
|
-
data.push([command].concat(args.splice(0, 2)));
|
|
2697
|
-
type = 'l';
|
|
2698
|
-
command = command == 'm' ? 'l' : 'L';
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
|
-
while (true) {
|
|
2702
|
-
if (args.length == length[type]) {
|
|
2703
|
-
args.unshift(command);
|
|
2704
|
-
return data.push(args)
|
|
2705
|
-
}
|
|
2706
|
-
if (args.length < length[type]) throw new Error('malformed path data')
|
|
2707
|
-
data.push([command].concat(args.splice(0, length[type])));
|
|
2708
|
-
}
|
|
2709
|
-
});
|
|
2710
|
-
return data
|
|
2711
|
-
}
|
|
2712
|
-
|
|
2713
|
-
var number = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;
|
|
2714
|
-
|
|
2715
|
-
function parseValues(args) {
|
|
2716
|
-
var numbers = args.match(number);
|
|
2717
|
-
return numbers ? numbers.map(Number) : []
|
|
2718
|
-
}
|
|
2719
|
-
|
|
2720
|
-
function simplifyLinesPath(path) {
|
|
2721
|
-
const parsed = parseSvgPath(path).map(values => values.map((v, i) => {
|
|
2722
|
-
if (i > 0) return Math.round(v);
|
|
2723
|
-
return v;
|
|
2724
|
-
}));
|
|
2725
|
-
const simplifiedPath = [];
|
|
2726
|
-
for (let i = 0; i < parsed.length - 1; ++i) {
|
|
2727
|
-
const current = parsed[i];
|
|
2728
|
-
let next = parsed[i + 1];
|
|
2729
|
-
simplifiedPath.push(current);
|
|
2730
|
-
let sameX = current[1] === next[1];
|
|
2731
|
-
let sameY = current[2] === next[2];
|
|
2732
|
-
if (sameX) {
|
|
2733
|
-
while(sameX) {
|
|
2734
|
-
i += 1;
|
|
2735
|
-
next = parsed[i + 1];
|
|
2736
|
-
sameX = next[0] === "L" && current[1] === next[1];
|
|
2737
|
-
}
|
|
2738
|
-
i -= 1;
|
|
2739
|
-
}
|
|
2740
|
-
if (sameY) {
|
|
2741
|
-
while(sameY) {
|
|
2742
|
-
i += 1;
|
|
2743
|
-
next = parsed[i + 1];
|
|
2744
|
-
sameY = next[0] === "L" && current[2] === next[2];
|
|
2745
|
-
}
|
|
2746
|
-
i -= 1;
|
|
2747
|
-
}
|
|
2748
|
-
}
|
|
2749
|
-
simplifiedPath.push(parsed[parsed.length - 1]);
|
|
2750
|
-
return instructionsToPath(simplifiedPath);
|
|
2751
|
-
}
|
|
2752
|
-
|
|
2753
|
-
function instructionsToPath(data) {
|
|
2754
|
-
let str = '';
|
|
2755
|
-
data.forEach(ins => {
|
|
2756
|
-
for (let i = 0; i < ins.length; ++i) {
|
|
2757
|
-
let val = ins[i];
|
|
2758
|
-
if (i > 0) val = Math.round(val);
|
|
2759
|
-
str += val + (i === ins.length - 1 ? '' : ' ');
|
|
2760
|
-
}
|
|
2761
|
-
});
|
|
2762
|
-
return str;
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
1647
|
function pointInBox(p, box) {
|
|
2766
1648
|
return !(p.x < box.left || p.x > box.right || p.y > box.bottom || p.y < box.top)
|
|
2767
1649
|
}
|
|
@@ -2822,21 +1704,32 @@ function computeContours(boundingBoxes, pageDimensions) {
|
|
|
2822
1704
|
const maxY = Math.ceil(Math.max(...offsetBoxes.map(rect => rect.bottom)));
|
|
2823
1705
|
const maxNbPixels = 20000;
|
|
2824
1706
|
const downscaleFactor = (maxX * maxY) / maxNbPixels;
|
|
2825
|
-
const
|
|
2826
|
-
const
|
|
2827
|
-
|
|
2828
|
-
const
|
|
2829
|
-
|
|
2830
|
-
|
|
1707
|
+
const widthArrayX = Math.ceil(maxX / downscaleFactor);
|
|
1708
|
+
const widthArrayY = Math.ceil(maxY / downscaleFactor);
|
|
1709
|
+
const pixelsByStepX = (maxX) / widthArrayX;
|
|
1710
|
+
const pixelsByStepY = (maxY) / widthArrayY;
|
|
1711
|
+
const values = new Array(widthArrayX * widthArrayY); // one coordinate per pixel
|
|
1712
|
+
for (let j = 0, k = 0; j < widthArrayY; ++j) {
|
|
1713
|
+
for (let i = 0; i < widthArrayX; ++i, ++k) {
|
|
2831
1714
|
values[k] = pointInBoxes({x: i * downscaleFactor, y: j * downscaleFactor}, offsetBoxes) ? 1 : 0;
|
|
2832
1715
|
}
|
|
2833
1716
|
}
|
|
2834
|
-
|
|
2835
|
-
const
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
1717
|
+
|
|
1718
|
+
const computedContours = contours().size([widthArrayX, widthArrayY]).thresholds([1])(values)[0];
|
|
1719
|
+
let holes = '';
|
|
1720
|
+
for (let polygon of computedContours.coordinates) {
|
|
1721
|
+
for (let ring of polygon) {
|
|
1722
|
+
for (let i = 0; i < ring.length; ++i) {
|
|
1723
|
+
const point = ring[i];
|
|
1724
|
+
const x = point[0] * pixelsByStepX + minX;
|
|
1725
|
+
const y = point[1] * pixelsByStepY + minY;
|
|
1726
|
+
if (!i) holes += `M${x} ${y}`;
|
|
1727
|
+
else holes += `L ${x} ${y}`;
|
|
1728
|
+
}
|
|
1729
|
+
holes += 'Z';
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
return `${_pathWithHoles} ${holes}`;
|
|
2840
1733
|
}
|
|
2841
1734
|
|
|
2842
1735
|
/*!
|
|
@@ -3844,9 +2737,9 @@ function create_fragment$1(ctx) {
|
|
|
3844
2737
|
insert(target, div, anchor);
|
|
3845
2738
|
/*div_binding*/ ctx[6](div);
|
|
3846
2739
|
},
|
|
3847
|
-
p: noop$
|
|
3848
|
-
i: noop$
|
|
3849
|
-
o: noop$
|
|
2740
|
+
p: noop$1,
|
|
2741
|
+
i: noop$1,
|
|
2742
|
+
o: noop$1,
|
|
3850
2743
|
d(detaching) {
|
|
3851
2744
|
if (detaching) detach(div);
|
|
3852
2745
|
/*div_binding*/ ctx[6](null);
|
|
@@ -4568,8 +3461,8 @@ function create_if_block_3(ctx) {
|
|
|
4568
3461
|
each_blocks.length = each_value_1.length;
|
|
4569
3462
|
}
|
|
4570
3463
|
},
|
|
4571
|
-
i: noop$
|
|
4572
|
-
o: noop$
|
|
3464
|
+
i: noop$1,
|
|
3465
|
+
o: noop$1,
|
|
4573
3466
|
d(detaching) {
|
|
4574
3467
|
if (detaching) detach(select);
|
|
4575
3468
|
destroy_each(each_blocks, detaching);
|
|
@@ -4636,8 +3529,8 @@ function create_if_block_2(ctx) {
|
|
|
4636
3529
|
|
|
4637
3530
|
if (dirty[0] & /*allCurrentPropDefs, propsByType*/ 24576 && t1_value !== (t1_value = /*allCurrentPropDefs*/ ctx[14][/*selectedName*/ ctx[55]].displayed + "")) set_data(t1, t1_value);
|
|
4638
3531
|
},
|
|
4639
|
-
i: noop$
|
|
4640
|
-
o: noop$
|
|
3532
|
+
i: noop$1,
|
|
3533
|
+
o: noop$1,
|
|
4641
3534
|
d(detaching) {
|
|
4642
3535
|
if (detaching) detach(input);
|
|
4643
3536
|
if (detaching) detach(t0);
|