vislite 0.8.0 → 0.8.1-alpha.0

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