vislite 0.5.2-alpha.0 → 0.5.2-alpha.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.
Files changed (70) hide show
  1. package/CHANGELOG +7 -1
  2. package/lib/Buffer/index.umd.js +55 -0
  3. package/lib/Buffer/index.umd.min.js +11 -0
  4. package/lib/Canvas/index.umd.js +721 -0
  5. package/lib/Canvas/index.umd.min.js +11 -0
  6. package/lib/Cardinal/index.umd.js +112 -0
  7. package/lib/Cardinal/index.umd.min.js +11 -0
  8. package/lib/Eoap/index.umd.js +53 -0
  9. package/lib/Eoap/index.umd.min.js +11 -0
  10. package/lib/Geometry/index.umd.js +205 -0
  11. package/lib/Geometry/index.umd.min.js +11 -0
  12. package/lib/Hermite/index.umd.js +55 -0
  13. package/lib/Hermite/index.umd.min.js +11 -0
  14. package/lib/Matrix4/index.umd.js +146 -0
  15. package/lib/Matrix4/index.umd.min.js +11 -0
  16. package/lib/Mercator/index.umd.js +39 -0
  17. package/lib/Mercator/index.umd.min.js +11 -0
  18. package/lib/OralCanvas/index.es.js +657 -0
  19. package/lib/OralCanvas/index.es.min.js +11 -0
  20. package/lib/OralWebGL/index.es.js +611 -0
  21. package/lib/OralWebGL/index.es.min.js +11 -0
  22. package/lib/SVG/index.umd.js +540 -0
  23. package/lib/SVG/index.umd.min.js +11 -0
  24. package/lib/Shader/index.umd.js +134 -0
  25. package/lib/Shader/index.umd.min.js +11 -0
  26. package/lib/Texture/index.umd.js +72 -0
  27. package/lib/Texture/index.umd.min.js +11 -0
  28. package/lib/TreeLayout/index.umd.js +430 -0
  29. package/lib/TreeLayout/index.umd.min.js +11 -0
  30. package/lib/WebGL/index.umd.js +684 -0
  31. package/lib/WebGL/index.umd.min.js +11 -0
  32. package/lib/animation/index.umd.js +91 -0
  33. package/lib/animation/index.umd.min.js +11 -0
  34. package/lib/formatColor/index.umd.js +59 -0
  35. package/lib/formatColor/index.umd.min.js +11 -0
  36. package/lib/getLoopColors/index.umd.js +55 -0
  37. package/lib/getLoopColors/index.umd.min.js +11 -0
  38. package/lib/getWebGLContext/index.umd.js +65 -0
  39. package/lib/getWebGLContext/index.umd.min.js +11 -0
  40. package/lib/index.umd.js +2916 -0
  41. package/lib/index.umd.min.js +11 -0
  42. package/lib/move/index.umd.js +27 -0
  43. package/lib/move/index.umd.min.js +11 -0
  44. package/lib/resizeObserver/index.umd.js +48 -0
  45. package/lib/resizeObserver/index.umd.min.js +11 -0
  46. package/lib/rotate/index.umd.js +27 -0
  47. package/lib/rotate/index.umd.min.js +11 -0
  48. package/lib/ruler/index.umd.js +145 -0
  49. package/lib/ruler/index.umd.min.js +11 -0
  50. package/lib/scale/index.umd.js +26 -0
  51. package/lib/scale/index.umd.min.js +11 -0
  52. package/lib/throttle/index.umd.js +70 -0
  53. package/lib/throttle/index.umd.min.js +11 -0
  54. package/lib/viewHandler/index.umd.js +139 -0
  55. package/lib/viewHandler/index.umd.min.js +11 -0
  56. package/package/index.ts +4 -0
  57. package/package/move/index.ts +3 -0
  58. package/package/scale/index.ts +3 -0
  59. package/package.json +1 -1
  60. package/src/common/svg/config.ts +157 -145
  61. package/src/common/svg/gradient.ts +63 -0
  62. package/src/common/svg/index.ts +12 -0
  63. package/src/move.ts +8 -0
  64. package/src/scale.ts +7 -0
  65. package/types/Canvas.d.ts +2 -2
  66. package/types/Gradient.d.ts +2 -2
  67. package/types/SVG.d.ts +23 -0
  68. package/types/index.d.ts +6 -0
  69. package/types/move.d.ts +3 -0
  70. package/types/scale.d.ts +3 -0
@@ -0,0 +1,540 @@
1
+ /*!
2
+ * VISLite JavaScript Library v0.5.2-alpha.2
3
+ * git+https://github.com/oi-contrib/VISLite.git
4
+ *
5
+ * Copyright zxl20070701
6
+ * Released under the MIT license
7
+ * https://zxl20070701.github.io/notebook/home.html
8
+ *
9
+ * Publish Date: Mon Oct 23 2023 22:21:10 GMT+0800 (中国标准时间)
10
+ */
11
+ (function (global, factory) {
12
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
13
+ typeof define === 'function' && define.amd ? define(factory) :
14
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_SVG = factory());
15
+ })(this, (function () { 'use strict';
16
+
17
+ /******************************************************************************
18
+ Copyright (c) Microsoft Corporation.
19
+
20
+ Permission to use, copy, modify, and/or distribute this software for any
21
+ purpose with or without fee is hereby granted.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
24
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
25
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
26
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
27
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
28
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
29
+ PERFORMANCE OF THIS SOFTWARE.
30
+ ***************************************************************************** */
31
+ /* global Reflect, Promise, SuppressedError, Symbol */
32
+
33
+ var extendStatics = function(d, b) {
34
+ extendStatics = Object.setPrototypeOf ||
35
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
37
+ return extendStatics(d, b);
38
+ };
39
+
40
+ function __extends(d, b) {
41
+ if (typeof b !== "function" && b !== null)
42
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
43
+ extendStatics(d, b);
44
+ function __() { this.constructor = d; }
45
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
46
+ }
47
+
48
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
49
+ var e = new Error(message);
50
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
+ };
52
+
53
+ var XLINK_ATTRIBUTE = ["href", "title", "show", "type", "role", "actuate"];
54
+
55
+ function toNode(tagname) {
56
+ return document.createElementNS('http://www.w3.org/2000/svg', tagname);
57
+ }
58
+ var _setAttribute = function (el, key, value) {
59
+ if (XLINK_ATTRIBUTE.indexOf(key) > -1) {
60
+ el.setAttributeNS("http://www.w3.org/1999/xlink", 'xlink:' + key, value + "");
61
+ }
62
+ else {
63
+ el.setAttribute(key, value + "");
64
+ }
65
+ };
66
+ var setAttribute = _setAttribute;
67
+ function getAttribute(el, key) {
68
+ if (XLINK_ATTRIBUTE.indexOf(key) > -1)
69
+ key = 'xlink:' + key;
70
+ return el.getAttribute(key);
71
+ }
72
+ function full(el, config) {
73
+ _setAttribute(el, "stroke", config.strokeStyle);
74
+ _setAttribute(el, "fill", config.fillStyle);
75
+ _setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
76
+ }
77
+ function fill(el, config) {
78
+ _setAttribute(el, "fill", config.fillStyle);
79
+ }
80
+ function stroke(el, config) {
81
+ _setAttribute(el, "stroke", config.strokeStyle);
82
+ _setAttribute(el, "fill", "none");
83
+ _setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
84
+ }
85
+
86
+ function setStyle (el, styles) {
87
+ for (var key in styles) {
88
+ el.style[key] = styles[key];
89
+ }
90
+ }
91
+
92
+ var rotate$1 = function (cx, cy, deg, x, y) {
93
+ var cos = Math.cos(deg), sin = Math.sin(deg);
94
+ return [
95
+ +((x - cx) * cos - (y - cy) * sin + cx).toFixed(7),
96
+ +((x - cx) * sin + (y - cy) * cos + cy).toFixed(7)
97
+ ];
98
+ };
99
+ function arc (beginA, rotateA, cx, cy, r1, r2, doback) {
100
+ if (rotateA < 0) {
101
+ beginA += rotateA;
102
+ rotateA *= -1;
103
+ }
104
+ var temp = [], p;
105
+ p = rotate$1(0, 0, beginA, r1, 0);
106
+ temp[0] = p[0];
107
+ temp[1] = p[1];
108
+ p = rotate$1(0, 0, rotateA, p[0], p[1]);
109
+ temp[2] = p[0];
110
+ temp[3] = p[1];
111
+ p = rotate$1(0, 0, beginA, r2, 0);
112
+ temp[4] = p[0];
113
+ temp[5] = p[1];
114
+ p = rotate$1(0, 0, rotateA, p[0], p[1]);
115
+ temp[6] = p[0];
116
+ temp[7] = p[1];
117
+ doback(beginA, beginA + rotateA, temp[0] + cx, temp[1] + cy, temp[4] + cx, temp[5] + cy, temp[2] + cx, temp[3] + cy, temp[6] + cx, temp[7] + cy, (r2 - r1) * 0.5);
118
+ }
119
+
120
+ var initDefs = function (el) {
121
+ var defs = el.getElementsByTagName('defs');
122
+ if (defs.length <= 0) {
123
+ var newDefs = toNode("defs");
124
+ el.appendChild(newDefs);
125
+ return newDefs;
126
+ }
127
+ else {
128
+ return defs[0];
129
+ }
130
+ };
131
+ var initText = function (el, config, x, y, deg) {
132
+ if (el.nodeName.toLowerCase() !== "text")
133
+ throw new Error("Need a <text> !");
134
+ setAttribute(el, "dy", {
135
+ top: config["fontSize"] * 0.5,
136
+ middle: 0,
137
+ bottom: -config["fontSize"] * 0.5,
138
+ }[config.textBaseline]);
139
+ setStyle(el, {
140
+ "text-anchor": {
141
+ left: "start",
142
+ right: "end",
143
+ center: "middle",
144
+ }[config.textAlign],
145
+ "dominant-baseline": "central",
146
+ "font-size": config["fontSize"] + "px",
147
+ "font-family": config["fontFamily"],
148
+ });
149
+ setAttribute(el, "x", x);
150
+ setAttribute(el, "y", y);
151
+ if (typeof deg == "number") {
152
+ deg = deg % 360;
153
+ setAttribute(el, "transform", "rotate(" + deg + "," + x + "," + y + ")");
154
+ }
155
+ };
156
+ var initCircle = function (el, cx, cy, r) {
157
+ if (el.nodeName.toLowerCase() !== "circle")
158
+ throw new Error("Need a <circle> !");
159
+ setAttribute(el, "cx", cx);
160
+ setAttribute(el, "cy", cy);
161
+ setAttribute(el, "r", r);
162
+ };
163
+ var initPath = function (el, path) {
164
+ if (el.nodeName.toLowerCase() !== "path")
165
+ throw new Error("Need a <path> !");
166
+ setAttribute(el, "d", path);
167
+ };
168
+ var initRect = function (el, x, y, width, height) {
169
+ if (el.nodeName.toLowerCase() !== "rect")
170
+ throw new Error("Need a <rect> !");
171
+ if (height < 0) {
172
+ height *= -1;
173
+ y -= height;
174
+ }
175
+ if (width < 0) {
176
+ width *= -1;
177
+ x -= width;
178
+ }
179
+ setAttribute(el, "x", x);
180
+ setAttribute(el, "y", y);
181
+ setAttribute(el, "width", width);
182
+ setAttribute(el, "height", height);
183
+ };
184
+ var initArc = function (el, config, cx, cy, r1, r2, beginDeg, deg) {
185
+ if (el.nodeName.toLowerCase() !== "path")
186
+ throw new Error("Need a <path> !");
187
+ beginDeg = (beginDeg / 180) * Math.PI;
188
+ deg = (deg / 180) * Math.PI;
189
+ beginDeg = beginDeg % (Math.PI * 2);
190
+ if (r1 > r2) {
191
+ var temp = r1;
192
+ r1 = r2;
193
+ r2 = temp;
194
+ }
195
+ if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
196
+ deg = Math.PI * 1.999999;
197
+ }
198
+ else {
199
+ deg = deg % (Math.PI * 2);
200
+ }
201
+ arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
202
+ var f = endA - beginA > Math.PI ? 1 : 0, d = "M" + begInnerX + " " + begInnerY;
203
+ if (r < 0)
204
+ r = -r;
205
+ d +=
206
+ "A" + r1 + " " + r1 + " 0 " + f + " 1 " + endInnerX + " " + endInnerY;
207
+ if (config.arcEndCap == "round")
208
+ d += "A" + r + " " + r + " " + " 0 1 0 " + endOuterX + " " + endOuterY;
209
+ else if (config.arcEndCap == "-round")
210
+ d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
211
+ else
212
+ d += "L" + endOuterX + " " + endOuterY;
213
+ d +=
214
+ "A" + r2 + " " + r2 + " 0 " + f + " 0 " + begOuterX + " " + begOuterY;
215
+ if (config.arcStartCap == "round")
216
+ d += "A" + r + " " + r + " " + " 0 1 0 " + begInnerX + " " + begInnerY;
217
+ else if (config.arcStartCap == "-round")
218
+ d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
219
+ else
220
+ d += "L" + begInnerX + " " + begInnerY;
221
+ if (config.arcStartCap == "butt")
222
+ d += "Z";
223
+ setAttribute(el, "d", d);
224
+ });
225
+ };
226
+
227
+ function rotate (cx, cy, deg, x, y) {
228
+ var cos = Math.cos(deg), sin = Math.sin(deg);
229
+ return [
230
+ (x - cx) * cos - (y - cy) * sin + cx,
231
+ (x - cx) * sin + (y - cy) * cos + cy
232
+ ];
233
+ }
234
+
235
+ var linearGradient = function (el, x0, y0, x1, y1) {
236
+ var defs = initDefs(el);
237
+ var gradientId = "vislite-lg-" + new Date().valueOf() + "-" + Math.random();
238
+ var linearGradient = toNode("linearGradient");
239
+ defs.appendChild(linearGradient);
240
+ setAttribute(linearGradient, "id", gradientId);
241
+ setAttribute(linearGradient, "x1", x0 + "%");
242
+ setAttribute(linearGradient, "y1", y0 + "%");
243
+ setAttribute(linearGradient, "x2", x1 + "%");
244
+ setAttribute(linearGradient, "y2", y1 + "%");
245
+ var enhanceGradient = {
246
+ "value": function () {
247
+ return "url(#" + gradientId + ")";
248
+ },
249
+ "setColor": function (stop, color) {
250
+ var stopEl = toNode("stop");
251
+ linearGradient.appendChild(stopEl);
252
+ setAttribute(stopEl, "offset", (stop * 100) + "%");
253
+ setAttribute(stopEl, "style", "stop-color:" + color + ";");
254
+ return enhanceGradient;
255
+ }
256
+ };
257
+ return enhanceGradient;
258
+ };
259
+ var radialGradient = function (el, cx, cy, r) {
260
+ var defs = initDefs(el);
261
+ var gradientId = "vislite-rg-" + new Date().valueOf() + "-" + Math.random();
262
+ var radialGradient = toNode("radialGradient");
263
+ defs.appendChild(radialGradient);
264
+ setAttribute(radialGradient, "id", gradientId);
265
+ setAttribute(radialGradient, "cx", cx + "%");
266
+ setAttribute(radialGradient, "cy", cy + "%");
267
+ setAttribute(radialGradient, "r", r + "%");
268
+ var enhanceGradient = {
269
+ "value": function () {
270
+ return "url(#" + gradientId + ")";
271
+ },
272
+ "setColor": function (stop, color) {
273
+ var stopEl = toNode("stop");
274
+ radialGradient.appendChild(stopEl);
275
+ setAttribute(stopEl, "offset", (stop * 100) + "%");
276
+ setAttribute(stopEl, "style", "stop-color:" + color + ";");
277
+ return enhanceGradient;
278
+ }
279
+ };
280
+ return enhanceGradient;
281
+ };
282
+
283
+ var oldAttrName = {
284
+ "font-size": "fontSize",
285
+ "font-family": "fontFamily",
286
+ "arc-start-cap": "arcStartCap",
287
+ "arc-end-cap": "arcEndCap",
288
+ };
289
+ var SVG$1 = (function () {
290
+ function SVG(svg) {
291
+ this.name = "SVG";
292
+ this.__config = {
293
+ fillStyle: "#000",
294
+ strokeStyle: "#000",
295
+ lineWidth: 1,
296
+ textAlign: "left",
297
+ textBaseline: "middle",
298
+ "fontSize": 16,
299
+ "fontFamily": "sans-serif",
300
+ "arcStartCap": "butt",
301
+ "arcEndCap": "butt",
302
+ lineDash: [],
303
+ };
304
+ this.__path = "";
305
+ this.__currentPosition = [];
306
+ this.__svg = svg;
307
+ }
308
+ SVG.prototype.config = function (params) {
309
+ if (typeof params !== "object") {
310
+ return this.__config[oldAttrName[params] || params];
311
+ }
312
+ else {
313
+ for (var key in params) {
314
+ var _key = oldAttrName[key] || key;
315
+ this.__config[_key] = params[key];
316
+ }
317
+ }
318
+ return this;
319
+ };
320
+ SVG.prototype.useEl = function (el) {
321
+ this.__useEl = el;
322
+ return this;
323
+ };
324
+ SVG.prototype.getEl = function () {
325
+ return this.__useEl;
326
+ };
327
+ SVG.prototype.appendEl = function (el, context) {
328
+ context = context || this.__svg;
329
+ if (typeof el == "string")
330
+ el = toNode(el);
331
+ context.appendChild(el);
332
+ this.__useEl = el;
333
+ return this;
334
+ };
335
+ SVG.prototype.appendBoard = function (el, context) {
336
+ var _el = el;
337
+ if (typeof el == "string")
338
+ _el =
339
+ {
340
+ text: "text",
341
+ path: "path",
342
+ arc: "path",
343
+ circle: "circle",
344
+ rect: "rect",
345
+ }[el] || "";
346
+ if (_el == "")
347
+ throw new Error("Unsupported drawing method:" + el);
348
+ return this.appendEl(_el, context);
349
+ };
350
+ SVG.prototype.remove = function () {
351
+ if (!this.__useEl) {
352
+ throw new Error("Currently, no node can be deleted.");
353
+ }
354
+ else {
355
+ this.__useEl.parentNode.removeChild(this.__useEl);
356
+ }
357
+ return this;
358
+ };
359
+ SVG.prototype.attr = function (params) {
360
+ if (!this.__useEl)
361
+ throw new Error("Currently, no node can be modified or viewed.");
362
+ if (typeof params !== "object") {
363
+ return getAttribute(this.__useEl, params);
364
+ }
365
+ else {
366
+ for (var key in params) {
367
+ setAttribute(this.__useEl, key, params[key]);
368
+ }
369
+ return this;
370
+ }
371
+ };
372
+ SVG.prototype.fillText = function (text, x, y, deg) {
373
+ if (deg === void 0) { deg = 0; }
374
+ initText(this.__useEl, this.__config, x, y, deg);
375
+ this.__useEl.textContent = text;
376
+ fill(this.__useEl, this.__config);
377
+ return this;
378
+ };
379
+ SVG.prototype.strokeText = function (text, x, y, deg) {
380
+ if (deg === void 0) { deg = 0; }
381
+ initText(this.__useEl, this.__config, x, y, deg);
382
+ this.__useEl.textContent = text;
383
+ stroke(this.__useEl, this.__config);
384
+ return this;
385
+ };
386
+ SVG.prototype.fullText = function (text, x, y, deg) {
387
+ if (deg === void 0) { deg = 0; }
388
+ initText(this.__useEl, this.__config, x, y, deg);
389
+ this.__useEl.textContent = text;
390
+ full(this.__useEl, this.__config);
391
+ return this;
392
+ };
393
+ SVG.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
394
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
395
+ fill(this.__useEl, this.__config);
396
+ return this;
397
+ };
398
+ SVG.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
399
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
400
+ stroke(this.__useEl, this.__config);
401
+ return this;
402
+ };
403
+ SVG.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
404
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
405
+ full(this.__useEl, this.__config);
406
+ return this;
407
+ };
408
+ SVG.prototype.fillCircle = function (cx, cy, r) {
409
+ initCircle(this.__useEl, cx, cy, r);
410
+ fill(this.__useEl, this.__config);
411
+ return this;
412
+ };
413
+ SVG.prototype.strokeCircle = function (cx, cy, r) {
414
+ initCircle(this.__useEl, cx, cy, r);
415
+ stroke(this.__useEl, this.__config);
416
+ return this;
417
+ };
418
+ SVG.prototype.fullCircle = function (cx, cy, r) {
419
+ initCircle(this.__useEl, cx, cy, r);
420
+ full(this.__useEl, this.__config);
421
+ return this;
422
+ };
423
+ SVG.prototype.fillRect = function (x, y, width, height) {
424
+ initRect(this.__useEl, x, y, width, height);
425
+ fill(this.__useEl, this.__config);
426
+ return this;
427
+ };
428
+ SVG.prototype.strokeRect = function (x, y, width, height) {
429
+ initRect(this.__useEl, x, y, width, height);
430
+ stroke(this.__useEl, this.__config);
431
+ return this;
432
+ };
433
+ SVG.prototype.fullRect = function (x, y, width, height) {
434
+ initRect(this.__useEl, x, y, width, height);
435
+ full(this.__useEl, this.__config);
436
+ return this;
437
+ };
438
+ SVG.prototype.beginPath = function () {
439
+ this.__currentPosition = [];
440
+ this.__path = "";
441
+ return this;
442
+ };
443
+ SVG.prototype.closePath = function () {
444
+ this.__path += "Z";
445
+ return this;
446
+ };
447
+ SVG.prototype.moveTo = function (x, y) {
448
+ this.__currentPosition = [x, y];
449
+ this.__path += "M" + x + " " + y;
450
+ return this;
451
+ };
452
+ SVG.prototype.lineTo = function (x, y) {
453
+ this.__currentPosition = [x, y];
454
+ this.__path += (this.__path == "" ? "M" : "L") + x + " " + y;
455
+ return this;
456
+ };
457
+ SVG.prototype.fill = function () {
458
+ initPath(this.__useEl, this.__path);
459
+ fill(this.__useEl, this.__config);
460
+ return this;
461
+ };
462
+ SVG.prototype.stroke = function () {
463
+ initPath(this.__useEl, this.__path);
464
+ stroke(this.__useEl, this.__config);
465
+ return this;
466
+ };
467
+ SVG.prototype.full = function () {
468
+ initPath(this.__useEl, this.__path);
469
+ full(this.__useEl, this.__config);
470
+ return this;
471
+ };
472
+ SVG.prototype.arc = function (x, y, r, beginDeg, deg) {
473
+ var begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y);
474
+ var endPosition = rotate(x, y, ((beginDeg + deg) / 180) * Math.PI, x + r, y);
475
+ if (this.__path == "") {
476
+ this.__path += "M" + begPosition[0] + "," + begPosition[1];
477
+ }
478
+ else if (begPosition[0] != this.__currentPosition[0] ||
479
+ begPosition[1] != this.__currentPosition[1]) {
480
+ this.__path += "L" + begPosition[0] + "," + begPosition[1];
481
+ }
482
+ this.__path +=
483
+ "A" +
484
+ r +
485
+ "," +
486
+ r +
487
+ " 0 " +
488
+ (deg > 180 || deg < -180 ? 1 : 0) +
489
+ "," +
490
+ (deg > 0 ? 1 : 0) +
491
+ " " +
492
+ endPosition[0] +
493
+ "," +
494
+ endPosition[1];
495
+ return this;
496
+ };
497
+ SVG.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
498
+ this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y;
499
+ return this;
500
+ };
501
+ SVG.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
502
+ this.__path +=
503
+ "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y;
504
+ return this;
505
+ };
506
+ SVG.prototype.bind = function (eventType, callback) {
507
+ this.__useEl.addEventListener(eventType, function (event) {
508
+ callback.call(this, event, this);
509
+ }, false);
510
+ return this;
511
+ };
512
+ SVG.prototype.createLinearGradient = function (x0, y0, x1, y1) {
513
+ return linearGradient(this.__svg, x0, y0, x1, y1);
514
+ };
515
+ SVG.prototype.createRadialGradient = function (cx, cy, r) {
516
+ return radialGradient(this.__svg, cx, cy, r);
517
+ };
518
+ return SVG;
519
+ }());
520
+
521
+ var SVG = (function (_super) {
522
+ __extends(SVG, _super);
523
+ function SVG(el) {
524
+ if (!el) {
525
+ throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");
526
+ }
527
+ var width = el.clientWidth, height = el.clientHeight;
528
+ var ViewSVG = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
529
+ el.appendChild(ViewSVG);
530
+ ViewSVG.setAttribute("width", width + "");
531
+ ViewSVG.setAttribute("height", height + "");
532
+ ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height);
533
+ return _super.call(this, ViewSVG) || this;
534
+ }
535
+ return SVG;
536
+ }(SVG$1));
537
+
538
+ return SVG;
539
+
540
+ }));
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * VISLite JavaScript Library v0.5.2-alpha.2
3
+ * git+https://github.com/oi-contrib/VISLite.git
4
+ *
5
+ * Copyright zxl20070701
6
+ * Released under the MIT license
7
+ * https://zxl20070701.github.io/notebook/home.html
8
+ *
9
+ * Publish Date: Mon Oct 23 2023 22:21:10 GMT+0800 (中国标准时间)
10
+ */
11
+ var t,e;t=this,e=function(){"use strict";var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};"function"==typeof SuppressedError&&SuppressedError;var e=["href","title","show","type","role","actuate"];function i(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}var n=function(t,i,n){e.indexOf(i)>-1?t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:"+i,n+""):t.setAttribute(i,n+"")},r=n;function o(t,e){n(t,"stroke",e.strokeStyle),n(t,"fill",e.fillStyle),n(t,"stroke-dasharray",e.lineDash.join(","))}function s(t,e){n(t,"fill",e.fillStyle)}function u(t,e){n(t,"stroke",e.strokeStyle),n(t,"fill","none"),n(t,"stroke-dasharray",e.lineDash.join(","))}var h=function(t,e,i,n,r){var o=Math.cos(i),s=Math.sin(i);return[+((n-t)*o-(r-e)*s+t).toFixed(7),+((n-t)*s+(r-e)*o+e).toFixed(7)]},a=function(t){var e=t.getElementsByTagName("defs");if(e.length<=0){var n=i("defs");return t.appendChild(n),n}return e[0]},_=function(t,e,i,n,o){if("text"!==t.nodeName.toLowerCase())throw new Error("Need a <text> !");r(t,"dy",{top:.5*e.fontSize,middle:0,bottom:.5*-e.fontSize}[e.textBaseline]),function(t,e){for(var i in e)t.style[i]=e[i]}(t,{"text-anchor":{left:"start",right:"end",center:"middle"}[e.textAlign],"dominant-baseline":"central","font-size":e.fontSize+"px","font-family":e.fontFamily}),r(t,"x",i),r(t,"y",n),"number"==typeof o&&r(t,"transform","rotate("+(o%=360)+","+i+","+n+")")},l=function(t,e,i,n){if("circle"!==t.nodeName.toLowerCase())throw new Error("Need a <circle> !");r(t,"cx",e),r(t,"cy",i),r(t,"r",n)},c=function(t,e){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");r(t,"d",e)},f=function(t,e,i,n,o){if("rect"!==t.nodeName.toLowerCase())throw new Error("Need a <rect> !");o<0&&(i-=o*=-1),n<0&&(e-=n*=-1),r(t,"x",e),r(t,"y",i),r(t,"width",n),r(t,"height",o)},p=function(t,e,i,n,o,s,u,a){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");if(u=u/180*Math.PI,a=a/180*Math.PI,u%=2*Math.PI,o>s){var _=o;o=s,s=_}a>=1.999999*Math.PI||a<=1.999999*-Math.PI?a=1.999999*Math.PI:a%=2*Math.PI,function(t,e,i,n,r,o,s){e<0&&(t+=e,e*=-1);var u,a=[];u=h(0,0,t,r,0),a[0]=u[0],a[1]=u[1],u=h(0,0,e,u[0],u[1]),a[2]=u[0],a[3]=u[1],u=h(0,0,t,o,0),a[4]=u[0],a[5]=u[1],u=h(0,0,e,u[0],u[1]),a[6]=u[0],a[7]=u[1],s(t,t+e,a[0]+i,a[1]+n,a[4]+i,a[5]+n,a[2]+i,a[3]+n,a[6]+i,a[7]+n,.5*(o-r))}(u,a,i,n,o,s,(function(i,n,u,h,a,_,l,c,f,p,d){var y=n-i>Math.PI?1:0,E="M"+u+" "+h;d<0&&(d=-d),E+="A"+o+" "+o+" 0 "+y+" 1 "+l+" "+c,"round"==e.arcEndCap?E+="A"+d+" "+d+" 0 1 0 "+f+" "+p:"-round"==e.arcEndCap?E+="A"+d+" "+d+" 0 1 1 "+f+" "+p:E+="L"+f+" "+p,E+="A"+s+" "+s+" 0 "+y+" 0 "+a+" "+_,"round"==e.arcStartCap?E+="A"+d+" "+d+" 0 1 0 "+u+" "+h:"-round"==e.arcStartCap?E+="A"+d+" "+d+" 0 1 1 "+u+" "+h:E+="L"+u+" "+h,"butt"==e.arcStartCap&&(E+="Z"),r(t,"d",E)}))};function d(t,e,i,n,r){var o=Math.cos(i),s=Math.sin(i);return[(n-t)*o-(r-e)*s+t,(n-t)*s+(r-e)*o+e]}var y={"font-size":"fontSize","font-family":"fontFamily","arc-start-cap":"arcStartCap","arc-end-cap":"arcEndCap"},E=function(){function t(t){this.name="SVG",this.__config={fillStyle:"#000",strokeStyle:"#000",lineWidth:1,textAlign:"left",textBaseline:"middle",fontSize:16,fontFamily:"sans-serif",arcStartCap:"butt",arcEndCap:"butt",lineDash:[]},this.__path="",this.__currentPosition=[],this.__svg=t}return t.prototype.config=function(t){if("object"!=typeof t)return this.__config[y[t]||t];for(var e in t){var i=y[e]||e;this.__config[i]=t[e]}return this},t.prototype.useEl=function(t){return this.__useEl=t,this},t.prototype.getEl=function(){return this.__useEl},t.prototype.appendEl=function(t,e){return e=e||this.__svg,"string"==typeof t&&(t=i(t)),e.appendChild(t),this.__useEl=t,this},t.prototype.appendBoard=function(t,e){var i=t;if("string"==typeof t&&(i={text:"text",path:"path",arc:"path",circle:"circle",rect:"rect"}[t]||""),""==i)throw new Error("Unsupported drawing method:"+t);return this.appendEl(i,e)},t.prototype.remove=function(){if(!this.__useEl)throw new Error("Currently, no node can be deleted.");return this.__useEl.parentNode.removeChild(this.__useEl),this},t.prototype.attr=function(t){if(!this.__useEl)throw new Error("Currently, no node can be modified or viewed.");if("object"!=typeof t)return function(t,i){return e.indexOf(i)>-1&&(i="xlink:"+i),t.getAttribute(i)}(this.__useEl,t);for(var i in t)r(this.__useEl,i,t[i]);return this},t.prototype.fillText=function(t,e,i,n){return void 0===n&&(n=0),_(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,s(this.__useEl,this.__config),this},t.prototype.strokeText=function(t,e,i,n){return void 0===n&&(n=0),_(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,u(this.__useEl,this.__config),this},t.prototype.fullText=function(t,e,i,n){return void 0===n&&(n=0),_(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,o(this.__useEl,this.__config),this},t.prototype.fillArc=function(t,e,i,n,r,o){return p(this.__useEl,this.__config,t,e,i,n,r,o),s(this.__useEl,this.__config),this},t.prototype.strokeArc=function(t,e,i,n,r,o){return p(this.__useEl,this.__config,t,e,i,n,r,o),u(this.__useEl,this.__config),this},t.prototype.fullArc=function(t,e,i,n,r,s){return p(this.__useEl,this.__config,t,e,i,n,r,s),o(this.__useEl,this.__config),this},t.prototype.fillCircle=function(t,e,i){return l(this.__useEl,t,e,i),s(this.__useEl,this.__config),this},t.prototype.strokeCircle=function(t,e,i){return l(this.__useEl,t,e,i),u(this.__useEl,this.__config),this},t.prototype.fullCircle=function(t,e,i){return l(this.__useEl,t,e,i),o(this.__useEl,this.__config),this},t.prototype.fillRect=function(t,e,i,n){return f(this.__useEl,t,e,i,n),s(this.__useEl,this.__config),this},t.prototype.strokeRect=function(t,e,i,n){return f(this.__useEl,t,e,i,n),u(this.__useEl,this.__config),this},t.prototype.fullRect=function(t,e,i,n){return f(this.__useEl,t,e,i,n),o(this.__useEl,this.__config),this},t.prototype.beginPath=function(){return this.__currentPosition=[],this.__path="",this},t.prototype.closePath=function(){return this.__path+="Z",this},t.prototype.moveTo=function(t,e){return this.__currentPosition=[t,e],this.__path+="M"+t+" "+e,this},t.prototype.lineTo=function(t,e){return this.__currentPosition=[t,e],this.__path+=(""==this.__path?"M":"L")+t+" "+e,this},t.prototype.fill=function(){return c(this.__useEl,this.__path),s(this.__useEl,this.__config),this},t.prototype.stroke=function(){return c(this.__useEl,this.__path),u(this.__useEl,this.__config),this},t.prototype.full=function(){return c(this.__useEl,this.__path),o(this.__useEl,this.__config),this},t.prototype.arc=function(t,e,i,n,r){var o=d(t,e,n/180*Math.PI,t+i,e),s=d(t,e,(n+r)/180*Math.PI,t+i,e);return""==this.__path?this.__path+="M"+o[0]+","+o[1]:o[0]==this.__currentPosition[0]&&o[1]==this.__currentPosition[1]||(this.__path+="L"+o[0]+","+o[1]),this.__path+="A"+i+","+i+" 0 "+(r>180||r<-180?1:0)+","+(r>0?1:0)+" "+s[0]+","+s[1],this},t.prototype.quadraticCurveTo=function(t,e,i,n){return this.__path+="Q"+t+" "+e+","+i+" "+n,this},t.prototype.bezierCurveTo=function(t,e,i,n,r,o){return this.__path+="C"+t+" "+e+","+i+" "+n+","+r+" "+o,this},t.prototype.bind=function(t,e){return this.__useEl.addEventListener(t,(function(t){e.call(this,t,this)}),!1),this},t.prototype.createLinearGradient=function(t,e,n,o){return function(t,e,n,o,s){var u=a(t),h="vislite-lg-"+(new Date).valueOf()+"-"+Math.random(),_=i("linearGradient");u.appendChild(_),r(_,"id",h),r(_,"x1",e+"%"),r(_,"y1",n+"%"),r(_,"x2",o+"%"),r(_,"y2",s+"%");var l={value:function(){return"url(#"+h+")"},setColor:function(t,e){var n=i("stop");return _.appendChild(n),r(n,"offset",100*t+"%"),r(n,"style","stop-color:"+e+";"),l}};return l}(this.__svg,t,e,n,o)},t.prototype.createRadialGradient=function(t,e,n){return function(t,e,n,o){var s=a(t),u="vislite-rg-"+(new Date).valueOf()+"-"+Math.random(),h=i("radialGradient");s.appendChild(h),r(h,"id",u),r(h,"cx",e+"%"),r(h,"cy",n+"%"),r(h,"r",o+"%");var _={value:function(){return"url(#"+u+")"},setColor:function(t,e){var n=i("stop");return h.appendChild(n),r(n,"offset",100*t+"%"),r(n,"style","stop-color:"+e+";"),_}};return _}(this.__svg,t,e,n)},t}();return function(e){function i(t){if(!t)throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");var i=t.clientWidth,n=t.clientHeight,r=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.appendChild(r),r.setAttribute("width",i+""),r.setAttribute("height",n+""),r.setAttribute("viewBox","0 0 "+i+" "+n),e.call(this,r)||this}return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}(i,e),i}(E)},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_SVG=e();