vislite 1.4.0 → 1.5.0-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 (85) hide show
  1. package/CHANGELOG +313 -307
  2. package/lib/BarLayout/index.es.js +347 -347
  3. package/lib/BarLayout/index.es.min.js +1 -1
  4. package/lib/Buffer/index.es.js +35 -35
  5. package/lib/Buffer/index.es.min.js +1 -1
  6. package/lib/Canvas/index.es.js +775 -774
  7. package/lib/Canvas/index.es.min.js +2 -2
  8. package/lib/Cardinal/index.es.js +90 -90
  9. package/lib/Cardinal/index.es.min.js +1 -1
  10. package/lib/Eoap/index.es.js +33 -33
  11. package/lib/Eoap/index.es.min.js +1 -1
  12. package/lib/Hermite/index.es.js +35 -35
  13. package/lib/Hermite/index.es.min.js +1 -1
  14. package/lib/MapCoordinate/index.es.js +199 -199
  15. package/lib/MapCoordinate/index.es.min.js +1 -1
  16. package/lib/Matrix4/index.es.js +124 -124
  17. package/lib/Matrix4/index.es.min.js +1 -1
  18. package/lib/Mercator/index.es.js +19 -19
  19. package/lib/Mercator/index.es.min.js +1 -1
  20. package/lib/PieLayout/index.es.js +114 -114
  21. package/lib/PieLayout/index.es.min.js +1 -1
  22. package/lib/RawCanvas/index.es.js +704 -704
  23. package/lib/RawCanvas/index.es.min.js +1 -1
  24. package/lib/SVG/index.es.js +514 -514
  25. package/lib/SVG/index.es.min.js +1 -1
  26. package/lib/Shader/index.es.js +35 -35
  27. package/lib/Shader/index.es.min.js +1 -1
  28. package/lib/Texture/index.es.js +53 -53
  29. package/lib/Texture/index.es.min.js +1 -1
  30. package/lib/TreeLayout/index.es.js +301 -301
  31. package/lib/TreeLayout/index.es.min.js +1 -1
  32. package/lib/animation/index.es.js +3 -3
  33. package/lib/animation/index.es.min.js +1 -1
  34. package/lib/assemble/index.es.js +17 -17
  35. package/lib/assemble/index.es.min.js +1 -1
  36. package/lib/getLoopColors/index.es.js +35 -35
  37. package/lib/getLoopColors/index.es.min.js +1 -1
  38. package/lib/getWebGLContext/index.es.js +62 -62
  39. package/lib/getWebGLContext/index.es.min.js +1 -1
  40. package/lib/index.umd.js +2657 -2656
  41. package/lib/index.umd.min.js +4 -4
  42. package/lib/initOption/index.es.js +6 -6
  43. package/lib/initOption/index.es.min.js +1 -1
  44. package/lib/mergeOption/index.es.js +34 -34
  45. package/lib/mergeOption/index.es.min.js +1 -1
  46. package/lib/move/index.es.js +7 -7
  47. package/lib/move/index.es.min.js +1 -1
  48. package/lib/rotate/index.es.js +7 -7
  49. package/lib/rotate/index.es.min.js +1 -1
  50. package/lib/ruler/index.es.js +137 -137
  51. package/lib/ruler/index.es.min.js +1 -1
  52. package/lib/scale/index.es.js +6 -6
  53. package/lib/scale/index.es.min.js +1 -1
  54. package/lib/throttle/index.es.js +1 -1
  55. package/lib/throttle/index.es.min.js +1 -1
  56. package/package/BarLayout/index.ts +2 -2
  57. package/package/PieLayout/index.ts +2 -2
  58. package/package/animation/index.ts +5 -5
  59. package/package/index.ts +84 -84
  60. package/package/throttle/index.ts +2 -2
  61. package/package.json +75 -75
  62. package/src/Canvas.ts +9 -4
  63. package/src/SVG.ts +55 -55
  64. package/src/common/canvas/gradient.ts +31 -31
  65. package/src/common/svg/default.ts +29 -29
  66. package/src/common/svg/gradient.ts +53 -53
  67. package/src/common/svg/index.ts +332 -332
  68. package/src/common/tree/toPlainTree.ts +135 -135
  69. package/src/common/webgl/texture.ts +98 -98
  70. package/src/layout/BarLayout.ts +248 -248
  71. package/src/layout/PieLayout.ts +141 -141
  72. package/src/layout/TreeLayout.ts +197 -197
  73. package/types/Bar.d.ts +91 -91
  74. package/types/BarConfig.d.ts +4 -4
  75. package/types/BarLayout.d.ts +48 -48
  76. package/types/BarOption.d.ts +31 -31
  77. package/types/CanvasOption.d.ts +5 -0
  78. package/types/Pie.d.ts +73 -73
  79. package/types/PieConfig.d.ts +26 -26
  80. package/types/PieLayout.d.ts +40 -40
  81. package/types/PieOption.d.ts +21 -21
  82. package/types/SVG.d.ts +247 -247
  83. package/types/animation.d.ts +11 -11
  84. package/types/index.d.ts +195 -195
  85. package/types/throttle.d.ts +5 -5
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SVG of VISLite JavaScript Library v1.4.0
2
+ * SVG of VISLite JavaScript Library v1.5.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  /******************************************************************************
@@ -40,535 +40,535 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
40
40
 
41
41
  var XLINK_ATTRIBUTE = ["href", "title", "show", "type", "role", "actuate"];
42
42
 
43
- var setLineAttr = function (el, config) {
44
- setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
45
- setAttribute(el, "stroke-width", config.lineWidth + "");
46
- setAttribute(el, "stroke-linecap", config.lineCap + "");
47
- setAttribute(el, "stroke-linejoin", config.lineJoin + "");
48
- };
49
- function toNode(tagname) {
50
- return document.createElementNS('http://www.w3.org/2000/svg', tagname);
51
- }
52
- var _setAttribute = function (el, key, value) {
53
- if (XLINK_ATTRIBUTE.indexOf(key) > -1) {
54
- el.setAttributeNS("http://www.w3.org/1999/xlink", 'xlink:' + key, value + "");
55
- }
56
- else {
57
- el.setAttribute(key, value + "");
58
- }
59
- };
60
- var setAttribute = _setAttribute;
61
- function getAttribute(el, key) {
62
- if (XLINK_ATTRIBUTE.indexOf(key) > -1)
63
- key = 'xlink:' + key;
64
- return el.getAttribute(key);
65
- }
66
- function full(el, config) {
67
- setLineAttr(el, config);
68
- _setAttribute(el, "stroke", config.strokeStyle);
69
- _setAttribute(el, "fill", config.fillStyle);
70
- }
71
- function fill(el, config) {
72
- _setAttribute(el, "fill", config.fillStyle);
73
- }
74
- function stroke(el, config) {
75
- setLineAttr(el, config);
76
- _setAttribute(el, "stroke", config.strokeStyle);
77
- _setAttribute(el, "fill", "none");
43
+ var setLineAttr = function (el, config) {
44
+ setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
45
+ setAttribute(el, "stroke-width", config.lineWidth + "");
46
+ setAttribute(el, "stroke-linecap", config.lineCap + "");
47
+ setAttribute(el, "stroke-linejoin", config.lineJoin + "");
48
+ };
49
+ function toNode(tagname) {
50
+ return document.createElementNS('http://www.w3.org/2000/svg', tagname);
51
+ }
52
+ var _setAttribute = function (el, key, value) {
53
+ if (XLINK_ATTRIBUTE.indexOf(key) > -1) {
54
+ el.setAttributeNS("http://www.w3.org/1999/xlink", 'xlink:' + key, value + "");
55
+ }
56
+ else {
57
+ el.setAttribute(key, value + "");
58
+ }
59
+ };
60
+ var setAttribute = _setAttribute;
61
+ function getAttribute(el, key) {
62
+ if (XLINK_ATTRIBUTE.indexOf(key) > -1)
63
+ key = 'xlink:' + key;
64
+ return el.getAttribute(key);
65
+ }
66
+ function full(el, config) {
67
+ setLineAttr(el, config);
68
+ _setAttribute(el, "stroke", config.strokeStyle);
69
+ _setAttribute(el, "fill", config.fillStyle);
70
+ }
71
+ function fill(el, config) {
72
+ _setAttribute(el, "fill", config.fillStyle);
73
+ }
74
+ function stroke(el, config) {
75
+ setLineAttr(el, config);
76
+ _setAttribute(el, "stroke", config.strokeStyle);
77
+ _setAttribute(el, "fill", "none");
78
78
  }
79
79
 
80
- function setStyle (el, styles) {
81
- for (var key in styles) {
82
- el.style[key] = styles[key];
83
- }
80
+ function setStyle (el, styles) {
81
+ for (var key in styles) {
82
+ el.style[key] = styles[key];
83
+ }
84
84
  }
85
85
 
86
- var rotate$1 = function (cx, cy, deg, x, y) {
87
- var cos = Math.cos(deg), sin = Math.sin(deg);
88
- return [
89
- +((x - cx) * cos - (y - cy) * sin + cx).toFixed(7),
90
- +((x - cx) * sin + (y - cy) * cos + cy).toFixed(7)
91
- ];
92
- };
93
- function arc (beginA, rotateA, cx, cy, r1, r2, doback) {
94
- if (rotateA < 0) {
95
- beginA += rotateA;
96
- rotateA *= -1;
97
- }
98
- var temp = [];
99
- var p;
100
- p = rotate$1(0, 0, beginA, r1, 0);
101
- temp[0] = p[0];
102
- temp[1] = p[1];
103
- p = rotate$1(0, 0, rotateA, p[0], p[1]);
104
- temp[2] = p[0];
105
- temp[3] = p[1];
106
- p = rotate$1(0, 0, beginA, r2, 0);
107
- temp[4] = p[0];
108
- temp[5] = p[1];
109
- p = rotate$1(0, 0, rotateA, p[0], p[1]);
110
- temp[6] = p[0];
111
- temp[7] = p[1];
112
- 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);
86
+ var rotate$1 = function (cx, cy, deg, x, y) {
87
+ var cos = Math.cos(deg), sin = Math.sin(deg);
88
+ return [
89
+ +((x - cx) * cos - (y - cy) * sin + cx).toFixed(7),
90
+ +((x - cx) * sin + (y - cy) * cos + cy).toFixed(7)
91
+ ];
92
+ };
93
+ function arc (beginA, rotateA, cx, cy, r1, r2, doback) {
94
+ if (rotateA < 0) {
95
+ beginA += rotateA;
96
+ rotateA *= -1;
97
+ }
98
+ var temp = [];
99
+ var p;
100
+ p = rotate$1(0, 0, beginA, r1, 0);
101
+ temp[0] = p[0];
102
+ temp[1] = p[1];
103
+ p = rotate$1(0, 0, rotateA, p[0], p[1]);
104
+ temp[2] = p[0];
105
+ temp[3] = p[1];
106
+ p = rotate$1(0, 0, beginA, r2, 0);
107
+ temp[4] = p[0];
108
+ temp[5] = p[1];
109
+ p = rotate$1(0, 0, rotateA, p[0], p[1]);
110
+ temp[6] = p[0];
111
+ temp[7] = p[1];
112
+ 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);
113
113
  }
114
114
 
115
- var initDefs = function (el) {
116
- var defs = el.getElementsByTagName('defs');
117
- if (defs.length <= 0) {
118
- var newDefs = toNode("defs");
119
- el.appendChild(newDefs);
120
- return newDefs;
121
- }
122
- else {
123
- return defs[0];
124
- }
125
- };
126
- var initText = function (el, config, x, y, deg) {
127
- if (el.nodeName.toLowerCase() !== "text")
128
- throw new Error("Need a <text> !");
129
- setAttribute(el, "dy", {
130
- top: config["fontSize"] * 0.5,
131
- middle: 0,
132
- bottom: -config["fontSize"] * 0.5,
133
- }[config.textBaseline]);
134
- setStyle(el, {
135
- "text-anchor": {
136
- left: "start",
137
- right: "end",
138
- center: "middle",
139
- }[config.textAlign],
140
- "dominant-baseline": "central",
141
- "font-size": config["fontSize"] + "px",
142
- "font-family": config["fontFamily"],
143
- });
144
- setAttribute(el, "x", x);
145
- setAttribute(el, "y", y);
146
- if (typeof deg == "number") {
147
- deg = deg % 360;
148
- setAttribute(el, "transform", "rotate(" + deg + "," + x + "," + y + ")");
149
- }
150
- };
151
- var initCircle = function (el, cx, cy, r) {
152
- if (el.nodeName.toLowerCase() !== "circle")
153
- throw new Error("Need a <circle> !");
154
- setAttribute(el, "cx", cx);
155
- setAttribute(el, "cy", cy);
156
- setAttribute(el, "r", r);
157
- };
158
- var initPath = function (el, path) {
159
- if (el.nodeName.toLowerCase() !== "path")
160
- throw new Error("Need a <path> !");
161
- setAttribute(el, "d", path);
162
- };
163
- var initRect = function (el, config, x, y, width, height) {
164
- if (el.nodeName.toLowerCase() !== "path")
165
- throw new Error("Need a <path> !");
166
- var rectRadius = [];
167
- if (Array.isArray(config.rectRadius) && config.rectRadius.length > 0) {
168
- for (var index = 0; index < 4; index++) {
169
- rectRadius.push.apply(rectRadius, config.rectRadius);
170
- }
171
- }
172
- if (height < 0) {
173
- height *= -1;
174
- y -= height;
175
- }
176
- if (width < 0) {
177
- width *= -1;
178
- x -= width;
179
- }
180
- var d = "";
181
- if (rectRadius.length >= 4) {
182
- d = "M" + (x + rectRadius[0]) + " " + y;
183
- d += "L" + (x + width - rectRadius[1]) + " " + y;
184
- d += "A" + rectRadius[1] + " " + rectRadius[1] + " 0 0 1 " + (x + width) + " " + (y + rectRadius[1]);
185
- d += "L" + (x + width) + " " + (y + height - rectRadius[2]);
186
- d += "A" + rectRadius[2] + " " + rectRadius[2] + " 0 0 1 " + (x + width - rectRadius[2]) + " " + (y + height);
187
- d += "L" + (x + rectRadius[3]) + " " + (y + height);
188
- d += "A" + rectRadius[3] + " " + rectRadius[3] + " 0 0 1 " + x + " " + (y + height - rectRadius[3]);
189
- d += "L" + x + " " + (y + rectRadius[0]);
190
- d += "A" + rectRadius[0] + " " + rectRadius[0] + " 0 0 1 " + (x + rectRadius[0]) + " " + y;
191
- }
192
- else {
193
- d = "M" + x + " " + y;
194
- d += "L" + (x + width) + " " + y;
195
- d += "L" + (x + width) + " " + (y + height);
196
- d += "L" + x + " " + (y + height);
197
- d += "Z";
198
- }
199
- setAttribute(el, "d", d);
200
- };
201
- var initArc = function (el, config, cx, cy, r1, r2, beginDeg, deg) {
202
- if (el.nodeName.toLowerCase() !== "path")
203
- throw new Error("Need a <path> !");
204
- beginDeg = (beginDeg / 180) * Math.PI;
205
- deg = (deg / 180) * Math.PI;
206
- beginDeg = beginDeg % (Math.PI * 2);
207
- if (r1 > r2) {
208
- var temp = r1;
209
- r1 = r2;
210
- r2 = temp;
211
- }
212
- if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
213
- deg = Math.PI * 1.999999;
214
- }
215
- else {
216
- deg = deg % (Math.PI * 2);
217
- }
218
- arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
219
- var f = endA - beginA > Math.PI ? 1 : 0;
220
- var d = "M" + begInnerX + " " + begInnerY;
221
- if (r < 0)
222
- r = -r;
223
- d +=
224
- "A" + r1 + " " + r1 + " 0 " + f + " 1 " + endInnerX + " " + endInnerY;
225
- if (config.arcEndCap == "round")
226
- d += "A" + r + " " + r + " " + " 0 1 0 " + endOuterX + " " + endOuterY;
227
- else if (config.arcEndCap == "-round")
228
- d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
229
- else
230
- d += "L" + endOuterX + " " + endOuterY;
231
- d +=
232
- "A" + r2 + " " + r2 + " 0 " + f + " 0 " + begOuterX + " " + begOuterY;
233
- if (config.arcStartCap == "round")
234
- d += "A" + r + " " + r + " " + " 0 1 0 " + begInnerX + " " + begInnerY;
235
- else if (config.arcStartCap == "-round")
236
- d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
237
- else
238
- d += "L" + begInnerX + " " + begInnerY;
239
- if (config.arcStartCap == "butt")
240
- d += "Z";
241
- setAttribute(el, "d", d);
242
- });
115
+ var initDefs = function (el) {
116
+ var defs = el.getElementsByTagName('defs');
117
+ if (defs.length <= 0) {
118
+ var newDefs = toNode("defs");
119
+ el.appendChild(newDefs);
120
+ return newDefs;
121
+ }
122
+ else {
123
+ return defs[0];
124
+ }
125
+ };
126
+ var initText = function (el, config, x, y, deg) {
127
+ if (el.nodeName.toLowerCase() !== "text")
128
+ throw new Error("Need a <text> !");
129
+ setAttribute(el, "dy", {
130
+ top: config["fontSize"] * 0.5,
131
+ middle: 0,
132
+ bottom: -config["fontSize"] * 0.5,
133
+ }[config.textBaseline]);
134
+ setStyle(el, {
135
+ "text-anchor": {
136
+ left: "start",
137
+ right: "end",
138
+ center: "middle",
139
+ }[config.textAlign],
140
+ "dominant-baseline": "central",
141
+ "font-size": config["fontSize"] + "px",
142
+ "font-family": config["fontFamily"],
143
+ });
144
+ setAttribute(el, "x", x);
145
+ setAttribute(el, "y", y);
146
+ if (typeof deg == "number") {
147
+ deg = deg % 360;
148
+ setAttribute(el, "transform", "rotate(" + deg + "," + x + "," + y + ")");
149
+ }
150
+ };
151
+ var initCircle = function (el, cx, cy, r) {
152
+ if (el.nodeName.toLowerCase() !== "circle")
153
+ throw new Error("Need a <circle> !");
154
+ setAttribute(el, "cx", cx);
155
+ setAttribute(el, "cy", cy);
156
+ setAttribute(el, "r", r);
157
+ };
158
+ var initPath = function (el, path) {
159
+ if (el.nodeName.toLowerCase() !== "path")
160
+ throw new Error("Need a <path> !");
161
+ setAttribute(el, "d", path);
162
+ };
163
+ var initRect = function (el, config, x, y, width, height) {
164
+ if (el.nodeName.toLowerCase() !== "path")
165
+ throw new Error("Need a <path> !");
166
+ var rectRadius = [];
167
+ if (Array.isArray(config.rectRadius) && config.rectRadius.length > 0) {
168
+ for (var index = 0; index < 4; index++) {
169
+ rectRadius.push.apply(rectRadius, config.rectRadius);
170
+ }
171
+ }
172
+ if (height < 0) {
173
+ height *= -1;
174
+ y -= height;
175
+ }
176
+ if (width < 0) {
177
+ width *= -1;
178
+ x -= width;
179
+ }
180
+ var d = "";
181
+ if (rectRadius.length >= 4) {
182
+ d = "M" + (x + rectRadius[0]) + " " + y;
183
+ d += "L" + (x + width - rectRadius[1]) + " " + y;
184
+ d += "A" + rectRadius[1] + " " + rectRadius[1] + " 0 0 1 " + (x + width) + " " + (y + rectRadius[1]);
185
+ d += "L" + (x + width) + " " + (y + height - rectRadius[2]);
186
+ d += "A" + rectRadius[2] + " " + rectRadius[2] + " 0 0 1 " + (x + width - rectRadius[2]) + " " + (y + height);
187
+ d += "L" + (x + rectRadius[3]) + " " + (y + height);
188
+ d += "A" + rectRadius[3] + " " + rectRadius[3] + " 0 0 1 " + x + " " + (y + height - rectRadius[3]);
189
+ d += "L" + x + " " + (y + rectRadius[0]);
190
+ d += "A" + rectRadius[0] + " " + rectRadius[0] + " 0 0 1 " + (x + rectRadius[0]) + " " + y;
191
+ }
192
+ else {
193
+ d = "M" + x + " " + y;
194
+ d += "L" + (x + width) + " " + y;
195
+ d += "L" + (x + width) + " " + (y + height);
196
+ d += "L" + x + " " + (y + height);
197
+ d += "Z";
198
+ }
199
+ setAttribute(el, "d", d);
200
+ };
201
+ var initArc = function (el, config, cx, cy, r1, r2, beginDeg, deg) {
202
+ if (el.nodeName.toLowerCase() !== "path")
203
+ throw new Error("Need a <path> !");
204
+ beginDeg = (beginDeg / 180) * Math.PI;
205
+ deg = (deg / 180) * Math.PI;
206
+ beginDeg = beginDeg % (Math.PI * 2);
207
+ if (r1 > r2) {
208
+ var temp = r1;
209
+ r1 = r2;
210
+ r2 = temp;
211
+ }
212
+ if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
213
+ deg = Math.PI * 1.999999;
214
+ }
215
+ else {
216
+ deg = deg % (Math.PI * 2);
217
+ }
218
+ arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
219
+ var f = endA - beginA > Math.PI ? 1 : 0;
220
+ var d = "M" + begInnerX + " " + begInnerY;
221
+ if (r < 0)
222
+ r = -r;
223
+ d +=
224
+ "A" + r1 + " " + r1 + " 0 " + f + " 1 " + endInnerX + " " + endInnerY;
225
+ if (config.arcEndCap == "round")
226
+ d += "A" + r + " " + r + " " + " 0 1 0 " + endOuterX + " " + endOuterY;
227
+ else if (config.arcEndCap == "-round")
228
+ d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
229
+ else
230
+ d += "L" + endOuterX + " " + endOuterY;
231
+ d +=
232
+ "A" + r2 + " " + r2 + " 0 " + f + " 0 " + begOuterX + " " + begOuterY;
233
+ if (config.arcStartCap == "round")
234
+ d += "A" + r + " " + r + " " + " 0 1 0 " + begInnerX + " " + begInnerY;
235
+ else if (config.arcStartCap == "-round")
236
+ d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
237
+ else
238
+ d += "L" + begInnerX + " " + begInnerY;
239
+ if (config.arcStartCap == "butt")
240
+ d += "Z";
241
+ setAttribute(el, "d", d);
242
+ });
243
243
  };
244
244
 
245
- function rotate (cx, cy, deg, x, y) {
246
- var cos = Math.cos(deg), sin = Math.sin(deg);
247
- return [
248
- (x - cx) * cos - (y - cy) * sin + cx,
249
- (x - cx) * sin + (y - cy) * cos + cy
250
- ];
245
+ function rotate (cx, cy, deg, x, y) {
246
+ var cos = Math.cos(deg), sin = Math.sin(deg);
247
+ return [
248
+ (x - cx) * cos - (y - cy) * sin + cx,
249
+ (x - cx) * sin + (y - cy) * cos + cy
250
+ ];
251
251
  }
252
252
 
253
- var enhanceGradient = function (gradient, gradientId) {
254
- var enhanceGradient = {
255
- "value": function () {
256
- return "url(#" + gradientId + ")";
257
- },
258
- "setColor": function (stop, color) {
259
- var stopEl = toNode("stop");
260
- gradient.appendChild(stopEl);
261
- setAttribute(stopEl, "offset", (stop * 100) + "%");
262
- setAttribute(stopEl, "style", "stop-color:" + color + ";");
263
- return enhanceGradient;
264
- }
265
- };
266
- return enhanceGradient;
267
- };
268
- var linearGradient = function (el, x0, y0, x1, y1) {
269
- var defs = initDefs(el);
270
- var gradientId = "visliteLg" + new Date().valueOf() + "" + (Math.random() * 1000000).toFixed(0);
271
- var linearGradient = toNode("linearGradient");
272
- defs.appendChild(linearGradient);
273
- setAttribute(linearGradient, "id", gradientId);
274
- setAttribute(linearGradient, "x1", x0 + "%");
275
- setAttribute(linearGradient, "y1", y0 + "%");
276
- setAttribute(linearGradient, "x2", x1 + "%");
277
- setAttribute(linearGradient, "y2", y1 + "%");
278
- return enhanceGradient(linearGradient, gradientId);
279
- };
280
- var radialGradient = function (el, cx, cy, r) {
281
- var defs = initDefs(el);
282
- var gradientId = "visliteRg" + new Date().valueOf() + "" + (Math.random() * 1000000).toFixed(0);
283
- var radialGradient = toNode("radialGradient");
284
- defs.appendChild(radialGradient);
285
- setAttribute(radialGradient, "id", gradientId);
286
- setAttribute(radialGradient, "cx", cx + "%");
287
- setAttribute(radialGradient, "cy", cy + "%");
288
- setAttribute(radialGradient, "r", r + "%");
289
- return enhanceGradient(radialGradient, gradientId);
253
+ var enhanceGradient = function (gradient, gradientId) {
254
+ var enhanceGradient = {
255
+ "value": function () {
256
+ return "url(#" + gradientId + ")";
257
+ },
258
+ "setColor": function (stop, color) {
259
+ var stopEl = toNode("stop");
260
+ gradient.appendChild(stopEl);
261
+ setAttribute(stopEl, "offset", (stop * 100) + "%");
262
+ setAttribute(stopEl, "style", "stop-color:" + color + ";");
263
+ return enhanceGradient;
264
+ }
265
+ };
266
+ return enhanceGradient;
267
+ };
268
+ var linearGradient = function (el, x0, y0, x1, y1) {
269
+ var defs = initDefs(el);
270
+ var gradientId = "visliteLg" + new Date().valueOf() + "" + (Math.random() * 1000000).toFixed(0);
271
+ var linearGradient = toNode("linearGradient");
272
+ defs.appendChild(linearGradient);
273
+ setAttribute(linearGradient, "id", gradientId);
274
+ setAttribute(linearGradient, "x1", x0 + "%");
275
+ setAttribute(linearGradient, "y1", y0 + "%");
276
+ setAttribute(linearGradient, "x2", x1 + "%");
277
+ setAttribute(linearGradient, "y2", y1 + "%");
278
+ return enhanceGradient(linearGradient, gradientId);
279
+ };
280
+ var radialGradient = function (el, cx, cy, r) {
281
+ var defs = initDefs(el);
282
+ var gradientId = "visliteRg" + new Date().valueOf() + "" + (Math.random() * 1000000).toFixed(0);
283
+ var radialGradient = toNode("radialGradient");
284
+ defs.appendChild(radialGradient);
285
+ setAttribute(radialGradient, "id", gradientId);
286
+ setAttribute(radialGradient, "cx", cx + "%");
287
+ setAttribute(radialGradient, "cy", cy + "%");
288
+ setAttribute(radialGradient, "r", r + "%");
289
+ return enhanceGradient(radialGradient, gradientId);
290
290
  };
291
291
 
292
- function defaultFactory () {
293
- return {
294
- fillStyle: "rgb(0,0,0)",
295
- strokeStyle: "rgb(0,0,0)",
296
- textAlign: "left",
297
- textBaseline: "middle",
298
- "fontSize": 16,
299
- "fontFamily": "sans-serif",
300
- "arcStartCap": "butt",
301
- "arcEndCap": "butt",
302
- lineDash: [],
303
- lineWidth: 1,
304
- lineCap: "butt",
305
- lineJoin: "miter",
306
- "rectRadius": []
307
- };
292
+ function defaultFactory () {
293
+ return {
294
+ fillStyle: "rgb(0,0,0)",
295
+ strokeStyle: "rgb(0,0,0)",
296
+ textAlign: "left",
297
+ textBaseline: "middle",
298
+ "fontSize": 16,
299
+ "fontFamily": "sans-serif",
300
+ "arcStartCap": "butt",
301
+ "arcEndCap": "butt",
302
+ lineDash: [],
303
+ lineWidth: 1,
304
+ lineCap: "butt",
305
+ lineJoin: "miter",
306
+ "rectRadius": []
307
+ };
308
308
  }
309
309
 
310
- var SVG$1 = (function () {
311
- function SVG(svg) {
312
- this.name = "SVG";
313
- this.__config = defaultFactory();
314
- this.__path = "";
315
- this.__currentPosition = [];
316
- this.__svg = svg;
317
- }
318
- SVG.prototype.config = function (params) {
319
- if (typeof params !== "object") {
320
- return this.__config[params];
321
- }
322
- else {
323
- for (var key in params) {
324
- this.__config[key] = params[key];
325
- }
326
- }
327
- return this;
328
- };
329
- SVG.prototype.reset = function () {
330
- this.config(defaultFactory());
331
- return this;
332
- };
333
- SVG.prototype.useEl = function (el) {
334
- this.__useEl = el;
335
- return this;
336
- };
337
- SVG.prototype.getEl = function () {
338
- return this.__useEl;
339
- };
340
- SVG.prototype.appendEl = function (el, context) {
341
- context = context || this.__svg;
342
- if (typeof el == "string")
343
- el = toNode(el);
344
- context.appendChild(el);
345
- this.__useEl = el;
346
- return this;
347
- };
348
- SVG.prototype.appendBoard = function (el, context) {
349
- var _el = el;
350
- if (typeof el == "string")
351
- _el =
352
- {
353
- text: "text",
354
- path: "path",
355
- arc: "path",
356
- circle: "circle",
357
- rect: "rect",
358
- }[el] || "";
359
- if (_el == "")
360
- throw new Error("Unsupported drawing method:" + el);
361
- return this.appendEl(_el, context);
362
- };
363
- SVG.prototype.remove = function () {
364
- if (!this.__useEl) {
365
- throw new Error("Currently, no node can be deleted.");
366
- }
367
- else {
368
- this.__useEl.parentNode.removeChild(this.__useEl);
369
- }
370
- return this;
371
- };
372
- SVG.prototype.attr = function (params) {
373
- if (!this.__useEl)
374
- throw new Error("Currently, no node can be modified or viewed.");
375
- if (typeof params !== "object") {
376
- return getAttribute(this.__useEl, params);
377
- }
378
- else {
379
- for (var key in params) {
380
- setAttribute(this.__useEl, key, params[key]);
381
- }
382
- return this;
383
- }
384
- };
385
- SVG.prototype.fillText = function (text, x, y, deg) {
386
- if (deg === void 0) { deg = 0; }
387
- initText(this.__useEl, this.__config, x, y, deg);
388
- this.__useEl.textContent = text;
389
- fill(this.__useEl, this.__config);
390
- return this;
391
- };
392
- SVG.prototype.strokeText = function (text, x, y, deg) {
393
- if (deg === void 0) { deg = 0; }
394
- initText(this.__useEl, this.__config, x, y, deg);
395
- this.__useEl.textContent = text;
396
- stroke(this.__useEl, this.__config);
397
- return this;
398
- };
399
- SVG.prototype.fullText = function (text, x, y, deg) {
400
- if (deg === void 0) { deg = 0; }
401
- initText(this.__useEl, this.__config, x, y, deg);
402
- this.__useEl.textContent = text;
403
- full(this.__useEl, this.__config);
404
- return this;
405
- };
406
- SVG.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
407
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
408
- fill(this.__useEl, this.__config);
409
- return this;
410
- };
411
- SVG.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
412
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
413
- stroke(this.__useEl, this.__config);
414
- return this;
415
- };
416
- SVG.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
417
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
418
- full(this.__useEl, this.__config);
419
- return this;
420
- };
421
- SVG.prototype.fillCircle = function (cx, cy, r) {
422
- initCircle(this.__useEl, cx, cy, r);
423
- fill(this.__useEl, this.__config);
424
- return this;
425
- };
426
- SVG.prototype.strokeCircle = function (cx, cy, r) {
427
- initCircle(this.__useEl, cx, cy, r);
428
- stroke(this.__useEl, this.__config);
429
- return this;
430
- };
431
- SVG.prototype.fullCircle = function (cx, cy, r) {
432
- initCircle(this.__useEl, cx, cy, r);
433
- full(this.__useEl, this.__config);
434
- return this;
435
- };
436
- SVG.prototype.fillRect = function (x, y, width, height) {
437
- initRect(this.__useEl, this.__config, x, y, width, height);
438
- fill(this.__useEl, this.__config);
439
- return this;
440
- };
441
- SVG.prototype.strokeRect = function (x, y, width, height) {
442
- initRect(this.__useEl, this.__config, x, y, width, height);
443
- stroke(this.__useEl, this.__config);
444
- return this;
445
- };
446
- SVG.prototype.fullRect = function (x, y, width, height) {
447
- initRect(this.__useEl, this.__config, x, y, width, height);
448
- full(this.__useEl, this.__config);
449
- return this;
450
- };
451
- SVG.prototype.beginPath = function () {
452
- this.__currentPosition = [];
453
- this.__path = "";
454
- return this;
455
- };
456
- SVG.prototype.closePath = function () {
457
- this.__path += "Z";
458
- return this;
459
- };
460
- SVG.prototype.moveTo = function (x, y) {
461
- this.__currentPosition = [x, y];
462
- this.__path += "M" + x + " " + y;
463
- return this;
464
- };
465
- SVG.prototype.lineTo = function (x, y) {
466
- this.__currentPosition = [x, y];
467
- this.__path += (this.__path == "" ? "M" : "L") + x + " " + y;
468
- return this;
469
- };
470
- SVG.prototype.fill = function () {
471
- initPath(this.__useEl, this.__path);
472
- fill(this.__useEl, this.__config);
473
- return this;
474
- };
475
- SVG.prototype.stroke = function () {
476
- initPath(this.__useEl, this.__path);
477
- stroke(this.__useEl, this.__config);
478
- return this;
479
- };
480
- SVG.prototype.full = function () {
481
- initPath(this.__useEl, this.__path);
482
- full(this.__useEl, this.__config);
483
- return this;
484
- };
485
- SVG.prototype.arc = function (x, y, r, beginDeg, deg) {
486
- var begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y);
487
- var endPosition = rotate(x, y, ((beginDeg + deg) / 180) * Math.PI, x + r, y);
488
- if (this.__path == "") {
489
- this.__path += "M" + begPosition[0] + "," + begPosition[1];
490
- }
491
- else if (begPosition[0] != this.__currentPosition[0] ||
492
- begPosition[1] != this.__currentPosition[1]) {
493
- this.__path += "L" + begPosition[0] + "," + begPosition[1];
494
- }
495
- this.__path +=
496
- "A" +
497
- r +
498
- "," +
499
- r +
500
- " 0 " +
501
- (deg > 180 || deg < -180 ? 1 : 0) +
502
- "," +
503
- (deg > 0 ? 1 : 0) +
504
- " " +
505
- endPosition[0] +
506
- "," +
507
- endPosition[1];
508
- return this;
509
- };
510
- SVG.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
511
- this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y;
512
- return this;
513
- };
514
- SVG.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
515
- this.__path +=
516
- "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y;
517
- return this;
518
- };
519
- SVG.prototype.bind = function (eventType, callback) {
520
- this.__useEl.addEventListener(eventType, function (event) {
521
- callback.call(this, event, this);
522
- }, false);
523
- return this;
524
- };
525
- SVG.prototype.createLinearGradient = function (x0, y0, x1, y1) {
526
- return linearGradient(this.__svg, x0, y0, x1, y1);
527
- };
528
- SVG.prototype.createRadialGradient = function (cx, cy, r) {
529
- return radialGradient(this.__svg, cx, cy, r);
530
- };
531
- return SVG;
310
+ var SVG$1 = (function () {
311
+ function SVG(svg) {
312
+ this.name = "SVG";
313
+ this.__config = defaultFactory();
314
+ this.__path = "";
315
+ this.__currentPosition = [];
316
+ this.__svg = svg;
317
+ }
318
+ SVG.prototype.config = function (params) {
319
+ if (typeof params !== "object") {
320
+ return this.__config[params];
321
+ }
322
+ else {
323
+ for (var key in params) {
324
+ this.__config[key] = params[key];
325
+ }
326
+ }
327
+ return this;
328
+ };
329
+ SVG.prototype.reset = function () {
330
+ this.config(defaultFactory());
331
+ return this;
332
+ };
333
+ SVG.prototype.useEl = function (el) {
334
+ this.__useEl = el;
335
+ return this;
336
+ };
337
+ SVG.prototype.getEl = function () {
338
+ return this.__useEl;
339
+ };
340
+ SVG.prototype.appendEl = function (el, context) {
341
+ context = context || this.__svg;
342
+ if (typeof el == "string")
343
+ el = toNode(el);
344
+ context.appendChild(el);
345
+ this.__useEl = el;
346
+ return this;
347
+ };
348
+ SVG.prototype.appendBoard = function (el, context) {
349
+ var _el = el;
350
+ if (typeof el == "string")
351
+ _el =
352
+ {
353
+ text: "text",
354
+ path: "path",
355
+ arc: "path",
356
+ circle: "circle",
357
+ rect: "rect",
358
+ }[el] || "";
359
+ if (_el == "")
360
+ throw new Error("Unsupported drawing method:" + el);
361
+ return this.appendEl(_el, context);
362
+ };
363
+ SVG.prototype.remove = function () {
364
+ if (!this.__useEl) {
365
+ throw new Error("Currently, no node can be deleted.");
366
+ }
367
+ else {
368
+ this.__useEl.parentNode.removeChild(this.__useEl);
369
+ }
370
+ return this;
371
+ };
372
+ SVG.prototype.attr = function (params) {
373
+ if (!this.__useEl)
374
+ throw new Error("Currently, no node can be modified or viewed.");
375
+ if (typeof params !== "object") {
376
+ return getAttribute(this.__useEl, params);
377
+ }
378
+ else {
379
+ for (var key in params) {
380
+ setAttribute(this.__useEl, key, params[key]);
381
+ }
382
+ return this;
383
+ }
384
+ };
385
+ SVG.prototype.fillText = function (text, x, y, deg) {
386
+ if (deg === void 0) { deg = 0; }
387
+ initText(this.__useEl, this.__config, x, y, deg);
388
+ this.__useEl.textContent = text;
389
+ fill(this.__useEl, this.__config);
390
+ return this;
391
+ };
392
+ SVG.prototype.strokeText = function (text, x, y, deg) {
393
+ if (deg === void 0) { deg = 0; }
394
+ initText(this.__useEl, this.__config, x, y, deg);
395
+ this.__useEl.textContent = text;
396
+ stroke(this.__useEl, this.__config);
397
+ return this;
398
+ };
399
+ SVG.prototype.fullText = function (text, x, y, deg) {
400
+ if (deg === void 0) { deg = 0; }
401
+ initText(this.__useEl, this.__config, x, y, deg);
402
+ this.__useEl.textContent = text;
403
+ full(this.__useEl, this.__config);
404
+ return this;
405
+ };
406
+ SVG.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
407
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
408
+ fill(this.__useEl, this.__config);
409
+ return this;
410
+ };
411
+ SVG.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
412
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
413
+ stroke(this.__useEl, this.__config);
414
+ return this;
415
+ };
416
+ SVG.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
417
+ initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
418
+ full(this.__useEl, this.__config);
419
+ return this;
420
+ };
421
+ SVG.prototype.fillCircle = function (cx, cy, r) {
422
+ initCircle(this.__useEl, cx, cy, r);
423
+ fill(this.__useEl, this.__config);
424
+ return this;
425
+ };
426
+ SVG.prototype.strokeCircle = function (cx, cy, r) {
427
+ initCircle(this.__useEl, cx, cy, r);
428
+ stroke(this.__useEl, this.__config);
429
+ return this;
430
+ };
431
+ SVG.prototype.fullCircle = function (cx, cy, r) {
432
+ initCircle(this.__useEl, cx, cy, r);
433
+ full(this.__useEl, this.__config);
434
+ return this;
435
+ };
436
+ SVG.prototype.fillRect = function (x, y, width, height) {
437
+ initRect(this.__useEl, this.__config, x, y, width, height);
438
+ fill(this.__useEl, this.__config);
439
+ return this;
440
+ };
441
+ SVG.prototype.strokeRect = function (x, y, width, height) {
442
+ initRect(this.__useEl, this.__config, x, y, width, height);
443
+ stroke(this.__useEl, this.__config);
444
+ return this;
445
+ };
446
+ SVG.prototype.fullRect = function (x, y, width, height) {
447
+ initRect(this.__useEl, this.__config, x, y, width, height);
448
+ full(this.__useEl, this.__config);
449
+ return this;
450
+ };
451
+ SVG.prototype.beginPath = function () {
452
+ this.__currentPosition = [];
453
+ this.__path = "";
454
+ return this;
455
+ };
456
+ SVG.prototype.closePath = function () {
457
+ this.__path += "Z";
458
+ return this;
459
+ };
460
+ SVG.prototype.moveTo = function (x, y) {
461
+ this.__currentPosition = [x, y];
462
+ this.__path += "M" + x + " " + y;
463
+ return this;
464
+ };
465
+ SVG.prototype.lineTo = function (x, y) {
466
+ this.__currentPosition = [x, y];
467
+ this.__path += (this.__path == "" ? "M" : "L") + x + " " + y;
468
+ return this;
469
+ };
470
+ SVG.prototype.fill = function () {
471
+ initPath(this.__useEl, this.__path);
472
+ fill(this.__useEl, this.__config);
473
+ return this;
474
+ };
475
+ SVG.prototype.stroke = function () {
476
+ initPath(this.__useEl, this.__path);
477
+ stroke(this.__useEl, this.__config);
478
+ return this;
479
+ };
480
+ SVG.prototype.full = function () {
481
+ initPath(this.__useEl, this.__path);
482
+ full(this.__useEl, this.__config);
483
+ return this;
484
+ };
485
+ SVG.prototype.arc = function (x, y, r, beginDeg, deg) {
486
+ var begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y);
487
+ var endPosition = rotate(x, y, ((beginDeg + deg) / 180) * Math.PI, x + r, y);
488
+ if (this.__path == "") {
489
+ this.__path += "M" + begPosition[0] + "," + begPosition[1];
490
+ }
491
+ else if (begPosition[0] != this.__currentPosition[0] ||
492
+ begPosition[1] != this.__currentPosition[1]) {
493
+ this.__path += "L" + begPosition[0] + "," + begPosition[1];
494
+ }
495
+ this.__path +=
496
+ "A" +
497
+ r +
498
+ "," +
499
+ r +
500
+ " 0 " +
501
+ (deg > 180 || deg < -180 ? 1 : 0) +
502
+ "," +
503
+ (deg > 0 ? 1 : 0) +
504
+ " " +
505
+ endPosition[0] +
506
+ "," +
507
+ endPosition[1];
508
+ return this;
509
+ };
510
+ SVG.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
511
+ this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y;
512
+ return this;
513
+ };
514
+ SVG.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
515
+ this.__path +=
516
+ "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y;
517
+ return this;
518
+ };
519
+ SVG.prototype.bind = function (eventType, callback) {
520
+ this.__useEl.addEventListener(eventType, function (event) {
521
+ callback.call(this, event, this);
522
+ }, false);
523
+ return this;
524
+ };
525
+ SVG.prototype.createLinearGradient = function (x0, y0, x1, y1) {
526
+ return linearGradient(this.__svg, x0, y0, x1, y1);
527
+ };
528
+ SVG.prototype.createRadialGradient = function (cx, cy, r) {
529
+ return radialGradient(this.__svg, cx, cy, r);
530
+ };
531
+ return SVG;
532
532
  }());
533
533
 
534
- var SVG = (function (_super) {
535
- __extends(SVG, _super);
536
- function SVG(el) {
537
- var _this = this;
538
- if (!el) {
539
- throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");
540
- }
541
- var width = el.clientWidth, height = el.clientHeight;
542
- var ViewSVG = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
543
- el.appendChild(ViewSVG);
544
- ViewSVG.setAttribute("width", width + "");
545
- ViewSVG.setAttribute("height", height + "");
546
- ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height);
547
- _this = _super.call(this, ViewSVG) || this;
548
- _this.__el = el;
549
- return _this;
550
- }
551
- SVG.prototype.toDataURL = function () {
552
- var _this = this;
553
- return new Promise(function (resolve) {
554
- var width = _this.__el.clientWidth, height = _this.__el.clientHeight;
555
- var img = document.createElement('img');
556
- img.setAttribute('width', width + "");
557
- img.setAttribute('height', height + "");
558
- var base64_svg = "data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='" + width + "' height='" + height + "'>" + _this.__svg.innerHTML.replace(/"/g, "'") + "</svg>";
559
- img.setAttribute('src', base64_svg);
560
- setTimeout(function () {
561
- var canvas = document.createElement('canvas');
562
- canvas.setAttribute('width', width + "");
563
- canvas.setAttribute('height', height + "");
564
- var painter = canvas.getContext('2d');
565
- if (painter)
566
- painter.drawImage(img, 0, 0, width, height);
567
- resolve(canvas.toDataURL());
568
- }, 100);
569
- });
570
- };
571
- return SVG;
534
+ var SVG = (function (_super) {
535
+ __extends(SVG, _super);
536
+ function SVG(el) {
537
+ var _this = this;
538
+ if (!el) {
539
+ throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");
540
+ }
541
+ var width = el.clientWidth, height = el.clientHeight;
542
+ var ViewSVG = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
543
+ el.appendChild(ViewSVG);
544
+ ViewSVG.setAttribute("width", width + "");
545
+ ViewSVG.setAttribute("height", height + "");
546
+ ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height);
547
+ _this = _super.call(this, ViewSVG) || this;
548
+ _this.__el = el;
549
+ return _this;
550
+ }
551
+ SVG.prototype.toDataURL = function () {
552
+ var _this = this;
553
+ return new Promise(function (resolve) {
554
+ var width = _this.__el.clientWidth, height = _this.__el.clientHeight;
555
+ var img = document.createElement('img');
556
+ img.setAttribute('width', width + "");
557
+ img.setAttribute('height', height + "");
558
+ var base64_svg = "data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='" + width + "' height='" + height + "'>" + _this.__svg.innerHTML.replace(/"/g, "'") + "</svg>";
559
+ img.setAttribute('src', base64_svg);
560
+ setTimeout(function () {
561
+ var canvas = document.createElement('canvas');
562
+ canvas.setAttribute('width', width + "");
563
+ canvas.setAttribute('height', height + "");
564
+ var painter = canvas.getContext('2d');
565
+ if (painter)
566
+ painter.drawImage(img, 0, 0, width, height);
567
+ resolve(canvas.toDataURL());
568
+ }, 100);
569
+ });
570
+ };
571
+ return SVG;
572
572
  }(SVG$1));
573
573
 
574
574
  export { SVG as default };