gs-maplibre-draw 0.0.1
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/index.js +1076 -0
- package/dist/index.umd.cjs +1 -0
- package/dist/vite.svg +1 -0
- package/index.d.ts +21 -0
- package/package.json +35 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1076 @@
|
|
|
1
|
+
const { abs: R, cos: N, sin: U, acos: et, atan2: J, sqrt: F, pow: L } = Math;
|
|
2
|
+
function $(o) {
|
|
3
|
+
return o < 0 ? -L(-o, 1 / 3) : L(o, 1 / 3);
|
|
4
|
+
}
|
|
5
|
+
const tt = Math.PI, X = 2 * tt, P = tt / 2, nt = 1e-6, Q = Number.MAX_SAFE_INTEGER || 9007199254740991, H = Number.MIN_SAFE_INTEGER || -9007199254740991, it = { x: 0, y: 0, z: 0 }, y = {
|
|
6
|
+
// Legendre-Gauss abscissae with n=24 (x_i values, defined at i=n as the roots of the nth order Legendre polynomial Pn(x))
|
|
7
|
+
Tvalues: [
|
|
8
|
+
-0.06405689286260563,
|
|
9
|
+
0.06405689286260563,
|
|
10
|
+
-0.1911188674736163,
|
|
11
|
+
0.1911188674736163,
|
|
12
|
+
-0.3150426796961634,
|
|
13
|
+
0.3150426796961634,
|
|
14
|
+
-0.4337935076260451,
|
|
15
|
+
0.4337935076260451,
|
|
16
|
+
-0.5454214713888396,
|
|
17
|
+
0.5454214713888396,
|
|
18
|
+
-0.6480936519369755,
|
|
19
|
+
0.6480936519369755,
|
|
20
|
+
-0.7401241915785544,
|
|
21
|
+
0.7401241915785544,
|
|
22
|
+
-0.820001985973903,
|
|
23
|
+
0.820001985973903,
|
|
24
|
+
-0.8864155270044011,
|
|
25
|
+
0.8864155270044011,
|
|
26
|
+
-0.9382745520027328,
|
|
27
|
+
0.9382745520027328,
|
|
28
|
+
-0.9747285559713095,
|
|
29
|
+
0.9747285559713095,
|
|
30
|
+
-0.9951872199970213,
|
|
31
|
+
0.9951872199970213
|
|
32
|
+
],
|
|
33
|
+
// Legendre-Gauss weights with n=24 (w_i values, defined by a function linked to in the Bezier primer article)
|
|
34
|
+
Cvalues: [
|
|
35
|
+
0.12793819534675216,
|
|
36
|
+
0.12793819534675216,
|
|
37
|
+
0.1258374563468283,
|
|
38
|
+
0.1258374563468283,
|
|
39
|
+
0.12167047292780339,
|
|
40
|
+
0.12167047292780339,
|
|
41
|
+
0.1155056680537256,
|
|
42
|
+
0.1155056680537256,
|
|
43
|
+
0.10744427011596563,
|
|
44
|
+
0.10744427011596563,
|
|
45
|
+
0.09761865210411388,
|
|
46
|
+
0.09761865210411388,
|
|
47
|
+
0.08619016153195327,
|
|
48
|
+
0.08619016153195327,
|
|
49
|
+
0.0733464814110803,
|
|
50
|
+
0.0733464814110803,
|
|
51
|
+
0.05929858491543678,
|
|
52
|
+
0.05929858491543678,
|
|
53
|
+
0.04427743881741981,
|
|
54
|
+
0.04427743881741981,
|
|
55
|
+
0.028531388628933663,
|
|
56
|
+
0.028531388628933663,
|
|
57
|
+
0.0123412297999872,
|
|
58
|
+
0.0123412297999872
|
|
59
|
+
],
|
|
60
|
+
arcfn: function(o, e) {
|
|
61
|
+
const n = e(o);
|
|
62
|
+
let i = n.x * n.x + n.y * n.y;
|
|
63
|
+
return typeof n.z < "u" && (i += n.z * n.z), F(i);
|
|
64
|
+
},
|
|
65
|
+
compute: function(o, e, n) {
|
|
66
|
+
if (o === 0)
|
|
67
|
+
return e[0].t = 0, e[0];
|
|
68
|
+
const i = e.length - 1;
|
|
69
|
+
if (o === 1)
|
|
70
|
+
return e[i].t = 1, e[i];
|
|
71
|
+
const s = 1 - o;
|
|
72
|
+
let c = e;
|
|
73
|
+
if (i === 0)
|
|
74
|
+
return e[0].t = o, e[0];
|
|
75
|
+
if (i === 1) {
|
|
76
|
+
const l = {
|
|
77
|
+
x: s * c[0].x + o * c[1].x,
|
|
78
|
+
y: s * c[0].y + o * c[1].y,
|
|
79
|
+
t: o
|
|
80
|
+
};
|
|
81
|
+
return n && (l.z = s * c[0].z + o * c[1].z), l;
|
|
82
|
+
}
|
|
83
|
+
if (i < 4) {
|
|
84
|
+
let l = s * s, u = o * o, f, h, a, p = 0;
|
|
85
|
+
i === 2 ? (c = [c[0], c[1], c[2], it], f = l, h = s * o * 2, a = u) : i === 3 && (f = l * s, h = l * o * 3, a = s * u * 3, p = o * u);
|
|
86
|
+
const g = {
|
|
87
|
+
x: f * c[0].x + h * c[1].x + a * c[2].x + p * c[3].x,
|
|
88
|
+
y: f * c[0].y + h * c[1].y + a * c[2].y + p * c[3].y,
|
|
89
|
+
t: o
|
|
90
|
+
};
|
|
91
|
+
return n && (g.z = f * c[0].z + h * c[1].z + a * c[2].z + p * c[3].z), g;
|
|
92
|
+
}
|
|
93
|
+
const r = JSON.parse(JSON.stringify(e));
|
|
94
|
+
for (; r.length > 1; ) {
|
|
95
|
+
for (let l = 0; l < r.length - 1; l++)
|
|
96
|
+
r[l] = {
|
|
97
|
+
x: r[l].x + (r[l + 1].x - r[l].x) * o,
|
|
98
|
+
y: r[l].y + (r[l + 1].y - r[l].y) * o
|
|
99
|
+
}, typeof r[l].z < "u" && (r[l].z = r[l].z + (r[l + 1].z - r[l].z) * o);
|
|
100
|
+
r.splice(r.length - 1, 1);
|
|
101
|
+
}
|
|
102
|
+
return r[0].t = o, r[0];
|
|
103
|
+
},
|
|
104
|
+
computeWithRatios: function(o, e, n, i) {
|
|
105
|
+
const s = 1 - o, c = n, r = e;
|
|
106
|
+
let l = c[0], u = c[1], f = c[2], h = c[3], a;
|
|
107
|
+
if (l *= s, u *= o, r.length === 2)
|
|
108
|
+
return a = l + u, {
|
|
109
|
+
x: (l * r[0].x + u * r[1].x) / a,
|
|
110
|
+
y: (l * r[0].y + u * r[1].y) / a,
|
|
111
|
+
z: i ? (l * r[0].z + u * r[1].z) / a : !1,
|
|
112
|
+
t: o
|
|
113
|
+
};
|
|
114
|
+
if (l *= s, u *= 2 * s, f *= o * o, r.length === 3)
|
|
115
|
+
return a = l + u + f, {
|
|
116
|
+
x: (l * r[0].x + u * r[1].x + f * r[2].x) / a,
|
|
117
|
+
y: (l * r[0].y + u * r[1].y + f * r[2].y) / a,
|
|
118
|
+
z: i ? (l * r[0].z + u * r[1].z + f * r[2].z) / a : !1,
|
|
119
|
+
t: o
|
|
120
|
+
};
|
|
121
|
+
if (l *= s, u *= 1.5 * s, f *= 3 * s, h *= o * o * o, r.length === 4)
|
|
122
|
+
return a = l + u + f + h, {
|
|
123
|
+
x: (l * r[0].x + u * r[1].x + f * r[2].x + h * r[3].x) / a,
|
|
124
|
+
y: (l * r[0].y + u * r[1].y + f * r[2].y + h * r[3].y) / a,
|
|
125
|
+
z: i ? (l * r[0].z + u * r[1].z + f * r[2].z + h * r[3].z) / a : !1,
|
|
126
|
+
t: o
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
derive: function(o, e) {
|
|
130
|
+
const n = [];
|
|
131
|
+
for (let i = o, s = i.length, c = s - 1; s > 1; s--, c--) {
|
|
132
|
+
const r = [];
|
|
133
|
+
for (let l = 0, u; l < c; l++)
|
|
134
|
+
u = {
|
|
135
|
+
x: c * (i[l + 1].x - i[l].x),
|
|
136
|
+
y: c * (i[l + 1].y - i[l].y)
|
|
137
|
+
}, e && (u.z = c * (i[l + 1].z - i[l].z)), r.push(u);
|
|
138
|
+
n.push(r), i = r;
|
|
139
|
+
}
|
|
140
|
+
return n;
|
|
141
|
+
},
|
|
142
|
+
between: function(o, e, n) {
|
|
143
|
+
return e <= o && o <= n || y.approximately(o, e) || y.approximately(o, n);
|
|
144
|
+
},
|
|
145
|
+
approximately: function(o, e, n) {
|
|
146
|
+
return R(o - e) <= (n || nt);
|
|
147
|
+
},
|
|
148
|
+
length: function(o) {
|
|
149
|
+
const n = y.Tvalues.length;
|
|
150
|
+
let i = 0;
|
|
151
|
+
for (let s = 0, c; s < n; s++)
|
|
152
|
+
c = 0.5 * y.Tvalues[s] + 0.5, i += y.Cvalues[s] * y.arcfn(c, o);
|
|
153
|
+
return 0.5 * i;
|
|
154
|
+
},
|
|
155
|
+
map: function(o, e, n, i, s) {
|
|
156
|
+
const c = n - e, r = s - i, l = o - e, u = l / c;
|
|
157
|
+
return i + r * u;
|
|
158
|
+
},
|
|
159
|
+
lerp: function(o, e, n) {
|
|
160
|
+
const i = {
|
|
161
|
+
x: e.x + o * (n.x - e.x),
|
|
162
|
+
y: e.y + o * (n.y - e.y)
|
|
163
|
+
};
|
|
164
|
+
return e.z !== void 0 && n.z !== void 0 && (i.z = e.z + o * (n.z - e.z)), i;
|
|
165
|
+
},
|
|
166
|
+
pointToString: function(o) {
|
|
167
|
+
let e = o.x + "/" + o.y;
|
|
168
|
+
return typeof o.z < "u" && (e += "/" + o.z), e;
|
|
169
|
+
},
|
|
170
|
+
pointsToString: function(o) {
|
|
171
|
+
return "[" + o.map(y.pointToString).join(", ") + "]";
|
|
172
|
+
},
|
|
173
|
+
copy: function(o) {
|
|
174
|
+
return JSON.parse(JSON.stringify(o));
|
|
175
|
+
},
|
|
176
|
+
angle: function(o, e, n) {
|
|
177
|
+
const i = e.x - o.x, s = e.y - o.y, c = n.x - o.x, r = n.y - o.y, l = i * r - s * c, u = i * c + s * r;
|
|
178
|
+
return J(l, u);
|
|
179
|
+
},
|
|
180
|
+
// round as string, to avoid rounding errors
|
|
181
|
+
round: function(o, e) {
|
|
182
|
+
const n = "" + o, i = n.indexOf(".");
|
|
183
|
+
return parseFloat(n.substring(0, i + 1 + e));
|
|
184
|
+
},
|
|
185
|
+
dist: function(o, e) {
|
|
186
|
+
const n = o.x - e.x, i = o.y - e.y;
|
|
187
|
+
return F(n * n + i * i);
|
|
188
|
+
},
|
|
189
|
+
closest: function(o, e) {
|
|
190
|
+
let n = L(2, 63), i, s;
|
|
191
|
+
return o.forEach(function(c, r) {
|
|
192
|
+
s = y.dist(e, c), s < n && (n = s, i = r);
|
|
193
|
+
}), { mdist: n, mpos: i };
|
|
194
|
+
},
|
|
195
|
+
abcratio: function(o, e) {
|
|
196
|
+
if (e !== 2 && e !== 3)
|
|
197
|
+
return !1;
|
|
198
|
+
if (typeof o > "u")
|
|
199
|
+
o = 0.5;
|
|
200
|
+
else if (o === 0 || o === 1)
|
|
201
|
+
return o;
|
|
202
|
+
const n = L(o, e) + L(1 - o, e), i = n - 1;
|
|
203
|
+
return R(i / n);
|
|
204
|
+
},
|
|
205
|
+
projectionratio: function(o, e) {
|
|
206
|
+
if (e !== 2 && e !== 3)
|
|
207
|
+
return !1;
|
|
208
|
+
if (typeof o > "u")
|
|
209
|
+
o = 0.5;
|
|
210
|
+
else if (o === 0 || o === 1)
|
|
211
|
+
return o;
|
|
212
|
+
const n = L(1 - o, e), i = L(o, e) + n;
|
|
213
|
+
return n / i;
|
|
214
|
+
},
|
|
215
|
+
lli8: function(o, e, n, i, s, c, r, l) {
|
|
216
|
+
const u = (o * i - e * n) * (s - r) - (o - n) * (s * l - c * r), f = (o * i - e * n) * (c - l) - (e - i) * (s * l - c * r), h = (o - n) * (c - l) - (e - i) * (s - r);
|
|
217
|
+
return h == 0 ? !1 : { x: u / h, y: f / h };
|
|
218
|
+
},
|
|
219
|
+
lli4: function(o, e, n, i) {
|
|
220
|
+
const s = o.x, c = o.y, r = e.x, l = e.y, u = n.x, f = n.y, h = i.x, a = i.y;
|
|
221
|
+
return y.lli8(s, c, r, l, u, f, h, a);
|
|
222
|
+
},
|
|
223
|
+
lli: function(o, e) {
|
|
224
|
+
return y.lli4(o, o.c, e, e.c);
|
|
225
|
+
},
|
|
226
|
+
makeline: function(o, e) {
|
|
227
|
+
return new E(
|
|
228
|
+
o.x,
|
|
229
|
+
o.y,
|
|
230
|
+
(o.x + e.x) / 2,
|
|
231
|
+
(o.y + e.y) / 2,
|
|
232
|
+
e.x,
|
|
233
|
+
e.y
|
|
234
|
+
);
|
|
235
|
+
},
|
|
236
|
+
findbbox: function(o) {
|
|
237
|
+
let e = Q, n = Q, i = H, s = H;
|
|
238
|
+
return o.forEach(function(c) {
|
|
239
|
+
const r = c.bbox();
|
|
240
|
+
e > r.x.min && (e = r.x.min), n > r.y.min && (n = r.y.min), i < r.x.max && (i = r.x.max), s < r.y.max && (s = r.y.max);
|
|
241
|
+
}), {
|
|
242
|
+
x: { min: e, mid: (e + i) / 2, max: i, size: i - e },
|
|
243
|
+
y: { min: n, mid: (n + s) / 2, max: s, size: s - n }
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
shapeintersections: function(o, e, n, i, s) {
|
|
247
|
+
if (!y.bboxoverlap(e, i))
|
|
248
|
+
return [];
|
|
249
|
+
const c = [], r = [o.startcap, o.forward, o.back, o.endcap], l = [n.startcap, n.forward, n.back, n.endcap];
|
|
250
|
+
return r.forEach(function(u) {
|
|
251
|
+
u.virtual || l.forEach(function(f) {
|
|
252
|
+
if (f.virtual)
|
|
253
|
+
return;
|
|
254
|
+
const h = u.intersects(f, s);
|
|
255
|
+
h.length > 0 && (h.c1 = u, h.c2 = f, h.s1 = o, h.s2 = n, c.push(h));
|
|
256
|
+
});
|
|
257
|
+
}), c;
|
|
258
|
+
},
|
|
259
|
+
makeshape: function(o, e, n) {
|
|
260
|
+
const i = e.points.length, s = o.points.length, c = y.makeline(e.points[i - 1], o.points[0]), r = y.makeline(o.points[s - 1], e.points[0]), l = {
|
|
261
|
+
startcap: c,
|
|
262
|
+
forward: o,
|
|
263
|
+
back: e,
|
|
264
|
+
endcap: r,
|
|
265
|
+
bbox: y.findbbox([c, o, e, r])
|
|
266
|
+
};
|
|
267
|
+
return l.intersections = function(u) {
|
|
268
|
+
return y.shapeintersections(
|
|
269
|
+
l,
|
|
270
|
+
l.bbox,
|
|
271
|
+
u,
|
|
272
|
+
u.bbox,
|
|
273
|
+
n
|
|
274
|
+
);
|
|
275
|
+
}, l;
|
|
276
|
+
},
|
|
277
|
+
getminmax: function(o, e, n) {
|
|
278
|
+
if (!n)
|
|
279
|
+
return { min: 0, max: 0 };
|
|
280
|
+
let i = Q, s = H, c, r;
|
|
281
|
+
n.indexOf(0) === -1 && (n = [0].concat(n)), n.indexOf(1) === -1 && n.push(1);
|
|
282
|
+
for (let l = 0, u = n.length; l < u; l++)
|
|
283
|
+
c = n[l], r = o.get(c), r[e] < i && (i = r[e]), r[e] > s && (s = r[e]);
|
|
284
|
+
return { min: i, mid: (i + s) / 2, max: s, size: s - i };
|
|
285
|
+
},
|
|
286
|
+
align: function(o, e) {
|
|
287
|
+
const n = e.p1.x, i = e.p1.y, s = -J(e.p2.y - i, e.p2.x - n), c = function(r) {
|
|
288
|
+
return {
|
|
289
|
+
x: (r.x - n) * N(s) - (r.y - i) * U(s),
|
|
290
|
+
y: (r.x - n) * U(s) + (r.y - i) * N(s)
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
return o.map(c);
|
|
294
|
+
},
|
|
295
|
+
roots: function(o, e) {
|
|
296
|
+
e = e || { p1: { x: 0, y: 0 }, p2: { x: 1, y: 0 } };
|
|
297
|
+
const n = o.length - 1, i = y.align(o, e), s = function(x) {
|
|
298
|
+
return 0 <= x && x <= 1;
|
|
299
|
+
};
|
|
300
|
+
if (n === 2) {
|
|
301
|
+
const x = i[0].y, m = i[1].y, v = i[2].y, w = x - 2 * m + v;
|
|
302
|
+
if (w !== 0) {
|
|
303
|
+
const b = -F(m * m - x * v), k = -x + m, q = -(b + k) / w, M = -(-b + k) / w;
|
|
304
|
+
return [q, M].filter(s);
|
|
305
|
+
} else if (m !== v && w === 0)
|
|
306
|
+
return [(2 * m - v) / (2 * m - 2 * v)].filter(s);
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
309
|
+
const c = i[0].y, r = i[1].y, l = i[2].y, u = i[3].y;
|
|
310
|
+
let f = -c + 3 * r - 3 * l + u, h = 3 * c - 6 * r + 3 * l, a = -3 * c + 3 * r, p = c;
|
|
311
|
+
if (y.approximately(f, 0)) {
|
|
312
|
+
if (y.approximately(h, 0))
|
|
313
|
+
return y.approximately(a, 0) ? [] : [-p / a].filter(s);
|
|
314
|
+
const x = F(a * a - 4 * h * p), m = 2 * h;
|
|
315
|
+
return [(x - a) / m, (-a - x) / m].filter(s);
|
|
316
|
+
}
|
|
317
|
+
h /= f, a /= f, p /= f;
|
|
318
|
+
const g = (3 * a - h * h) / 3, _ = g / 3, C = (2 * h * h * h - 9 * h * a + 27 * p) / 27, A = C / 2, S = A * A + _ * _ * _;
|
|
319
|
+
let j, O, T, z, d;
|
|
320
|
+
if (S < 0) {
|
|
321
|
+
const x = -g / 3, m = x * x * x, v = F(m), w = -C / (2 * v), b = w < -1 ? -1 : w > 1 ? 1 : w, k = et(b), q = $(v), M = 2 * q;
|
|
322
|
+
return T = M * N(k / 3) - h / 3, z = M * N((k + X) / 3) - h / 3, d = M * N((k + 2 * X) / 3) - h / 3, [T, z, d].filter(s);
|
|
323
|
+
} else {
|
|
324
|
+
if (S === 0)
|
|
325
|
+
return j = A < 0 ? $(-A) : -$(A), T = 2 * j - h / 3, z = -j - h / 3, [T, z].filter(s);
|
|
326
|
+
{
|
|
327
|
+
const x = F(S);
|
|
328
|
+
return j = $(-A + x), O = $(A + x), [j - O - h / 3].filter(s);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
droots: function(o) {
|
|
333
|
+
if (o.length === 3) {
|
|
334
|
+
const e = o[0], n = o[1], i = o[2], s = e - 2 * n + i;
|
|
335
|
+
if (s !== 0) {
|
|
336
|
+
const c = -F(n * n - e * i), r = -e + n, l = -(c + r) / s, u = -(-c + r) / s;
|
|
337
|
+
return [l, u];
|
|
338
|
+
} else if (n !== i && s === 0)
|
|
339
|
+
return [(2 * n - i) / (2 * (n - i))];
|
|
340
|
+
return [];
|
|
341
|
+
}
|
|
342
|
+
if (o.length === 2) {
|
|
343
|
+
const e = o[0], n = o[1];
|
|
344
|
+
return e !== n ? [e / (e - n)] : [];
|
|
345
|
+
}
|
|
346
|
+
return [];
|
|
347
|
+
},
|
|
348
|
+
curvature: function(o, e, n, i, s) {
|
|
349
|
+
let c, r, l, u, f = 0, h = 0;
|
|
350
|
+
const a = y.compute(o, e), p = y.compute(o, n), g = a.x * a.x + a.y * a.y;
|
|
351
|
+
if (i ? (c = F(
|
|
352
|
+
L(a.y * p.z - p.y * a.z, 2) + L(a.z * p.x - p.z * a.x, 2) + L(a.x * p.y - p.x * a.y, 2)
|
|
353
|
+
), r = L(g + a.z * a.z, 3 / 2)) : (c = a.x * p.y - a.y * p.x, r = L(g, 3 / 2)), c === 0 || r === 0)
|
|
354
|
+
return { k: 0, r: 0 };
|
|
355
|
+
if (f = c / r, h = r / c, !s) {
|
|
356
|
+
const _ = y.curvature(o - 1e-3, e, n, i, !0).k, C = y.curvature(o + 1e-3, e, n, i, !0).k;
|
|
357
|
+
u = (C - f + (f - _)) / 2, l = (R(C - f) + R(f - _)) / 2;
|
|
358
|
+
}
|
|
359
|
+
return { k: f, r: h, dk: u, adk: l };
|
|
360
|
+
},
|
|
361
|
+
inflections: function(o) {
|
|
362
|
+
if (o.length < 4)
|
|
363
|
+
return [];
|
|
364
|
+
const e = y.align(o, { p1: o[0], p2: o.slice(-1)[0] }), n = e[2].x * e[1].y, i = e[3].x * e[1].y, s = e[1].x * e[2].y, c = e[3].x * e[2].y, r = 18 * (-3 * n + 2 * i + 3 * s - c), l = 18 * (3 * n - i - 3 * s), u = 18 * (s - n);
|
|
365
|
+
if (y.approximately(r, 0)) {
|
|
366
|
+
if (!y.approximately(l, 0)) {
|
|
367
|
+
let p = -u / l;
|
|
368
|
+
if (0 <= p && p <= 1)
|
|
369
|
+
return [p];
|
|
370
|
+
}
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
const f = 2 * r;
|
|
374
|
+
if (y.approximately(f, 0))
|
|
375
|
+
return [];
|
|
376
|
+
const h = l * l - 4 * r * u;
|
|
377
|
+
if (h < 0)
|
|
378
|
+
return [];
|
|
379
|
+
const a = Math.sqrt(h);
|
|
380
|
+
return [(a - l) / f, -(l + a) / f].filter(function(p) {
|
|
381
|
+
return 0 <= p && p <= 1;
|
|
382
|
+
});
|
|
383
|
+
},
|
|
384
|
+
bboxoverlap: function(o, e) {
|
|
385
|
+
const n = ["x", "y"], i = n.length;
|
|
386
|
+
for (let s = 0, c, r, l, u; s < i; s++)
|
|
387
|
+
if (c = n[s], r = o[c].mid, l = e[c].mid, u = (o[c].size + e[c].size) / 2, R(r - l) >= u)
|
|
388
|
+
return !1;
|
|
389
|
+
return !0;
|
|
390
|
+
},
|
|
391
|
+
expandbox: function(o, e) {
|
|
392
|
+
e.x.min < o.x.min && (o.x.min = e.x.min), e.y.min < o.y.min && (o.y.min = e.y.min), e.z && e.z.min < o.z.min && (o.z.min = e.z.min), e.x.max > o.x.max && (o.x.max = e.x.max), e.y.max > o.y.max && (o.y.max = e.y.max), e.z && e.z.max > o.z.max && (o.z.max = e.z.max), o.x.mid = (o.x.min + o.x.max) / 2, o.y.mid = (o.y.min + o.y.max) / 2, o.z && (o.z.mid = (o.z.min + o.z.max) / 2), o.x.size = o.x.max - o.x.min, o.y.size = o.y.max - o.y.min, o.z && (o.z.size = o.z.max - o.z.min);
|
|
393
|
+
},
|
|
394
|
+
pairiteration: function(o, e, n) {
|
|
395
|
+
const i = o.bbox(), s = e.bbox(), c = 1e5, r = n || 0.5;
|
|
396
|
+
if (i.x.size + i.y.size < r && s.x.size + s.y.size < r)
|
|
397
|
+
return [
|
|
398
|
+
(c * (o._t1 + o._t2) / 2 | 0) / c + "/" + (c * (e._t1 + e._t2) / 2 | 0) / c
|
|
399
|
+
];
|
|
400
|
+
let l = o.split(0.5), u = e.split(0.5), f = [
|
|
401
|
+
{ left: l.left, right: u.left },
|
|
402
|
+
{ left: l.left, right: u.right },
|
|
403
|
+
{ left: l.right, right: u.right },
|
|
404
|
+
{ left: l.right, right: u.left }
|
|
405
|
+
];
|
|
406
|
+
f = f.filter(function(a) {
|
|
407
|
+
return y.bboxoverlap(a.left.bbox(), a.right.bbox());
|
|
408
|
+
});
|
|
409
|
+
let h = [];
|
|
410
|
+
return f.length === 0 || (f.forEach(function(a) {
|
|
411
|
+
h = h.concat(
|
|
412
|
+
y.pairiteration(a.left, a.right, r)
|
|
413
|
+
);
|
|
414
|
+
}), h = h.filter(function(a, p) {
|
|
415
|
+
return h.indexOf(a) === p;
|
|
416
|
+
})), h;
|
|
417
|
+
},
|
|
418
|
+
getccenter: function(o, e, n) {
|
|
419
|
+
const i = e.x - o.x, s = e.y - o.y, c = n.x - e.x, r = n.y - e.y, l = i * N(P) - s * U(P), u = i * U(P) + s * N(P), f = c * N(P) - r * U(P), h = c * U(P) + r * N(P), a = (o.x + e.x) / 2, p = (o.y + e.y) / 2, g = (e.x + n.x) / 2, _ = (e.y + n.y) / 2, C = a + l, A = p + u, S = g + f, j = _ + h, O = y.lli8(a, p, C, A, g, _, S, j), T = y.dist(O, o);
|
|
420
|
+
let z = J(o.y - O.y, o.x - O.x), d = J(e.y - O.y, e.x - O.x), x = J(n.y - O.y, n.x - O.x), m;
|
|
421
|
+
return z < x ? ((z > d || d > x) && (z += X), z > x && (m = x, x = z, z = m)) : x < d && d < z ? (m = x, x = z, z = m) : x += X, O.s = z, O.e = x, O.r = T, O;
|
|
422
|
+
},
|
|
423
|
+
numberSort: function(o, e) {
|
|
424
|
+
return o - e;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
class V {
|
|
428
|
+
constructor(e) {
|
|
429
|
+
this.curves = [], this._3d = !1, e && (this.curves = e, this._3d = this.curves[0]._3d);
|
|
430
|
+
}
|
|
431
|
+
valueOf() {
|
|
432
|
+
return this.toString();
|
|
433
|
+
}
|
|
434
|
+
toString() {
|
|
435
|
+
return "[" + this.curves.map(function(e) {
|
|
436
|
+
return y.pointsToString(e.points);
|
|
437
|
+
}).join(", ") + "]";
|
|
438
|
+
}
|
|
439
|
+
addCurve(e) {
|
|
440
|
+
this.curves.push(e), this._3d = this._3d || e._3d;
|
|
441
|
+
}
|
|
442
|
+
length() {
|
|
443
|
+
return this.curves.map(function(e) {
|
|
444
|
+
return e.length();
|
|
445
|
+
}).reduce(function(e, n) {
|
|
446
|
+
return e + n;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
curve(e) {
|
|
450
|
+
return this.curves[e];
|
|
451
|
+
}
|
|
452
|
+
bbox() {
|
|
453
|
+
const e = this.curves;
|
|
454
|
+
for (var n = e[0].bbox(), i = 1; i < e.length; i++)
|
|
455
|
+
y.expandbox(n, e[i].bbox());
|
|
456
|
+
return n;
|
|
457
|
+
}
|
|
458
|
+
offset(e) {
|
|
459
|
+
const n = [];
|
|
460
|
+
return this.curves.forEach(function(i) {
|
|
461
|
+
n.push(...i.offset(e));
|
|
462
|
+
}), new V(n);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const { abs: G, min: K, max: B, cos: rt, sin: st, acos: ot, sqrt: Z } = Math, ct = Math.PI;
|
|
466
|
+
class E {
|
|
467
|
+
constructor(e) {
|
|
468
|
+
let n = e && e.forEach ? e : Array.from(arguments).slice(), i = !1;
|
|
469
|
+
if (typeof n[0] == "object") {
|
|
470
|
+
i = n.length;
|
|
471
|
+
const g = [];
|
|
472
|
+
n.forEach(function(_) {
|
|
473
|
+
["x", "y", "z"].forEach(function(C) {
|
|
474
|
+
typeof _[C] < "u" && g.push(_[C]);
|
|
475
|
+
});
|
|
476
|
+
}), n = g;
|
|
477
|
+
}
|
|
478
|
+
let s = !1;
|
|
479
|
+
const c = n.length;
|
|
480
|
+
if (i) {
|
|
481
|
+
if (i > 4) {
|
|
482
|
+
if (arguments.length !== 1)
|
|
483
|
+
throw new Error(
|
|
484
|
+
"Only new Bezier(point[]) is accepted for 4th and higher order curves"
|
|
485
|
+
);
|
|
486
|
+
s = !0;
|
|
487
|
+
}
|
|
488
|
+
} else if (c !== 6 && c !== 8 && c !== 9 && c !== 12 && arguments.length !== 1)
|
|
489
|
+
throw new Error(
|
|
490
|
+
"Only new Bezier(point[]) is accepted for 4th and higher order curves"
|
|
491
|
+
);
|
|
492
|
+
const r = this._3d = !s && (c === 9 || c === 12) || e && e[0] && typeof e[0].z < "u", l = this.points = [];
|
|
493
|
+
for (let g = 0, _ = r ? 3 : 2; g < c; g += _) {
|
|
494
|
+
var u = {
|
|
495
|
+
x: n[g],
|
|
496
|
+
y: n[g + 1]
|
|
497
|
+
};
|
|
498
|
+
r && (u.z = n[g + 2]), l.push(u);
|
|
499
|
+
}
|
|
500
|
+
const f = this.order = l.length - 1, h = this.dims = ["x", "y"];
|
|
501
|
+
r && h.push("z"), this.dimlen = h.length;
|
|
502
|
+
const a = y.align(l, { p1: l[0], p2: l[f] }), p = y.dist(l[0], l[f]);
|
|
503
|
+
this._linear = a.reduce((g, _) => g + G(_.y), 0) < p / 50, this._lut = [], this._t1 = 0, this._t2 = 1, this.update();
|
|
504
|
+
}
|
|
505
|
+
static quadraticFromPoints(e, n, i, s) {
|
|
506
|
+
if (typeof s > "u" && (s = 0.5), s === 0)
|
|
507
|
+
return new E(n, n, i);
|
|
508
|
+
if (s === 1)
|
|
509
|
+
return new E(e, n, n);
|
|
510
|
+
const c = E.getABC(2, e, n, i, s);
|
|
511
|
+
return new E(e, c.A, i);
|
|
512
|
+
}
|
|
513
|
+
static cubicFromPoints(e, n, i, s, c) {
|
|
514
|
+
typeof s > "u" && (s = 0.5);
|
|
515
|
+
const r = E.getABC(3, e, n, i, s);
|
|
516
|
+
typeof c > "u" && (c = y.dist(n, r.C));
|
|
517
|
+
const l = c * (1 - s) / s, u = y.dist(e, i), f = (i.x - e.x) / u, h = (i.y - e.y) / u, a = c * f, p = c * h, g = l * f, _ = l * h, C = { x: n.x - a, y: n.y - p }, A = { x: n.x + g, y: n.y + _ }, S = r.A, j = { x: S.x + (C.x - S.x) / (1 - s), y: S.y + (C.y - S.y) / (1 - s) }, O = { x: S.x + (A.x - S.x) / s, y: S.y + (A.y - S.y) / s }, T = { x: e.x + (j.x - e.x) / s, y: e.y + (j.y - e.y) / s }, z = {
|
|
518
|
+
x: i.x + (O.x - i.x) / (1 - s),
|
|
519
|
+
y: i.y + (O.y - i.y) / (1 - s)
|
|
520
|
+
};
|
|
521
|
+
return new E(e, T, z, i);
|
|
522
|
+
}
|
|
523
|
+
static getUtils() {
|
|
524
|
+
return y;
|
|
525
|
+
}
|
|
526
|
+
getUtils() {
|
|
527
|
+
return E.getUtils();
|
|
528
|
+
}
|
|
529
|
+
static get PolyBezier() {
|
|
530
|
+
return V;
|
|
531
|
+
}
|
|
532
|
+
valueOf() {
|
|
533
|
+
return this.toString();
|
|
534
|
+
}
|
|
535
|
+
toString() {
|
|
536
|
+
return y.pointsToString(this.points);
|
|
537
|
+
}
|
|
538
|
+
toSVG() {
|
|
539
|
+
if (this._3d)
|
|
540
|
+
return !1;
|
|
541
|
+
const e = this.points, n = e[0].x, i = e[0].y, s = ["M", n, i, this.order === 2 ? "Q" : "C"];
|
|
542
|
+
for (let c = 1, r = e.length; c < r; c++)
|
|
543
|
+
s.push(e[c].x), s.push(e[c].y);
|
|
544
|
+
return s.join(" ");
|
|
545
|
+
}
|
|
546
|
+
setRatios(e) {
|
|
547
|
+
if (e.length !== this.points.length)
|
|
548
|
+
throw new Error("incorrect number of ratio values");
|
|
549
|
+
this.ratios = e, this._lut = [];
|
|
550
|
+
}
|
|
551
|
+
verify() {
|
|
552
|
+
const e = this.coordDigest();
|
|
553
|
+
e !== this._print && (this._print = e, this.update());
|
|
554
|
+
}
|
|
555
|
+
coordDigest() {
|
|
556
|
+
return this.points.map(function(e, n) {
|
|
557
|
+
return "" + n + e.x + e.y + (e.z ? e.z : 0);
|
|
558
|
+
}).join("");
|
|
559
|
+
}
|
|
560
|
+
update() {
|
|
561
|
+
this._lut = [], this.dpoints = y.derive(this.points, this._3d), this.computedirection();
|
|
562
|
+
}
|
|
563
|
+
computedirection() {
|
|
564
|
+
const e = this.points, n = y.angle(e[0], e[this.order], e[1]);
|
|
565
|
+
this.clockwise = n > 0;
|
|
566
|
+
}
|
|
567
|
+
length() {
|
|
568
|
+
return y.length(this.derivative.bind(this));
|
|
569
|
+
}
|
|
570
|
+
static getABC(e = 2, n, i, s, c = 0.5) {
|
|
571
|
+
const r = y.projectionratio(c, e), l = 1 - r, u = {
|
|
572
|
+
x: r * n.x + l * s.x,
|
|
573
|
+
y: r * n.y + l * s.y
|
|
574
|
+
}, f = y.abcratio(c, e);
|
|
575
|
+
return { A: {
|
|
576
|
+
x: i.x + (i.x - u.x) / f,
|
|
577
|
+
y: i.y + (i.y - u.y) / f
|
|
578
|
+
}, B: i, C: u, S: n, E: s };
|
|
579
|
+
}
|
|
580
|
+
getABC(e, n) {
|
|
581
|
+
n = n || this.get(e);
|
|
582
|
+
let i = this.points[0], s = this.points[this.order];
|
|
583
|
+
return E.getABC(this.order, i, n, s, e);
|
|
584
|
+
}
|
|
585
|
+
getLUT(e) {
|
|
586
|
+
if (this.verify(), e = e || 100, this._lut.length === e + 1)
|
|
587
|
+
return this._lut;
|
|
588
|
+
this._lut = [], e++, this._lut = [];
|
|
589
|
+
for (let n = 0, i, s; n < e; n++)
|
|
590
|
+
s = n / (e - 1), i = this.compute(s), i.t = s, this._lut.push(i);
|
|
591
|
+
return this._lut;
|
|
592
|
+
}
|
|
593
|
+
on(e, n) {
|
|
594
|
+
n = n || 5;
|
|
595
|
+
const i = this.getLUT(), s = [];
|
|
596
|
+
for (let c = 0, r, l = 0; c < i.length; c++)
|
|
597
|
+
r = i[c], y.dist(r, e) < n && (s.push(r), l += c / i.length);
|
|
598
|
+
return s.length ? t /= s.length : !1;
|
|
599
|
+
}
|
|
600
|
+
project(e) {
|
|
601
|
+
const n = this.getLUT(), i = n.length - 1, s = y.closest(n, e), c = s.mpos, r = (c - 1) / i, l = (c + 1) / i, u = 0.1 / i;
|
|
602
|
+
let f = s.mdist, h = r, a = h, p;
|
|
603
|
+
f += 1;
|
|
604
|
+
for (let g; h < l + u; h += u)
|
|
605
|
+
p = this.compute(h), g = y.dist(e, p), g < f && (f = g, a = h);
|
|
606
|
+
return a = a < 0 ? 0 : a > 1 ? 1 : a, p = this.compute(a), p.t = a, p.d = f, p;
|
|
607
|
+
}
|
|
608
|
+
get(e) {
|
|
609
|
+
return this.compute(e);
|
|
610
|
+
}
|
|
611
|
+
point(e) {
|
|
612
|
+
return this.points[e];
|
|
613
|
+
}
|
|
614
|
+
compute(e) {
|
|
615
|
+
return this.ratios ? y.computeWithRatios(e, this.points, this.ratios, this._3d) : y.compute(e, this.points, this._3d, this.ratios);
|
|
616
|
+
}
|
|
617
|
+
raise() {
|
|
618
|
+
const e = this.points, n = [e[0]], i = e.length;
|
|
619
|
+
for (let s = 1, c, r; s < i; s++)
|
|
620
|
+
c = e[s], r = e[s - 1], n[s] = {
|
|
621
|
+
x: (i - s) / i * c.x + s / i * r.x,
|
|
622
|
+
y: (i - s) / i * c.y + s / i * r.y
|
|
623
|
+
};
|
|
624
|
+
return n[i] = e[i - 1], new E(n);
|
|
625
|
+
}
|
|
626
|
+
derivative(e) {
|
|
627
|
+
return y.compute(e, this.dpoints[0], this._3d);
|
|
628
|
+
}
|
|
629
|
+
dderivative(e) {
|
|
630
|
+
return y.compute(e, this.dpoints[1], this._3d);
|
|
631
|
+
}
|
|
632
|
+
align() {
|
|
633
|
+
let e = this.points;
|
|
634
|
+
return new E(y.align(e, { p1: e[0], p2: e[e.length - 1] }));
|
|
635
|
+
}
|
|
636
|
+
curvature(e) {
|
|
637
|
+
return y.curvature(e, this.dpoints[0], this.dpoints[1], this._3d);
|
|
638
|
+
}
|
|
639
|
+
inflections() {
|
|
640
|
+
return y.inflections(this.points);
|
|
641
|
+
}
|
|
642
|
+
normal(e) {
|
|
643
|
+
return this._3d ? this.__normal3(e) : this.__normal2(e);
|
|
644
|
+
}
|
|
645
|
+
__normal2(e) {
|
|
646
|
+
const n = this.derivative(e), i = Z(n.x * n.x + n.y * n.y);
|
|
647
|
+
return { t: e, x: -n.y / i, y: n.x / i };
|
|
648
|
+
}
|
|
649
|
+
__normal3(e) {
|
|
650
|
+
const n = this.derivative(e), i = this.derivative(e + 0.01), s = Z(n.x * n.x + n.y * n.y + n.z * n.z), c = Z(i.x * i.x + i.y * i.y + i.z * i.z);
|
|
651
|
+
n.x /= s, n.y /= s, n.z /= s, i.x /= c, i.y /= c, i.z /= c;
|
|
652
|
+
const r = {
|
|
653
|
+
x: i.y * n.z - i.z * n.y,
|
|
654
|
+
y: i.z * n.x - i.x * n.z,
|
|
655
|
+
z: i.x * n.y - i.y * n.x
|
|
656
|
+
}, l = Z(r.x * r.x + r.y * r.y + r.z * r.z);
|
|
657
|
+
r.x /= l, r.y /= l, r.z /= l;
|
|
658
|
+
const u = [
|
|
659
|
+
r.x * r.x,
|
|
660
|
+
r.x * r.y - r.z,
|
|
661
|
+
r.x * r.z + r.y,
|
|
662
|
+
r.x * r.y + r.z,
|
|
663
|
+
r.y * r.y,
|
|
664
|
+
r.y * r.z - r.x,
|
|
665
|
+
r.x * r.z - r.y,
|
|
666
|
+
r.y * r.z + r.x,
|
|
667
|
+
r.z * r.z
|
|
668
|
+
];
|
|
669
|
+
return {
|
|
670
|
+
t: e,
|
|
671
|
+
x: u[0] * n.x + u[1] * n.y + u[2] * n.z,
|
|
672
|
+
y: u[3] * n.x + u[4] * n.y + u[5] * n.z,
|
|
673
|
+
z: u[6] * n.x + u[7] * n.y + u[8] * n.z
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
hull(e) {
|
|
677
|
+
let n = this.points, i = [], s = [], c = 0;
|
|
678
|
+
for (s[c++] = n[0], s[c++] = n[1], s[c++] = n[2], this.order === 3 && (s[c++] = n[3]); n.length > 1; ) {
|
|
679
|
+
i = [];
|
|
680
|
+
for (let r = 0, l, u = n.length - 1; r < u; r++)
|
|
681
|
+
l = y.lerp(e, n[r], n[r + 1]), s[c++] = l, i.push(l);
|
|
682
|
+
n = i;
|
|
683
|
+
}
|
|
684
|
+
return s;
|
|
685
|
+
}
|
|
686
|
+
split(e, n) {
|
|
687
|
+
if (e === 0 && n)
|
|
688
|
+
return this.split(n).left;
|
|
689
|
+
if (n === 1)
|
|
690
|
+
return this.split(e).right;
|
|
691
|
+
const i = this.hull(e), s = {
|
|
692
|
+
left: this.order === 2 ? new E([i[0], i[3], i[5]]) : new E([i[0], i[4], i[7], i[9]]),
|
|
693
|
+
right: this.order === 2 ? new E([i[5], i[4], i[2]]) : new E([i[9], i[8], i[6], i[3]]),
|
|
694
|
+
span: i
|
|
695
|
+
};
|
|
696
|
+
return s.left._t1 = y.map(0, 0, 1, this._t1, this._t2), s.left._t2 = y.map(e, 0, 1, this._t1, this._t2), s.right._t1 = y.map(e, 0, 1, this._t1, this._t2), s.right._t2 = y.map(1, 0, 1, this._t1, this._t2), n ? (n = y.map(n, e, 1, 0, 1), s.right.split(n).left) : s;
|
|
697
|
+
}
|
|
698
|
+
extrema() {
|
|
699
|
+
const e = {};
|
|
700
|
+
let n = [];
|
|
701
|
+
return this.dims.forEach(
|
|
702
|
+
(function(i) {
|
|
703
|
+
let s = function(r) {
|
|
704
|
+
return r[i];
|
|
705
|
+
}, c = this.dpoints[0].map(s);
|
|
706
|
+
e[i] = y.droots(c), this.order === 3 && (c = this.dpoints[1].map(s), e[i] = e[i].concat(y.droots(c))), e[i] = e[i].filter(function(r) {
|
|
707
|
+
return r >= 0 && r <= 1;
|
|
708
|
+
}), n = n.concat(e[i].sort(y.numberSort));
|
|
709
|
+
}).bind(this)
|
|
710
|
+
), e.values = n.sort(y.numberSort).filter(function(i, s) {
|
|
711
|
+
return n.indexOf(i) === s;
|
|
712
|
+
}), e;
|
|
713
|
+
}
|
|
714
|
+
bbox() {
|
|
715
|
+
const e = this.extrema(), n = {};
|
|
716
|
+
return this.dims.forEach(
|
|
717
|
+
(function(i) {
|
|
718
|
+
n[i] = y.getminmax(this, i, e[i]);
|
|
719
|
+
}).bind(this)
|
|
720
|
+
), n;
|
|
721
|
+
}
|
|
722
|
+
overlaps(e) {
|
|
723
|
+
const n = this.bbox(), i = e.bbox();
|
|
724
|
+
return y.bboxoverlap(n, i);
|
|
725
|
+
}
|
|
726
|
+
offset(e, n) {
|
|
727
|
+
if (typeof n < "u") {
|
|
728
|
+
const i = this.get(e), s = this.normal(e), c = {
|
|
729
|
+
c: i,
|
|
730
|
+
n: s,
|
|
731
|
+
x: i.x + s.x * n,
|
|
732
|
+
y: i.y + s.y * n
|
|
733
|
+
};
|
|
734
|
+
return this._3d && (c.z = i.z + s.z * n), c;
|
|
735
|
+
}
|
|
736
|
+
if (this._linear) {
|
|
737
|
+
const i = this.normal(0), s = this.points.map(function(c) {
|
|
738
|
+
const r = {
|
|
739
|
+
x: c.x + e * i.x,
|
|
740
|
+
y: c.y + e * i.y
|
|
741
|
+
};
|
|
742
|
+
return c.z && i.z && (r.z = c.z + e * i.z), r;
|
|
743
|
+
});
|
|
744
|
+
return [new E(s)];
|
|
745
|
+
}
|
|
746
|
+
return this.reduce().map(function(i) {
|
|
747
|
+
return i._linear ? i.offset(e)[0] : i.scale(e);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
simple() {
|
|
751
|
+
if (this.order === 3) {
|
|
752
|
+
const s = y.angle(this.points[0], this.points[3], this.points[1]), c = y.angle(this.points[0], this.points[3], this.points[2]);
|
|
753
|
+
if (s > 0 && c < 0 || s < 0 && c > 0)
|
|
754
|
+
return !1;
|
|
755
|
+
}
|
|
756
|
+
const e = this.normal(0), n = this.normal(1);
|
|
757
|
+
let i = e.x * n.x + e.y * n.y;
|
|
758
|
+
return this._3d && (i += e.z * n.z), G(ot(i)) < ct / 3;
|
|
759
|
+
}
|
|
760
|
+
reduce() {
|
|
761
|
+
let e, n = 0, i = 0, s = 0.01, c, r = [], l = [], u = this.extrema().values;
|
|
762
|
+
for (u.indexOf(0) === -1 && (u = [0].concat(u)), u.indexOf(1) === -1 && u.push(1), n = u[0], e = 1; e < u.length; e++)
|
|
763
|
+
i = u[e], c = this.split(n, i), c._t1 = n, c._t2 = i, r.push(c), n = i;
|
|
764
|
+
return r.forEach(function(f) {
|
|
765
|
+
for (n = 0, i = 0; i <= 1; )
|
|
766
|
+
for (i = n + s; i <= 1 + s; i += s)
|
|
767
|
+
if (c = f.split(n, i), !c.simple()) {
|
|
768
|
+
if (i -= s, G(n - i) < s)
|
|
769
|
+
return [];
|
|
770
|
+
c = f.split(n, i), c._t1 = y.map(n, 0, 1, f._t1, f._t2), c._t2 = y.map(i, 0, 1, f._t1, f._t2), l.push(c), n = i;
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
n < 1 && (c = f.split(n, 1), c._t1 = y.map(n, 0, 1, f._t1, f._t2), c._t2 = f._t2, l.push(c));
|
|
774
|
+
}), l;
|
|
775
|
+
}
|
|
776
|
+
translate(e, n, i) {
|
|
777
|
+
i = typeof i == "number" ? i : n;
|
|
778
|
+
const s = this.order;
|
|
779
|
+
let c = this.points.map((r, l) => (1 - l / s) * n + l / s * i);
|
|
780
|
+
return new E(
|
|
781
|
+
this.points.map((r, l) => ({
|
|
782
|
+
x: r.x + e.x * c[l],
|
|
783
|
+
y: r.y + e.y * c[l]
|
|
784
|
+
}))
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
scale(e) {
|
|
788
|
+
const n = this.order;
|
|
789
|
+
let i = !1;
|
|
790
|
+
if (typeof e == "function" && (i = e), i && n === 2)
|
|
791
|
+
return this.raise().scale(i);
|
|
792
|
+
const s = this.clockwise, c = this.points;
|
|
793
|
+
if (this._linear)
|
|
794
|
+
return this.translate(
|
|
795
|
+
this.normal(0),
|
|
796
|
+
i ? i(0) : e,
|
|
797
|
+
i ? i(1) : e
|
|
798
|
+
);
|
|
799
|
+
const r = i ? i(0) : e, l = i ? i(1) : e, u = [this.offset(0, 10), this.offset(1, 10)], f = [], h = y.lli4(u[0], u[0].c, u[1], u[1].c);
|
|
800
|
+
if (!h)
|
|
801
|
+
throw new Error("cannot scale this curve. Try reducing it first.");
|
|
802
|
+
return [0, 1].forEach(function(a) {
|
|
803
|
+
const p = f[a * n] = y.copy(c[a * n]);
|
|
804
|
+
p.x += (a ? l : r) * u[a].n.x, p.y += (a ? l : r) * u[a].n.y;
|
|
805
|
+
}), i ? ([0, 1].forEach(function(a) {
|
|
806
|
+
if (!(n === 2 && a)) {
|
|
807
|
+
var p = c[a + 1], g = {
|
|
808
|
+
x: p.x - h.x,
|
|
809
|
+
y: p.y - h.y
|
|
810
|
+
}, _ = i ? i((a + 1) / n) : e;
|
|
811
|
+
i && !s && (_ = -_);
|
|
812
|
+
var C = Z(g.x * g.x + g.y * g.y);
|
|
813
|
+
g.x /= C, g.y /= C, f[a + 1] = {
|
|
814
|
+
x: p.x + _ * g.x,
|
|
815
|
+
y: p.y + _ * g.y
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
}), new E(f)) : ([0, 1].forEach((a) => {
|
|
819
|
+
if (n === 2 && a)
|
|
820
|
+
return;
|
|
821
|
+
const p = f[a * n], g = this.derivative(a), _ = { x: p.x + g.x, y: p.y + g.y };
|
|
822
|
+
f[a + 1] = y.lli4(p, _, h, c[a + 1]);
|
|
823
|
+
}), new E(f));
|
|
824
|
+
}
|
|
825
|
+
outline(e, n, i, s) {
|
|
826
|
+
if (n = n === void 0 ? e : n, this._linear) {
|
|
827
|
+
const z = this.normal(0), d = this.points[0], x = this.points[this.points.length - 1];
|
|
828
|
+
let m, v, w;
|
|
829
|
+
i === void 0 && (i = e, s = n), m = { x: d.x + z.x * e, y: d.y + z.y * e }, w = { x: x.x + z.x * i, y: x.y + z.y * i }, v = { x: (m.x + w.x) / 2, y: (m.y + w.y) / 2 };
|
|
830
|
+
const b = [m, v, w];
|
|
831
|
+
m = { x: d.x - z.x * n, y: d.y - z.y * n }, w = { x: x.x - z.x * s, y: x.y - z.y * s }, v = { x: (m.x + w.x) / 2, y: (m.y + w.y) / 2 };
|
|
832
|
+
const k = [w, v, m], q = y.makeline(k[2], b[0]), M = y.makeline(b[2], k[0]), I = [q, new E(b), M, new E(k)];
|
|
833
|
+
return new V(I);
|
|
834
|
+
}
|
|
835
|
+
const c = this.reduce(), r = c.length, l = [];
|
|
836
|
+
let u = [], f, h = 0, a = this.length();
|
|
837
|
+
const p = typeof i < "u" && typeof s < "u";
|
|
838
|
+
function g(z, d, x, m, v) {
|
|
839
|
+
return function(w) {
|
|
840
|
+
const b = m / x, k = (m + v) / x, q = d - z;
|
|
841
|
+
return y.map(w, 0, 1, z + b * q, z + k * q);
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
c.forEach(function(z) {
|
|
845
|
+
const d = z.length();
|
|
846
|
+
p ? (l.push(
|
|
847
|
+
z.scale(g(e, i, a, h, d))
|
|
848
|
+
), u.push(
|
|
849
|
+
z.scale(g(-n, -s, a, h, d))
|
|
850
|
+
)) : (l.push(z.scale(e)), u.push(z.scale(-n))), h += d;
|
|
851
|
+
}), u = u.map(function(z) {
|
|
852
|
+
return f = z.points, f[3] ? z.points = [f[3], f[2], f[1], f[0]] : z.points = [f[2], f[1], f[0]], z;
|
|
853
|
+
}).reverse();
|
|
854
|
+
const _ = l[0].points[0], C = l[r - 1].points[l[r - 1].points.length - 1], A = u[r - 1].points[u[r - 1].points.length - 1], S = u[0].points[0], j = y.makeline(A, _), O = y.makeline(C, S), T = [j].concat(l).concat([O]).concat(u);
|
|
855
|
+
return new V(T);
|
|
856
|
+
}
|
|
857
|
+
outlineshapes(e, n, i) {
|
|
858
|
+
n = n || e;
|
|
859
|
+
const s = this.outline(e, n).curves, c = [];
|
|
860
|
+
for (let r = 1, l = s.length; r < l / 2; r++) {
|
|
861
|
+
const u = y.makeshape(
|
|
862
|
+
s[r],
|
|
863
|
+
s[l - r],
|
|
864
|
+
i
|
|
865
|
+
);
|
|
866
|
+
u.startcap.virtual = r > 1, u.endcap.virtual = r < l / 2 - 1, c.push(u);
|
|
867
|
+
}
|
|
868
|
+
return c;
|
|
869
|
+
}
|
|
870
|
+
intersects(e, n) {
|
|
871
|
+
return e ? e.p1 && e.p2 ? this.lineIntersects(e) : (e instanceof E && (e = e.reduce()), this.curveintersects(
|
|
872
|
+
this.reduce(),
|
|
873
|
+
e,
|
|
874
|
+
n
|
|
875
|
+
)) : this.selfintersects(n);
|
|
876
|
+
}
|
|
877
|
+
lineIntersects(e) {
|
|
878
|
+
const n = K(e.p1.x, e.p2.x), i = K(e.p1.y, e.p2.y), s = B(e.p1.x, e.p2.x), c = B(e.p1.y, e.p2.y);
|
|
879
|
+
return y.roots(this.points, e).filter((r) => {
|
|
880
|
+
var l = this.get(r);
|
|
881
|
+
return y.between(l.x, n, s) && y.between(l.y, i, c);
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
selfintersects(e) {
|
|
885
|
+
const n = this.reduce(), i = n.length - 2, s = [];
|
|
886
|
+
for (let c = 0, r, l, u; c < i; c++)
|
|
887
|
+
l = n.slice(c, c + 1), u = n.slice(c + 2), r = this.curveintersects(l, u, e), s.push(...r);
|
|
888
|
+
return s;
|
|
889
|
+
}
|
|
890
|
+
curveintersects(e, n, i) {
|
|
891
|
+
const s = [];
|
|
892
|
+
e.forEach(function(r) {
|
|
893
|
+
n.forEach(function(l) {
|
|
894
|
+
r.overlaps(l) && s.push({ left: r, right: l });
|
|
895
|
+
});
|
|
896
|
+
});
|
|
897
|
+
let c = [];
|
|
898
|
+
return s.forEach(function(r) {
|
|
899
|
+
const l = y.pairiteration(
|
|
900
|
+
r.left,
|
|
901
|
+
r.right,
|
|
902
|
+
i
|
|
903
|
+
);
|
|
904
|
+
l.length > 0 && (c = c.concat(l));
|
|
905
|
+
}), c;
|
|
906
|
+
}
|
|
907
|
+
arcs(e) {
|
|
908
|
+
return e = e || 0.5, this._iterate(e, []);
|
|
909
|
+
}
|
|
910
|
+
_error(e, n, i, s) {
|
|
911
|
+
const c = (s - i) / 4, r = this.get(i + c), l = this.get(s - c), u = y.dist(e, n), f = y.dist(e, r), h = y.dist(e, l);
|
|
912
|
+
return G(f - u) + G(h - u);
|
|
913
|
+
}
|
|
914
|
+
_iterate(e, n) {
|
|
915
|
+
let i = 0, s = 1, c;
|
|
916
|
+
do {
|
|
917
|
+
c = 0, s = 1;
|
|
918
|
+
let r = this.get(i), l, u, f, h, a = !1, p = !1, g, _ = s, C = 1;
|
|
919
|
+
do
|
|
920
|
+
if (p = a, h = f, _ = (i + s) / 2, l = this.get(_), u = this.get(s), f = y.getccenter(r, l, u), f.interval = {
|
|
921
|
+
start: i,
|
|
922
|
+
end: s
|
|
923
|
+
}, a = this._error(f, r, i, s) <= e, g = p && !a, g || (C = s), a) {
|
|
924
|
+
if (s >= 1) {
|
|
925
|
+
if (f.interval.end = C = 1, h = f, s > 1) {
|
|
926
|
+
let S = {
|
|
927
|
+
x: f.x + f.r * rt(f.e),
|
|
928
|
+
y: f.y + f.r * st(f.e)
|
|
929
|
+
};
|
|
930
|
+
f.e += y.angle({ x: f.x, y: f.y }, S, this.get(1));
|
|
931
|
+
}
|
|
932
|
+
break;
|
|
933
|
+
}
|
|
934
|
+
s = s + (s - i) / 2;
|
|
935
|
+
} else
|
|
936
|
+
s = _;
|
|
937
|
+
while (!g && c++ < 100);
|
|
938
|
+
if (c >= 100)
|
|
939
|
+
break;
|
|
940
|
+
h = h || f, n.push(h), i = C;
|
|
941
|
+
} while (s < 1);
|
|
942
|
+
return n;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
function lt(o) {
|
|
946
|
+
let e = [], n = [], i = !1, s = !1, c = [], r = "", l = "", u = {
|
|
947
|
+
type: "Feature",
|
|
948
|
+
properties: {
|
|
949
|
+
fillColor: "",
|
|
950
|
+
MGValue: 1
|
|
951
|
+
},
|
|
952
|
+
geometry: {
|
|
953
|
+
type: "Polygon",
|
|
954
|
+
coordinates: [[]]
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
const f = (d, x) => {
|
|
958
|
+
u.properties.fillColor = d || "#ff0", u.properties.MGValue = x || 1, l = d || "#ff0";
|
|
959
|
+
}, h = (d, x) => {
|
|
960
|
+
i || (i = !0, f(d || "#ff0", x || 1), o.on("click", a), o.getCanvas().style.cursor = "crosshair");
|
|
961
|
+
}, a = () => {
|
|
962
|
+
if (s = !s, s)
|
|
963
|
+
r = C(), e.push(r), n.push(r), u.geometry.coordinates[0].length = 0, c.length = 0, o.addSource(r, { type: "geojson", data: u }), o.scrollZoom.disable(), o.dragPan.disable(), o.doubleClickZoom.disable(), o.addLayer({
|
|
964
|
+
id: r,
|
|
965
|
+
type: "fill",
|
|
966
|
+
source: r,
|
|
967
|
+
paint: {
|
|
968
|
+
"fill-antialias": !0,
|
|
969
|
+
"fill-color": l,
|
|
970
|
+
"fill-opacity": 0.8,
|
|
971
|
+
"fill-outline-color": "black"
|
|
972
|
+
}
|
|
973
|
+
}), o.addLayer({
|
|
974
|
+
id: "draw" + r,
|
|
975
|
+
type: "line",
|
|
976
|
+
source: r,
|
|
977
|
+
paint: {
|
|
978
|
+
"line-width": 2,
|
|
979
|
+
"line-color": "black"
|
|
980
|
+
}
|
|
981
|
+
}), o.on("mousemove", S);
|
|
982
|
+
else {
|
|
983
|
+
if (o.scrollZoom.enable(), o.dragPan.enable(), o.doubleClickZoom.enable(), o.removeLayer("draw" + r), o.off("mousemove", S), T(c)) {
|
|
984
|
+
alert("落区自相交,请重画"), e.pop(), n.pop(), o.removeLayer(r), o.removeSource(r);
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
const d = [...c.slice(c.length / 5), ...c.slice(0, c.length / 5)], m = new E(d).getLUT(100);
|
|
988
|
+
u.geometry.coordinates[0].length = 0;
|
|
989
|
+
for (let w = 0; w < m.length; w++) {
|
|
990
|
+
const b = o.unproject(m[w]);
|
|
991
|
+
u.geometry.coordinates[0].push(b.toArray());
|
|
992
|
+
}
|
|
993
|
+
const v = o.getSource(r);
|
|
994
|
+
v !== void 0 && v.setData(JSON.parse(JSON.stringify(u)));
|
|
995
|
+
}
|
|
996
|
+
}, p = (d) => {
|
|
997
|
+
c.push(d.point), u.geometry.coordinates[0].push(d.lngLat.toArray());
|
|
998
|
+
const x = o.getSource(r);
|
|
999
|
+
x !== void 0 && x.setData(u);
|
|
1000
|
+
}, g = () => {
|
|
1001
|
+
const d = n.slice(0, e.length), x = [];
|
|
1002
|
+
return d.forEach((m) => {
|
|
1003
|
+
const v = o.getSource(m);
|
|
1004
|
+
x.push(v.serialize().data);
|
|
1005
|
+
}), x;
|
|
1006
|
+
}, _ = () => {
|
|
1007
|
+
e.forEach((d) => o.removeLayer(d)), n.forEach((d) => o.removeSource(d)), e.length = 0, n.length = 0, o.off("click", a), o.getCanvas().style.cursor = "pointer", i = !1;
|
|
1008
|
+
}, C = () => {
|
|
1009
|
+
let d = (/* @__PURE__ */ new Date()).getTime();
|
|
1010
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(m) {
|
|
1011
|
+
const v = (d + Math.random() * 16) % 16 | 0;
|
|
1012
|
+
return d = Math.floor(d / 16), (m === "x" ? v : v & 3 | 8).toString(16);
|
|
1013
|
+
});
|
|
1014
|
+
}, S = ((d, x) => {
|
|
1015
|
+
let m = 0;
|
|
1016
|
+
return function(...v) {
|
|
1017
|
+
const w = (/* @__PURE__ */ new Date()).getTime();
|
|
1018
|
+
w - m < x || (m = w, d(...v));
|
|
1019
|
+
};
|
|
1020
|
+
})(p, 20), j = () => {
|
|
1021
|
+
e.length && (o.removeLayer(e[e.length - 1]), e.pop());
|
|
1022
|
+
}, O = () => {
|
|
1023
|
+
if (n.length) {
|
|
1024
|
+
const d = e.length - n.length, x = n.slice(d);
|
|
1025
|
+
if (console.log(x), d !== 0 && x.length) {
|
|
1026
|
+
const m = o.getSource(x[0]);
|
|
1027
|
+
console.log(m, "source");
|
|
1028
|
+
let v = "";
|
|
1029
|
+
m && (v = m.serialize().data.valueOf().properties.fillColor), o.getLayer(x[0]) || (e.push(x[0]), o.addLayer({
|
|
1030
|
+
id: x[0],
|
|
1031
|
+
type: "fill",
|
|
1032
|
+
source: x[0],
|
|
1033
|
+
paint: {
|
|
1034
|
+
"fill-color": v,
|
|
1035
|
+
"fill-opacity": 0.8,
|
|
1036
|
+
"fill-outline-color": "black"
|
|
1037
|
+
}
|
|
1038
|
+
}));
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}, T = (d) => {
|
|
1042
|
+
let x = !1, m = d, v = [], w = m.length - 1;
|
|
1043
|
+
for (let k = 0; k < w; k++) {
|
|
1044
|
+
let q = m[k], M = m[k + 1];
|
|
1045
|
+
(q.x != M.x || q.y != M.y) && v.push(q);
|
|
1046
|
+
}
|
|
1047
|
+
let b = v.length - 1;
|
|
1048
|
+
for (let k = 0; k < b; k++) {
|
|
1049
|
+
let q = v[k], M = v[k + 1];
|
|
1050
|
+
for (let I = k + 2; I < b; I++) {
|
|
1051
|
+
let W = v[I], D = v[I + 1], Y = z(q, M, W, D);
|
|
1052
|
+
if (Y == null && M.x == D.x && M.y == D.y && (Y = { x: M.x, y: M.y }), Y != null) {
|
|
1053
|
+
x = !0;
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
if (x)
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
return x;
|
|
1061
|
+
}, z = (d, x, m, v) => {
|
|
1062
|
+
var w = null, b = (d.x - m.x) * (x.y - m.y) - (d.y - m.y) * (x.x - m.x), k = (d.x - v.x) * (x.y - v.y) - (d.y - v.y) * (x.x - v.x);
|
|
1063
|
+
if (b * k >= 0)
|
|
1064
|
+
return w;
|
|
1065
|
+
var q = (m.x - d.x) * (v.y - d.y) - (m.y - d.y) * (v.x - d.x), M = q + b - k;
|
|
1066
|
+
if (q * M >= 0)
|
|
1067
|
+
return w;
|
|
1068
|
+
var I = q / (k - b), W = I * (x.x - d.x), D = I * (x.y - d.y);
|
|
1069
|
+
return w = { x: d.x + W, y: d.y + D }, w;
|
|
1070
|
+
};
|
|
1071
|
+
return { isStart: i, start: h, getFeatures: g, clear: _, revoke: j, redo: O, setColor: f };
|
|
1072
|
+
}
|
|
1073
|
+
const ut = { drawFreehand: lt };
|
|
1074
|
+
export {
|
|
1075
|
+
ut as default
|
|
1076
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(N,A){typeof exports=="object"&&typeof module<"u"?module.exports=A():typeof define=="function"&&define.amd?define(A):(N=typeof globalThis<"u"?globalThis:N||self,N.index=A())})(this,function(){"use strict";const{abs:N,cos:A,sin:D,acos:et,atan2:R,sqrt:P,pow:L}=Math;function J(o){return o<0?-L(-o,1/3):L(o,1/3)}const K=Math.PI,X=2*K,U=K/2,nt=1e-6,W=Number.MAX_SAFE_INTEGER||9007199254740991,Y=Number.MIN_SAFE_INTEGER||-9007199254740991,it={x:0,y:0,z:0},y={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(o,e){const n=e(o);let i=n.x*n.x+n.y*n.y;return typeof n.z<"u"&&(i+=n.z*n.z),P(i)},compute:function(o,e,n){if(o===0)return e[0].t=0,e[0];const i=e.length-1;if(o===1)return e[i].t=1,e[i];const s=1-o;let c=e;if(i===0)return e[0].t=o,e[0];if(i===1){const l={x:s*c[0].x+o*c[1].x,y:s*c[0].y+o*c[1].y,t:o};return n&&(l.z=s*c[0].z+o*c[1].z),l}if(i<4){let l=s*s,u=o*o,f,h,a,p=0;i===2?(c=[c[0],c[1],c[2],it],f=l,h=s*o*2,a=u):i===3&&(f=l*s,h=l*o*3,a=s*u*3,p=o*u);const g={x:f*c[0].x+h*c[1].x+a*c[2].x+p*c[3].x,y:f*c[0].y+h*c[1].y+a*c[2].y+p*c[3].y,t:o};return n&&(g.z=f*c[0].z+h*c[1].z+a*c[2].z+p*c[3].z),g}const r=JSON.parse(JSON.stringify(e));for(;r.length>1;){for(let l=0;l<r.length-1;l++)r[l]={x:r[l].x+(r[l+1].x-r[l].x)*o,y:r[l].y+(r[l+1].y-r[l].y)*o},typeof r[l].z<"u"&&(r[l].z=r[l].z+(r[l+1].z-r[l].z)*o);r.splice(r.length-1,1)}return r[0].t=o,r[0]},computeWithRatios:function(o,e,n,i){const s=1-o,c=n,r=e;let l=c[0],u=c[1],f=c[2],h=c[3],a;if(l*=s,u*=o,r.length===2)return a=l+u,{x:(l*r[0].x+u*r[1].x)/a,y:(l*r[0].y+u*r[1].y)/a,z:i?(l*r[0].z+u*r[1].z)/a:!1,t:o};if(l*=s,u*=2*s,f*=o*o,r.length===3)return a=l+u+f,{x:(l*r[0].x+u*r[1].x+f*r[2].x)/a,y:(l*r[0].y+u*r[1].y+f*r[2].y)/a,z:i?(l*r[0].z+u*r[1].z+f*r[2].z)/a:!1,t:o};if(l*=s,u*=1.5*s,f*=3*s,h*=o*o*o,r.length===4)return a=l+u+f+h,{x:(l*r[0].x+u*r[1].x+f*r[2].x+h*r[3].x)/a,y:(l*r[0].y+u*r[1].y+f*r[2].y+h*r[3].y)/a,z:i?(l*r[0].z+u*r[1].z+f*r[2].z+h*r[3].z)/a:!1,t:o}},derive:function(o,e){const n=[];for(let i=o,s=i.length,c=s-1;s>1;s--,c--){const r=[];for(let l=0,u;l<c;l++)u={x:c*(i[l+1].x-i[l].x),y:c*(i[l+1].y-i[l].y)},e&&(u.z=c*(i[l+1].z-i[l].z)),r.push(u);n.push(r),i=r}return n},between:function(o,e,n){return e<=o&&o<=n||y.approximately(o,e)||y.approximately(o,n)},approximately:function(o,e,n){return N(o-e)<=(n||nt)},length:function(o){const n=y.Tvalues.length;let i=0;for(let s=0,c;s<n;s++)c=.5*y.Tvalues[s]+.5,i+=y.Cvalues[s]*y.arcfn(c,o);return .5*i},map:function(o,e,n,i,s){const c=n-e,r=s-i,l=o-e,u=l/c;return i+r*u},lerp:function(o,e,n){const i={x:e.x+o*(n.x-e.x),y:e.y+o*(n.y-e.y)};return e.z!==void 0&&n.z!==void 0&&(i.z=e.z+o*(n.z-e.z)),i},pointToString:function(o){let e=o.x+"/"+o.y;return typeof o.z<"u"&&(e+="/"+o.z),e},pointsToString:function(o){return"["+o.map(y.pointToString).join(", ")+"]"},copy:function(o){return JSON.parse(JSON.stringify(o))},angle:function(o,e,n){const i=e.x-o.x,s=e.y-o.y,c=n.x-o.x,r=n.y-o.y,l=i*r-s*c,u=i*c+s*r;return R(l,u)},round:function(o,e){const n=""+o,i=n.indexOf(".");return parseFloat(n.substring(0,i+1+e))},dist:function(o,e){const n=o.x-e.x,i=o.y-e.y;return P(n*n+i*i)},closest:function(o,e){let n=L(2,63),i,s;return o.forEach(function(c,r){s=y.dist(e,c),s<n&&(n=s,i=r)}),{mdist:n,mpos:i}},abcratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const n=L(o,e)+L(1-o,e),i=n-1;return N(i/n)},projectionratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const n=L(1-o,e),i=L(o,e)+n;return n/i},lli8:function(o,e,n,i,s,c,r,l){const u=(o*i-e*n)*(s-r)-(o-n)*(s*l-c*r),f=(o*i-e*n)*(c-l)-(e-i)*(s*l-c*r),h=(o-n)*(c-l)-(e-i)*(s-r);return h==0?!1:{x:u/h,y:f/h}},lli4:function(o,e,n,i){const s=o.x,c=o.y,r=e.x,l=e.y,u=n.x,f=n.y,h=i.x,a=i.y;return y.lli8(s,c,r,l,u,f,h,a)},lli:function(o,e){return y.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new C(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=W,n=W,i=Y,s=Y;return o.forEach(function(c){const r=c.bbox();e>r.x.min&&(e=r.x.min),n>r.y.min&&(n=r.y.min),i<r.x.max&&(i=r.x.max),s<r.y.max&&(s=r.y.max)}),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:n,mid:(n+s)/2,max:s,size:s-n}}},shapeintersections:function(o,e,n,i,s){if(!y.bboxoverlap(e,i))return[];const c=[],r=[o.startcap,o.forward,o.back,o.endcap],l=[n.startcap,n.forward,n.back,n.endcap];return r.forEach(function(u){u.virtual||l.forEach(function(f){if(f.virtual)return;const h=u.intersects(f,s);h.length>0&&(h.c1=u,h.c2=f,h.s1=o,h.s2=n,c.push(h))})}),c},makeshape:function(o,e,n){const i=e.points.length,s=o.points.length,c=y.makeline(e.points[i-1],o.points[0]),r=y.makeline(o.points[s-1],e.points[0]),l={startcap:c,forward:o,back:e,endcap:r,bbox:y.findbbox([c,o,e,r])};return l.intersections=function(u){return y.shapeintersections(l,l.bbox,u,u.bbox,n)},l},getminmax:function(o,e,n){if(!n)return{min:0,max:0};let i=W,s=Y,c,r;n.indexOf(0)===-1&&(n=[0].concat(n)),n.indexOf(1)===-1&&n.push(1);for(let l=0,u=n.length;l<u;l++)c=n[l],r=o.get(c),r[e]<i&&(i=r[e]),r[e]>s&&(s=r[e]);return{min:i,mid:(i+s)/2,max:s,size:s-i}},align:function(o,e){const n=e.p1.x,i=e.p1.y,s=-R(e.p2.y-i,e.p2.x-n),c=function(r){return{x:(r.x-n)*A(s)-(r.y-i)*D(s),y:(r.x-n)*D(s)+(r.y-i)*A(s)}};return o.map(c)},roots:function(o,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=o.length-1,i=y.align(o,e),s=function(x){return 0<=x&&x<=1};if(n===2){const x=i[0].y,m=i[1].y,v=i[2].y,w=x-2*m+v;if(w!==0){const O=-P(m*m-x*v),k=-x+m,q=-(O+k)/w,M=-(-O+k)/w;return[q,M].filter(s)}else if(m!==v&&w===0)return[(2*m-v)/(2*m-2*v)].filter(s);return[]}const c=i[0].y,r=i[1].y,l=i[2].y,u=i[3].y;let f=-c+3*r-3*l+u,h=3*c-6*r+3*l,a=-3*c+3*r,p=c;if(y.approximately(f,0)){if(y.approximately(h,0))return y.approximately(a,0)?[]:[-p/a].filter(s);const x=P(a*a-4*h*p),m=2*h;return[(x-a)/m,(-a-x)/m].filter(s)}h/=f,a/=f,p/=f;const g=(3*a-h*h)/3,_=g/3,E=(2*h*h*h-9*h*a+27*p)/27,T=E/2,S=T*T+_*_*_;let j,b,I,z,d;if(S<0){const x=-g/3,m=x*x*x,v=P(m),w=-E/(2*v),O=w<-1?-1:w>1?1:w,k=et(O),q=J(v),M=2*q;return I=M*A(k/3)-h/3,z=M*A((k+X)/3)-h/3,d=M*A((k+2*X)/3)-h/3,[I,z,d].filter(s)}else{if(S===0)return j=T<0?J(-T):-J(T),I=2*j-h/3,z=-j-h/3,[I,z].filter(s);{const x=P(S);return j=J(-T+x),b=J(T+x),[j-b-h/3].filter(s)}}},droots:function(o){if(o.length===3){const e=o[0],n=o[1],i=o[2],s=e-2*n+i;if(s!==0){const c=-P(n*n-e*i),r=-e+n,l=-(c+r)/s,u=-(-c+r)/s;return[l,u]}else if(n!==i&&s===0)return[(2*n-i)/(2*(n-i))];return[]}if(o.length===2){const e=o[0],n=o[1];return e!==n?[e/(e-n)]:[]}return[]},curvature:function(o,e,n,i,s){let c,r,l,u,f=0,h=0;const a=y.compute(o,e),p=y.compute(o,n),g=a.x*a.x+a.y*a.y;if(i?(c=P(L(a.y*p.z-p.y*a.z,2)+L(a.z*p.x-p.z*a.x,2)+L(a.x*p.y-p.x*a.y,2)),r=L(g+a.z*a.z,3/2)):(c=a.x*p.y-a.y*p.x,r=L(g,3/2)),c===0||r===0)return{k:0,r:0};if(f=c/r,h=r/c,!s){const _=y.curvature(o-.001,e,n,i,!0).k,E=y.curvature(o+.001,e,n,i,!0).k;u=(E-f+(f-_))/2,l=(N(E-f)+N(f-_))/2}return{k:f,r:h,dk:u,adk:l}},inflections:function(o){if(o.length<4)return[];const e=y.align(o,{p1:o[0],p2:o.slice(-1)[0]}),n=e[2].x*e[1].y,i=e[3].x*e[1].y,s=e[1].x*e[2].y,c=e[3].x*e[2].y,r=18*(-3*n+2*i+3*s-c),l=18*(3*n-i-3*s),u=18*(s-n);if(y.approximately(r,0)){if(!y.approximately(l,0)){let p=-u/l;if(0<=p&&p<=1)return[p]}return[]}const f=2*r;if(y.approximately(f,0))return[];const h=l*l-4*r*u;if(h<0)return[];const a=Math.sqrt(h);return[(a-l)/f,-(l+a)/f].filter(function(p){return 0<=p&&p<=1})},bboxoverlap:function(o,e){const n=["x","y"],i=n.length;for(let s=0,c,r,l,u;s<i;s++)if(c=n[s],r=o[c].mid,l=e[c].mid,u=(o[c].size+e[c].size)/2,N(r-l)>=u)return!1;return!0},expandbox:function(o,e){e.x.min<o.x.min&&(o.x.min=e.x.min),e.y.min<o.y.min&&(o.y.min=e.y.min),e.z&&e.z.min<o.z.min&&(o.z.min=e.z.min),e.x.max>o.x.max&&(o.x.max=e.x.max),e.y.max>o.y.max&&(o.y.max=e.y.max),e.z&&e.z.max>o.z.max&&(o.z.max=e.z.max),o.x.mid=(o.x.min+o.x.max)/2,o.y.mid=(o.y.min+o.y.max)/2,o.z&&(o.z.mid=(o.z.min+o.z.max)/2),o.x.size=o.x.max-o.x.min,o.y.size=o.y.max-o.y.min,o.z&&(o.z.size=o.z.max-o.z.min)},pairiteration:function(o,e,n){const i=o.bbox(),s=e.bbox(),c=1e5,r=n||.5;if(i.x.size+i.y.size<r&&s.x.size+s.y.size<r)return[(c*(o._t1+o._t2)/2|0)/c+"/"+(c*(e._t1+e._t2)/2|0)/c];let l=o.split(.5),u=e.split(.5),f=[{left:l.left,right:u.left},{left:l.left,right:u.right},{left:l.right,right:u.right},{left:l.right,right:u.left}];f=f.filter(function(a){return y.bboxoverlap(a.left.bbox(),a.right.bbox())});let h=[];return f.length===0||(f.forEach(function(a){h=h.concat(y.pairiteration(a.left,a.right,r))}),h=h.filter(function(a,p){return h.indexOf(a)===p})),h},getccenter:function(o,e,n){const i=e.x-o.x,s=e.y-o.y,c=n.x-e.x,r=n.y-e.y,l=i*A(U)-s*D(U),u=i*D(U)+s*A(U),f=c*A(U)-r*D(U),h=c*D(U)+r*A(U),a=(o.x+e.x)/2,p=(o.y+e.y)/2,g=(e.x+n.x)/2,_=(e.y+n.y)/2,E=a+l,T=p+u,S=g+f,j=_+h,b=y.lli8(a,p,E,T,g,_,S,j),I=y.dist(b,o);let z=R(o.y-b.y,o.x-b.x),d=R(e.y-b.y,e.x-b.x),x=R(n.y-b.y,n.x-b.x),m;return z<x?((z>d||d>x)&&(z+=X),z>x&&(m=x,x=z,z=m)):x<d&&d<z?(m=x,x=z,z=m):x+=X,b.s=z,b.e=x,b.r=I,b},numberSort:function(o,e){return o-e}};class ${constructor(e){this.curves=[],this._3d=!1,e&&(this.curves=e,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(e){return y.pointsToString(e.points)}).join(", ")+"]"}addCurve(e){this.curves.push(e),this._3d=this._3d||e._3d}length(){return this.curves.map(function(e){return e.length()}).reduce(function(e,n){return e+n})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var n=e[0].bbox(),i=1;i<e.length;i++)y.expandbox(n,e[i].bbox());return n}offset(e){const n=[];return this.curves.forEach(function(i){n.push(...i.offset(e))}),new $(n)}}const{abs:G,min:B,max:tt,cos:rt,sin:st,acos:ot,sqrt:Z}=Math,ct=Math.PI;class C{constructor(e){let n=e&&e.forEach?e:Array.from(arguments).slice(),i=!1;if(typeof n[0]=="object"){i=n.length;const g=[];n.forEach(function(_){["x","y","z"].forEach(function(E){typeof _[E]<"u"&&g.push(_[E])})}),n=g}let s=!1;const c=n.length;if(i){if(i>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");s=!0}}else if(c!==6&&c!==8&&c!==9&&c!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const r=this._3d=!s&&(c===9||c===12)||e&&e[0]&&typeof e[0].z<"u",l=this.points=[];for(let g=0,_=r?3:2;g<c;g+=_){var u={x:n[g],y:n[g+1]};r&&(u.z=n[g+2]),l.push(u)}const f=this.order=l.length-1,h=this.dims=["x","y"];r&&h.push("z"),this.dimlen=h.length;const a=y.align(l,{p1:l[0],p2:l[f]}),p=y.dist(l[0],l[f]);this._linear=a.reduce((g,_)=>g+G(_.y),0)<p/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,n,i,s){if(typeof s>"u"&&(s=.5),s===0)return new C(n,n,i);if(s===1)return new C(e,n,n);const c=C.getABC(2,e,n,i,s);return new C(e,c.A,i)}static cubicFromPoints(e,n,i,s,c){typeof s>"u"&&(s=.5);const r=C.getABC(3,e,n,i,s);typeof c>"u"&&(c=y.dist(n,r.C));const l=c*(1-s)/s,u=y.dist(e,i),f=(i.x-e.x)/u,h=(i.y-e.y)/u,a=c*f,p=c*h,g=l*f,_=l*h,E={x:n.x-a,y:n.y-p},T={x:n.x+g,y:n.y+_},S=r.A,j={x:S.x+(E.x-S.x)/(1-s),y:S.y+(E.y-S.y)/(1-s)},b={x:S.x+(T.x-S.x)/s,y:S.y+(T.y-S.y)/s},I={x:e.x+(j.x-e.x)/s,y:e.y+(j.y-e.y)/s},z={x:i.x+(b.x-i.x)/(1-s),y:i.y+(b.y-i.y)/(1-s)};return new C(e,I,z,i)}static getUtils(){return y}getUtils(){return C.getUtils()}static get PolyBezier(){return $}valueOf(){return this.toString()}toString(){return y.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,n=e[0].x,i=e[0].y,s=["M",n,i,this.order===2?"Q":"C"];for(let c=1,r=e.length;c<r;c++)s.push(e[c].x),s.push(e[c].y);return s.join(" ")}setRatios(e){if(e.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=e,this._lut=[]}verify(){const e=this.coordDigest();e!==this._print&&(this._print=e,this.update())}coordDigest(){return this.points.map(function(e,n){return""+n+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=y.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,n=y.angle(e[0],e[this.order],e[1]);this.clockwise=n>0}length(){return y.length(this.derivative.bind(this))}static getABC(e=2,n,i,s,c=.5){const r=y.projectionratio(c,e),l=1-r,u={x:r*n.x+l*s.x,y:r*n.y+l*s.y},f=y.abcratio(c,e);return{A:{x:i.x+(i.x-u.x)/f,y:i.y+(i.y-u.y)/f},B:i,C:u,S:n,E:s}}getABC(e,n){n=n||this.get(e);let i=this.points[0],s=this.points[this.order];return C.getABC(this.order,i,n,s,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let n=0,i,s;n<e;n++)s=n/(e-1),i=this.compute(s),i.t=s,this._lut.push(i);return this._lut}on(e,n){n=n||5;const i=this.getLUT(),s=[];for(let c=0,r,l=0;c<i.length;c++)r=i[c],y.dist(r,e)<n&&(s.push(r),l+=c/i.length);return s.length?t/=s.length:!1}project(e){const n=this.getLUT(),i=n.length-1,s=y.closest(n,e),c=s.mpos,r=(c-1)/i,l=(c+1)/i,u=.1/i;let f=s.mdist,h=r,a=h,p;f+=1;for(let g;h<l+u;h+=u)p=this.compute(h),g=y.dist(e,p),g<f&&(f=g,a=h);return a=a<0?0:a>1?1:a,p=this.compute(a),p.t=a,p.d=f,p}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?y.computeWithRatios(e,this.points,this.ratios,this._3d):y.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,n=[e[0]],i=e.length;for(let s=1,c,r;s<i;s++)c=e[s],r=e[s-1],n[s]={x:(i-s)/i*c.x+s/i*r.x,y:(i-s)/i*c.y+s/i*r.y};return n[i]=e[i-1],new C(n)}derivative(e){return y.compute(e,this.dpoints[0],this._3d)}dderivative(e){return y.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new C(y.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return y.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return y.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const n=this.derivative(e),i=Z(n.x*n.x+n.y*n.y);return{t:e,x:-n.y/i,y:n.x/i}}__normal3(e){const n=this.derivative(e),i=this.derivative(e+.01),s=Z(n.x*n.x+n.y*n.y+n.z*n.z),c=Z(i.x*i.x+i.y*i.y+i.z*i.z);n.x/=s,n.y/=s,n.z/=s,i.x/=c,i.y/=c,i.z/=c;const r={x:i.y*n.z-i.z*n.y,y:i.z*n.x-i.x*n.z,z:i.x*n.y-i.y*n.x},l=Z(r.x*r.x+r.y*r.y+r.z*r.z);r.x/=l,r.y/=l,r.z/=l;const u=[r.x*r.x,r.x*r.y-r.z,r.x*r.z+r.y,r.x*r.y+r.z,r.y*r.y,r.y*r.z-r.x,r.x*r.z-r.y,r.y*r.z+r.x,r.z*r.z];return{t:e,x:u[0]*n.x+u[1]*n.y+u[2]*n.z,y:u[3]*n.x+u[4]*n.y+u[5]*n.z,z:u[6]*n.x+u[7]*n.y+u[8]*n.z}}hull(e){let n=this.points,i=[],s=[],c=0;for(s[c++]=n[0],s[c++]=n[1],s[c++]=n[2],this.order===3&&(s[c++]=n[3]);n.length>1;){i=[];for(let r=0,l,u=n.length-1;r<u;r++)l=y.lerp(e,n[r],n[r+1]),s[c++]=l,i.push(l);n=i}return s}split(e,n){if(e===0&&n)return this.split(n).left;if(n===1)return this.split(e).right;const i=this.hull(e),s={left:this.order===2?new C([i[0],i[3],i[5]]):new C([i[0],i[4],i[7],i[9]]),right:this.order===2?new C([i[5],i[4],i[2]]):new C([i[9],i[8],i[6],i[3]]),span:i};return s.left._t1=y.map(0,0,1,this._t1,this._t2),s.left._t2=y.map(e,0,1,this._t1,this._t2),s.right._t1=y.map(e,0,1,this._t1,this._t2),s.right._t2=y.map(1,0,1,this._t1,this._t2),n?(n=y.map(n,e,1,0,1),s.right.split(n).left):s}extrema(){const e={};let n=[];return this.dims.forEach((function(i){let s=function(r){return r[i]},c=this.dpoints[0].map(s);e[i]=y.droots(c),this.order===3&&(c=this.dpoints[1].map(s),e[i]=e[i].concat(y.droots(c))),e[i]=e[i].filter(function(r){return r>=0&&r<=1}),n=n.concat(e[i].sort(y.numberSort))}).bind(this)),e.values=n.sort(y.numberSort).filter(function(i,s){return n.indexOf(i)===s}),e}bbox(){const e=this.extrema(),n={};return this.dims.forEach((function(i){n[i]=y.getminmax(this,i,e[i])}).bind(this)),n}overlaps(e){const n=this.bbox(),i=e.bbox();return y.bboxoverlap(n,i)}offset(e,n){if(typeof n<"u"){const i=this.get(e),s=this.normal(e),c={c:i,n:s,x:i.x+s.x*n,y:i.y+s.y*n};return this._3d&&(c.z=i.z+s.z*n),c}if(this._linear){const i=this.normal(0),s=this.points.map(function(c){const r={x:c.x+e*i.x,y:c.y+e*i.y};return c.z&&i.z&&(r.z=c.z+e*i.z),r});return[new C(s)]}return this.reduce().map(function(i){return i._linear?i.offset(e)[0]:i.scale(e)})}simple(){if(this.order===3){const s=y.angle(this.points[0],this.points[3],this.points[1]),c=y.angle(this.points[0],this.points[3],this.points[2]);if(s>0&&c<0||s<0&&c>0)return!1}const e=this.normal(0),n=this.normal(1);let i=e.x*n.x+e.y*n.y;return this._3d&&(i+=e.z*n.z),G(ot(i))<ct/3}reduce(){let e,n=0,i=0,s=.01,c,r=[],l=[],u=this.extrema().values;for(u.indexOf(0)===-1&&(u=[0].concat(u)),u.indexOf(1)===-1&&u.push(1),n=u[0],e=1;e<u.length;e++)i=u[e],c=this.split(n,i),c._t1=n,c._t2=i,r.push(c),n=i;return r.forEach(function(f){for(n=0,i=0;i<=1;)for(i=n+s;i<=1+s;i+=s)if(c=f.split(n,i),!c.simple()){if(i-=s,G(n-i)<s)return[];c=f.split(n,i),c._t1=y.map(n,0,1,f._t1,f._t2),c._t2=y.map(i,0,1,f._t1,f._t2),l.push(c),n=i;break}n<1&&(c=f.split(n,1),c._t1=y.map(n,0,1,f._t1,f._t2),c._t2=f._t2,l.push(c))}),l}translate(e,n,i){i=typeof i=="number"?i:n;const s=this.order;let c=this.points.map((r,l)=>(1-l/s)*n+l/s*i);return new C(this.points.map((r,l)=>({x:r.x+e.x*c[l],y:r.y+e.y*c[l]})))}scale(e){const n=this.order;let i=!1;if(typeof e=="function"&&(i=e),i&&n===2)return this.raise().scale(i);const s=this.clockwise,c=this.points;if(this._linear)return this.translate(this.normal(0),i?i(0):e,i?i(1):e);const r=i?i(0):e,l=i?i(1):e,u=[this.offset(0,10),this.offset(1,10)],f=[],h=y.lli4(u[0],u[0].c,u[1],u[1].c);if(!h)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(a){const p=f[a*n]=y.copy(c[a*n]);p.x+=(a?l:r)*u[a].n.x,p.y+=(a?l:r)*u[a].n.y}),i?([0,1].forEach(function(a){if(!(n===2&&a)){var p=c[a+1],g={x:p.x-h.x,y:p.y-h.y},_=i?i((a+1)/n):e;i&&!s&&(_=-_);var E=Z(g.x*g.x+g.y*g.y);g.x/=E,g.y/=E,f[a+1]={x:p.x+_*g.x,y:p.y+_*g.y}}}),new C(f)):([0,1].forEach(a=>{if(n===2&&a)return;const p=f[a*n],g=this.derivative(a),_={x:p.x+g.x,y:p.y+g.y};f[a+1]=y.lli4(p,_,h,c[a+1])}),new C(f))}outline(e,n,i,s){if(n=n===void 0?e:n,this._linear){const z=this.normal(0),d=this.points[0],x=this.points[this.points.length-1];let m,v,w;i===void 0&&(i=e,s=n),m={x:d.x+z.x*e,y:d.y+z.y*e},w={x:x.x+z.x*i,y:x.y+z.y*i},v={x:(m.x+w.x)/2,y:(m.y+w.y)/2};const O=[m,v,w];m={x:d.x-z.x*n,y:d.y-z.y*n},w={x:x.x-z.x*s,y:x.y-z.y*s},v={x:(m.x+w.x)/2,y:(m.y+w.y)/2};const k=[w,v,m],q=y.makeline(k[2],O[0]),M=y.makeline(O[2],k[0]),F=[q,new C(O),M,new C(k)];return new $(F)}const c=this.reduce(),r=c.length,l=[];let u=[],f,h=0,a=this.length();const p=typeof i<"u"&&typeof s<"u";function g(z,d,x,m,v){return function(w){const O=m/x,k=(m+v)/x,q=d-z;return y.map(w,0,1,z+O*q,z+k*q)}}c.forEach(function(z){const d=z.length();p?(l.push(z.scale(g(e,i,a,h,d))),u.push(z.scale(g(-n,-s,a,h,d)))):(l.push(z.scale(e)),u.push(z.scale(-n))),h+=d}),u=u.map(function(z){return f=z.points,f[3]?z.points=[f[3],f[2],f[1],f[0]]:z.points=[f[2],f[1],f[0]],z}).reverse();const _=l[0].points[0],E=l[r-1].points[l[r-1].points.length-1],T=u[r-1].points[u[r-1].points.length-1],S=u[0].points[0],j=y.makeline(T,_),b=y.makeline(E,S),I=[j].concat(l).concat([b]).concat(u);return new $(I)}outlineshapes(e,n,i){n=n||e;const s=this.outline(e,n).curves,c=[];for(let r=1,l=s.length;r<l/2;r++){const u=y.makeshape(s[r],s[l-r],i);u.startcap.virtual=r>1,u.endcap.virtual=r<l/2-1,c.push(u)}return c}intersects(e,n){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof C&&(e=e.reduce()),this.curveintersects(this.reduce(),e,n)):this.selfintersects(n)}lineIntersects(e){const n=B(e.p1.x,e.p2.x),i=B(e.p1.y,e.p2.y),s=tt(e.p1.x,e.p2.x),c=tt(e.p1.y,e.p2.y);return y.roots(this.points,e).filter(r=>{var l=this.get(r);return y.between(l.x,n,s)&&y.between(l.y,i,c)})}selfintersects(e){const n=this.reduce(),i=n.length-2,s=[];for(let c=0,r,l,u;c<i;c++)l=n.slice(c,c+1),u=n.slice(c+2),r=this.curveintersects(l,u,e),s.push(...r);return s}curveintersects(e,n,i){const s=[];e.forEach(function(r){n.forEach(function(l){r.overlaps(l)&&s.push({left:r,right:l})})});let c=[];return s.forEach(function(r){const l=y.pairiteration(r.left,r.right,i);l.length>0&&(c=c.concat(l))}),c}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,n,i,s){const c=(s-i)/4,r=this.get(i+c),l=this.get(s-c),u=y.dist(e,n),f=y.dist(e,r),h=y.dist(e,l);return G(f-u)+G(h-u)}_iterate(e,n){let i=0,s=1,c;do{c=0,s=1;let r=this.get(i),l,u,f,h,a=!1,p=!1,g,_=s,E=1;do if(p=a,h=f,_=(i+s)/2,l=this.get(_),u=this.get(s),f=y.getccenter(r,l,u),f.interval={start:i,end:s},a=this._error(f,r,i,s)<=e,g=p&&!a,g||(E=s),a){if(s>=1){if(f.interval.end=E=1,h=f,s>1){let S={x:f.x+f.r*rt(f.e),y:f.y+f.r*st(f.e)};f.e+=y.angle({x:f.x,y:f.y},S,this.get(1))}break}s=s+(s-i)/2}else s=_;while(!g&&c++<100);if(c>=100)break;h=h||f,n.push(h),i=E}while(s<1);return n}}function lt(o){let e=[],n=[],i=!1,s=!1,c=[],r="",l="",u={type:"Feature",properties:{fillColor:"",MGValue:1},geometry:{type:"Polygon",coordinates:[[]]}};const f=(d,x)=>{u.properties.fillColor=d||"#ff0",u.properties.MGValue=x||1,l=d||"#ff0"},h=(d,x)=>{i||(i=!0,f(d||"#ff0",x||1),o.on("click",a),o.getCanvas().style.cursor="crosshair")},a=()=>{if(s=!s,s)r=E(),e.push(r),n.push(r),u.geometry.coordinates[0].length=0,c.length=0,o.addSource(r,{type:"geojson",data:u}),o.scrollZoom.disable(),o.dragPan.disable(),o.doubleClickZoom.disable(),o.addLayer({id:r,type:"fill",source:r,paint:{"fill-antialias":!0,"fill-color":l,"fill-opacity":.8,"fill-outline-color":"black"}}),o.addLayer({id:"draw"+r,type:"line",source:r,paint:{"line-width":2,"line-color":"black"}}),o.on("mousemove",S);else{if(o.scrollZoom.enable(),o.dragPan.enable(),o.doubleClickZoom.enable(),o.removeLayer("draw"+r),o.off("mousemove",S),I(c)){alert("落区自相交,请重画"),e.pop(),n.pop(),o.removeLayer(r),o.removeSource(r);return}const d=[...c.slice(c.length/5),...c.slice(0,c.length/5)],m=new C(d).getLUT(100);u.geometry.coordinates[0].length=0;for(let w=0;w<m.length;w++){const O=o.unproject(m[w]);u.geometry.coordinates[0].push(O.toArray())}const v=o.getSource(r);v!==void 0&&v.setData(JSON.parse(JSON.stringify(u)))}},p=d=>{c.push(d.point),u.geometry.coordinates[0].push(d.lngLat.toArray());const x=o.getSource(r);x!==void 0&&x.setData(u)},g=()=>{const d=n.slice(0,e.length),x=[];return d.forEach(m=>{const v=o.getSource(m);x.push(v.serialize().data)}),x},_=()=>{e.forEach(d=>o.removeLayer(d)),n.forEach(d=>o.removeSource(d)),e.length=0,n.length=0,o.off("click",a),o.getCanvas().style.cursor="pointer",i=!1},E=()=>{let d=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){const v=(d+Math.random()*16)%16|0;return d=Math.floor(d/16),(m==="x"?v:v&3|8).toString(16)})},S=((d,x)=>{let m=0;return function(...v){const w=new Date().getTime();w-m<x||(m=w,d(...v))}})(p,20),j=()=>{e.length&&(o.removeLayer(e[e.length-1]),e.pop())},b=()=>{if(n.length){const d=e.length-n.length,x=n.slice(d);if(console.log(x),d!==0&&x.length){const m=o.getSource(x[0]);console.log(m,"source");let v="";m&&(v=m.serialize().data.valueOf().properties.fillColor),o.getLayer(x[0])||(e.push(x[0]),o.addLayer({id:x[0],type:"fill",source:x[0],paint:{"fill-color":v,"fill-opacity":.8,"fill-outline-color":"black"}}))}}},I=d=>{let x=!1,m=d,v=[],w=m.length-1;for(let k=0;k<w;k++){let q=m[k],M=m[k+1];(q.x!=M.x||q.y!=M.y)&&v.push(q)}let O=v.length-1;for(let k=0;k<O;k++){let q=v[k],M=v[k+1];for(let F=k+2;F<O;F++){let Q=v[F],V=v[F+1],H=z(q,M,Q,V);if(H==null&&M.x==V.x&&M.y==V.y&&(H={x:M.x,y:M.y}),H!=null){x=!0;break}}if(x)break}return x},z=(d,x,m,v)=>{var w=null,O=(d.x-m.x)*(x.y-m.y)-(d.y-m.y)*(x.x-m.x),k=(d.x-v.x)*(x.y-v.y)-(d.y-v.y)*(x.x-v.x);if(O*k>=0)return w;var q=(m.x-d.x)*(v.y-d.y)-(m.y-d.y)*(v.x-d.x),M=q+O-k;if(q*M>=0)return w;var F=q/(k-O),Q=F*(x.x-d.x),V=F*(x.y-d.y);return w={x:d.x+Q,y:d.y+V},w};return{isStart:i,start:h,getFeatures:g,clear:_,revoke:j,redo:b,setColor:f}}return{drawFreehand:lt}});
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// 导出函数的声明
|
|
2
|
+
declare module '@turf/turf'
|
|
3
|
+
|
|
4
|
+
export default function (map: any): {
|
|
5
|
+
isStart: Boolean
|
|
6
|
+
start: (color: string, MGValue: number) => void
|
|
7
|
+
setColor: (color: string, MGValue: number) => void
|
|
8
|
+
getFeatures: () => void
|
|
9
|
+
clear: () => void
|
|
10
|
+
revoke: () => void
|
|
11
|
+
redo: () => void
|
|
12
|
+
}
|
|
13
|
+
export function draw(map: any): {
|
|
14
|
+
isStart: Boolean
|
|
15
|
+
start: (color: string, MGValue: number) => void
|
|
16
|
+
setColor: (color: string, MGValue: number) => void
|
|
17
|
+
getFeatures: () => void
|
|
18
|
+
clear: () => void
|
|
19
|
+
revoke: () => void
|
|
20
|
+
redo: () => void
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gs-maplibre-draw",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"index.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/index.umd.cjs",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.umd.cjs"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite",
|
|
20
|
+
"build": "tsc && vite build",
|
|
21
|
+
"push": "npm version --no-git-tag-version patch && npm publish"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
25
|
+
"typescript": "^5.3.3",
|
|
26
|
+
"vite": "^5.0.10"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@turf/turf": "^6.5.0",
|
|
30
|
+
"@types/geojson": "^7946.0.14",
|
|
31
|
+
"maplibre-gl": "^4.1.1",
|
|
32
|
+
"view-ui-plus": "^1.3.16",
|
|
33
|
+
"vue": "^3.4.21"
|
|
34
|
+
}
|
|
35
|
+
}
|