vislite 1.3.0 → 1.4.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 (191) hide show
  1. package/AUTHORS.txt +6 -6
  2. package/CHANGELOG +307 -300
  3. package/LICENSE +20 -20
  4. package/README.md +284 -284
  5. package/lib/BarLayout/index.es.d.ts +3 -0
  6. package/lib/BarLayout/index.es.js +467 -0
  7. package/lib/BarLayout/index.es.min.d.ts +3 -0
  8. package/lib/BarLayout/index.es.min.js +10 -0
  9. package/lib/Buffer/index.es.js +35 -35
  10. package/lib/Buffer/index.es.min.js +1 -1
  11. package/lib/Canvas/index.es.js +774 -774
  12. package/lib/Canvas/index.es.min.js +1 -1
  13. package/lib/Cardinal/index.es.js +90 -90
  14. package/lib/Cardinal/index.es.min.js +1 -1
  15. package/lib/Eoap/index.es.js +33 -33
  16. package/lib/Eoap/index.es.min.js +1 -1
  17. package/lib/Hermite/index.es.js +35 -35
  18. package/lib/Hermite/index.es.min.js +1 -1
  19. package/lib/MapCoordinate/index.es.js +199 -199
  20. package/lib/MapCoordinate/index.es.min.js +1 -1
  21. package/lib/Matrix4/index.es.js +124 -124
  22. package/lib/Matrix4/index.es.min.js +1 -1
  23. package/lib/Mercator/index.es.js +19 -19
  24. package/lib/Mercator/index.es.min.js +1 -1
  25. package/lib/PieLayout/index.es.d.ts +3 -0
  26. package/lib/PieLayout/index.es.js +234 -0
  27. package/lib/PieLayout/index.es.min.d.ts +3 -0
  28. package/lib/PieLayout/index.es.min.js +9 -0
  29. package/lib/RawCanvas/index.es.js +704 -704
  30. package/lib/RawCanvas/index.es.min.js +1 -1
  31. package/lib/SVG/index.es.js +514 -491
  32. package/lib/SVG/index.es.min.js +2 -2
  33. package/lib/Shader/index.es.js +35 -35
  34. package/lib/Shader/index.es.min.js +1 -1
  35. package/lib/Texture/index.es.js +53 -53
  36. package/lib/Texture/index.es.min.js +1 -1
  37. package/lib/TreeLayout/index.es.js +316 -309
  38. package/lib/TreeLayout/index.es.min.js +6 -2
  39. package/lib/animation/index.es.js +16 -9
  40. package/lib/animation/index.es.min.js +6 -2
  41. package/lib/assemble/index.es.js +17 -17
  42. package/lib/assemble/index.es.min.js +1 -1
  43. package/lib/getLoopColors/index.es.js +35 -35
  44. package/lib/getLoopColors/index.es.min.js +1 -1
  45. package/lib/getWebGLContext/index.es.js +62 -62
  46. package/lib/getWebGLContext/index.es.min.js +1 -1
  47. package/lib/index.umd.js +2675 -2327
  48. package/lib/index.umd.min.js +12 -2
  49. package/lib/initOption/index.es.js +6 -6
  50. package/lib/initOption/index.es.min.js +1 -1
  51. package/lib/mergeOption/index.es.js +34 -34
  52. package/lib/mergeOption/index.es.min.js +1 -1
  53. package/lib/move/index.es.js +7 -7
  54. package/lib/move/index.es.min.js +1 -1
  55. package/lib/rotate/index.es.js +7 -7
  56. package/lib/rotate/index.es.min.js +1 -1
  57. package/lib/ruler/index.es.js +137 -137
  58. package/lib/ruler/index.es.min.js +1 -1
  59. package/lib/scale/index.es.js +6 -6
  60. package/lib/scale/index.es.min.js +1 -1
  61. package/lib/throttle/index.es.js +7 -2
  62. package/lib/throttle/index.es.min.js +5 -1
  63. package/minialipay/ui-canvas/drawImage.js +35 -35
  64. package/minialipay/ui-canvas/index.acss +4 -4
  65. package/minialipay/ui-canvas/index.axml +3 -3
  66. package/minialipay/ui-canvas/index.d.ts +1 -1
  67. package/minialipay/ui-canvas/index.js +100 -100
  68. package/minialipay/ui-canvas/index.json +6 -6
  69. package/miniprogram/ui-canvas/drawImage.js +35 -35
  70. package/miniprogram/ui-canvas/index.js +117 -117
  71. package/miniprogram/ui-canvas/index.json +4 -4
  72. package/miniprogram/ui-canvas/index.wxml +4 -4
  73. package/miniprogram/ui-canvas/index.wxss +5 -5
  74. package/package/BarLayout/index.ts +3 -0
  75. package/package/Buffer/index.ts +2 -2
  76. package/package/Canvas/index.ts +2 -2
  77. package/package/Cardinal/index.ts +2 -2
  78. package/package/Eoap/index.ts +2 -2
  79. package/package/Hermite/index.ts +2 -2
  80. package/package/MapCoordinate/index.ts +2 -2
  81. package/package/Matrix4/index.ts +2 -2
  82. package/package/Mercator/index.ts +2 -2
  83. package/package/PieLayout/index.ts +3 -0
  84. package/package/RawCanvas/index.ts +2 -2
  85. package/package/SVG/index.ts +2 -2
  86. package/package/Shader/index.ts +2 -2
  87. package/package/Texture/index.ts +2 -2
  88. package/package/TreeLayout/index.ts +2 -2
  89. package/package/animation/index.ts +2 -2
  90. package/package/assemble/index.ts +2 -2
  91. package/package/getLoopColors/index.ts +2 -2
  92. package/package/getWebGLContext/index.ts +40 -40
  93. package/package/index.ts +84 -80
  94. package/package/initOption/index.ts +2 -2
  95. package/package/mergeOption/index.ts +2 -2
  96. package/package/move/index.ts +2 -2
  97. package/package/rotate/index.ts +2 -2
  98. package/package/ruler/index.ts +2 -2
  99. package/package/scale/index.ts +2 -2
  100. package/package/throttle/index.ts +2 -2
  101. package/package.json +75 -75
  102. package/src/Canvas.ts +84 -84
  103. package/src/Eoap.ts +66 -66
  104. package/src/Matrix4/index.ts +84 -84
  105. package/src/Matrix4/move.ts +12 -12
  106. package/src/Matrix4/rotate.ts +15 -15
  107. package/src/Matrix4/scale.ts +11 -11
  108. package/src/Matrix4/transform.ts +64 -64
  109. package/src/Mercator.ts +27 -27
  110. package/src/SVG.ts +55 -24
  111. package/src/common/assemble.ts +22 -22
  112. package/src/common/canvas/arc.ts +51 -51
  113. package/src/common/canvas/config.ts +176 -176
  114. package/src/common/canvas/default.ts +64 -64
  115. package/src/common/canvas/gradient.ts +31 -31
  116. package/src/common/canvas/index.ts +188 -188
  117. package/src/common/canvas/painter.ts +443 -443
  118. package/src/common/canvas/texts.ts +18 -18
  119. package/src/common/map/getBoundary.ts +15 -15
  120. package/src/common/map/tool.ts +29 -29
  121. package/src/common/option.ts +29 -29
  122. package/src/common/setStyle.ts +5 -5
  123. package/src/common/svg/config.ts +213 -213
  124. package/src/common/svg/default.ts +29 -29
  125. package/src/common/svg/gradient.ts +53 -53
  126. package/src/common/svg/index.ts +332 -332
  127. package/src/common/svg/tool.ts +51 -51
  128. package/src/common/tree/index.ts +25 -25
  129. package/src/common/tree/toInnerTree.ts +61 -61
  130. package/src/common/tree/toPlainTree.ts +135 -132
  131. package/src/common/type.ts +26 -26
  132. package/src/common/webgl/buffer.ts +79 -79
  133. package/src/common/webgl/getWebGLContext.ts +45 -45
  134. package/src/common/webgl/shader.ts +75 -75
  135. package/src/common/webgl/texture.ts +98 -97
  136. package/src/coordinate/MapCoordinate.ts +80 -80
  137. package/src/getLoopColors.ts +42 -42
  138. package/src/interpolation/Cardinal.ts +110 -110
  139. package/src/interpolation/Hermite.ts +65 -65
  140. package/src/layout/BarLayout.ts +249 -0
  141. package/src/layout/PieLayout.ts +142 -0
  142. package/src/layout/TreeLayout.ts +197 -194
  143. package/src/move.ts +7 -7
  144. package/src/rotate.ts +7 -7
  145. package/src/ruler.ts +209 -209
  146. package/src/scale.ts +6 -6
  147. package/types/Bar.d.ts +92 -0
  148. package/types/BarConfig.d.ts +5 -0
  149. package/types/BarLayout.d.ts +49 -0
  150. package/types/BarOption.d.ts +32 -0
  151. package/types/Buffer.d.ts +23 -23
  152. package/types/Canvas.d.ts +352 -352
  153. package/types/CanvasConfig.d.ts +88 -88
  154. package/types/CanvasOption.d.ts +8 -8
  155. package/types/CanvasOpts.d.ts +9 -9
  156. package/types/Cardinal.d.ts +13 -13
  157. package/types/Gradient.d.ts +14 -14
  158. package/types/Hermite.d.ts +18 -18
  159. package/types/Map.d.ts +9 -9
  160. package/types/MapConfig.d.ts +27 -27
  161. package/types/MapCoordinate.d.ts +22 -22
  162. package/types/Matrix4.d.ts +47 -47
  163. package/types/Pie.d.ts +74 -0
  164. package/types/PieConfig.d.ts +27 -0
  165. package/types/PieLayout.d.ts +41 -0
  166. package/types/PieOption.d.ts +22 -0
  167. package/types/SVG.d.ts +247 -243
  168. package/types/SVGConfig.d.ts +71 -71
  169. package/types/Shader.d.ts +16 -16
  170. package/types/Texture.d.ts +16 -16
  171. package/types/Tree.d.ts +74 -74
  172. package/types/TreeConfig.d.ts +36 -36
  173. package/types/TreeLayout.d.ts +59 -59
  174. package/types/TreeOption.d.ts +48 -48
  175. package/types/animation.d.ts +5 -5
  176. package/types/assemble.d.ts +5 -5
  177. package/types/getLoopColors.d.ts +5 -5
  178. package/types/getWebGLContext.d.ts +7 -7
  179. package/types/index.d.ts +195 -179
  180. package/types/move.d.ts +5 -5
  181. package/types/option.d.ts +12 -12
  182. package/types/painterConfig.d.ts +4 -4
  183. package/types/rotate.d.ts +5 -5
  184. package/types/ruler.d.ts +10 -10
  185. package/types/scale.d.ts +5 -5
  186. package/types/throttle.d.ts +5 -5
  187. package/types/throttleOption.d.ts +1 -1
  188. package/types/ui-canvas.d.ts +4 -4
  189. package/types/uni-canvas.d.ts +3 -3
  190. package/uni-app/drawImage.js +19 -19
  191. package/uni-app/ui-canvas.vue +284 -284
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SVG of VISLite JavaScript Library v1.3.0
2
+ * SVG of VISLite JavaScript Library v1.4.0-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  /******************************************************************************
@@ -40,512 +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 = "vislite-lg-" + new Date().valueOf() + "-" + Math.random();
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 = "vislite-rg-" + new Date().valueOf() + "-" + Math.random();
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: "#000",
295
- strokeStyle: "#000",
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
- if (!el) {
538
- throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");
539
- }
540
- var width = el.clientWidth, height = el.clientHeight;
541
- var ViewSVG = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
542
- el.appendChild(ViewSVG);
543
- ViewSVG.setAttribute("width", width + "");
544
- ViewSVG.setAttribute("height", height + "");
545
- ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height);
546
- return _super.call(this, ViewSVG) || this;
547
- }
548
- 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;
549
572
  }(SVG$1));
550
573
 
551
574
  export { SVG as default };