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