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.
Files changed (191) hide show
  1. package/.editorconfig +18 -18
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +143 -137
  4. package/LICENSE +20 -20
  5. package/README.md +69 -69
  6. package/lib/Buffer/index.umd.js +36 -36
  7. package/lib/Buffer/index.umd.min.js +2 -2
  8. package/lib/Canvas/index.umd.js +650 -650
  9. package/lib/Canvas/index.umd.min.js +2 -2
  10. package/lib/Cardinal/index.umd.js +91 -91
  11. package/lib/Cardinal/index.umd.min.js +2 -2
  12. package/lib/Eoap/index.umd.js +34 -34
  13. package/lib/Eoap/index.umd.min.js +2 -2
  14. package/lib/Geometry/index.umd.js +142 -142
  15. package/lib/Geometry/index.umd.min.js +2 -2
  16. package/lib/Hermite/index.umd.js +36 -36
  17. package/lib/Hermite/index.umd.min.js +2 -2
  18. package/lib/Matrix4/index.umd.js +119 -119
  19. package/lib/Matrix4/index.umd.min.js +2 -2
  20. package/lib/Mercator/index.umd.js +20 -20
  21. package/lib/Mercator/index.umd.min.js +2 -2
  22. package/lib/OralCanvas/index.es.js +598 -598
  23. package/lib/OralCanvas/index.es.min.js +2 -2
  24. package/lib/OralWebGL/index.es.js +532 -532
  25. package/lib/OralWebGL/index.es.min.js +3 -3
  26. package/lib/SVG/index.umd.js +470 -405
  27. package/lib/SVG/index.umd.min.js +3 -3
  28. package/lib/Shader/index.umd.js +69 -69
  29. package/lib/Shader/index.umd.min.js +3 -3
  30. package/lib/Texture/index.umd.js +53 -53
  31. package/lib/Texture/index.umd.min.js +2 -2
  32. package/lib/TreeLayout/index.umd.js +363 -363
  33. package/lib/TreeLayout/index.umd.min.js +2 -2
  34. package/lib/WebGL/index.umd.js +579 -579
  35. package/lib/WebGL/index.umd.min.js +3 -3
  36. package/lib/animation/index.umd.js +72 -72
  37. package/lib/animation/index.umd.min.js +2 -2
  38. package/lib/formatColor/index.umd.js +40 -40
  39. package/lib/formatColor/index.umd.min.js +2 -2
  40. package/lib/getLoopColors/index.umd.js +36 -36
  41. package/lib/getLoopColors/index.umd.min.js +2 -2
  42. package/lib/getWebGLContext/index.umd.js +44 -44
  43. package/lib/getWebGLContext/index.umd.min.js +2 -2
  44. package/lib/index.umd.js +2744 -2662
  45. package/lib/index.umd.min.js +3 -3
  46. package/lib/move/index.umd.js +27 -0
  47. package/lib/move/index.umd.min.js +11 -0
  48. package/lib/resizeObserver/index.umd.js +29 -29
  49. package/lib/resizeObserver/index.umd.min.js +2 -2
  50. package/lib/rotate/index.umd.js +8 -8
  51. package/lib/rotate/index.umd.min.js +2 -2
  52. package/lib/ruler/index.umd.js +126 -126
  53. package/lib/ruler/index.umd.min.js +2 -2
  54. package/lib/scale/index.umd.js +26 -0
  55. package/lib/scale/index.umd.min.js +11 -0
  56. package/lib/throttle/index.umd.js +49 -49
  57. package/lib/throttle/index.umd.min.js +2 -2
  58. package/lib/viewHandler/index.umd.js +120 -120
  59. package/lib/viewHandler/index.umd.min.js +2 -2
  60. package/miniprogram/ui-canvas/index.js +107 -107
  61. package/miniprogram/ui-canvas/index.json +4 -4
  62. package/miniprogram/ui-canvas/index.wxml +4 -4
  63. package/miniprogram/ui-canvas/index.wxss +5 -5
  64. package/package/Buffer/index.ts +2 -2
  65. package/package/Canvas/index.ts +2 -2
  66. package/package/Cardinal/index.ts +2 -2
  67. package/package/Eoap/index.ts +2 -2
  68. package/package/Geometry/index.ts +2 -2
  69. package/package/Hermite/index.ts +2 -2
  70. package/package/Matrix4/index.ts +2 -2
  71. package/package/Mercator/index.ts +2 -2
  72. package/package/OralCanvas/index.ts +2 -2
  73. package/package/OralWebGL/index.ts +2 -2
  74. package/package/SVG/index.ts +2 -2
  75. package/package/Shader/index.ts +39 -39
  76. package/package/Texture/index.ts +2 -2
  77. package/package/TreeLayout/index.ts +2 -2
  78. package/package/WebGL/index.ts +2 -2
  79. package/package/animation/index.ts +2 -2
  80. package/package/formatColor/index.ts +2 -2
  81. package/package/getLoopColors/index.ts +2 -2
  82. package/package/getWebGLContext/index.ts +39 -39
  83. package/package/index.ts +76 -72
  84. package/package/move/index.ts +3 -0
  85. package/package/resizeObserver/index.ts +2 -2
  86. package/package/rotate/index.ts +2 -2
  87. package/package/ruler/index.ts +2 -2
  88. package/package/scale/index.ts +3 -0
  89. package/package/throttle/index.ts +2 -2
  90. package/package/viewHandler/index.ts +2 -2
  91. package/package.json +66 -66
  92. package/src/Canvas.ts +67 -67
  93. package/src/Eoap.ts +66 -66
  94. package/src/Geometry.ts +82 -82
  95. package/src/Matrix4/index.ts +76 -76
  96. package/src/Matrix4/move.ts +12 -12
  97. package/src/Matrix4/rotate.ts +15 -15
  98. package/src/Matrix4/scale.ts +11 -11
  99. package/src/Matrix4/transform.ts +64 -64
  100. package/src/Mercator.ts +27 -27
  101. package/src/SVG.ts +24 -24
  102. package/src/TreeLayout/index.ts +186 -186
  103. package/src/WebGL.ts +66 -66
  104. package/src/animation.ts +98 -98
  105. package/src/common/assemble.ts +22 -22
  106. package/src/common/canvas/arc.ts +50 -50
  107. package/src/common/canvas/config.ts +158 -158
  108. package/src/common/canvas/gradient.ts +29 -29
  109. package/src/common/canvas/index.ts +168 -168
  110. package/src/common/canvas/painter.ts +426 -426
  111. package/src/common/canvas/texts.ts +18 -18
  112. package/src/common/geometry/prism-horizontal.ts +33 -33
  113. package/src/common/geometry/prism-vertical.ts +40 -40
  114. package/src/common/geometry/sphere-fragment.ts +39 -39
  115. package/src/common/geometry/tool/circle.ts +11 -11
  116. package/src/common/mergeOption.ts +6 -6
  117. package/src/common/setStyle.ts +5 -5
  118. package/src/common/svg/config.ts +186 -174
  119. package/src/common/svg/gradient.ts +63 -0
  120. package/src/common/svg/index.ts +356 -344
  121. package/src/common/svg/tool.ts +44 -44
  122. package/src/common/tree/index.ts +25 -25
  123. package/src/common/tree/toInnerTree.ts +56 -56
  124. package/src/common/tree/toPlainTree.ts +131 -131
  125. package/src/common/webgl/buffer.ts +79 -79
  126. package/src/common/webgl/doDraw.ts +108 -108
  127. package/src/common/webgl/getColorFactory.ts +26 -26
  128. package/src/common/webgl/getShader.ts +48 -48
  129. package/src/common/webgl/getTexture.ts +11 -11
  130. package/src/common/webgl/getWebGLContext.ts +27 -27
  131. package/src/common/webgl/index.ts +223 -223
  132. package/src/common/webgl/shader.ts +75 -75
  133. package/src/common/webgl/texture.ts +96 -96
  134. package/src/formatColor.ts +44 -44
  135. package/src/getLoopColors.ts +42 -42
  136. package/src/interpolation/Cardinal.ts +110 -110
  137. package/src/interpolation/Hermite.ts +65 -65
  138. package/src/move.ts +8 -0
  139. package/src/resizeObserver.ts +36 -36
  140. package/src/rotate.ts +7 -7
  141. package/src/ruler.ts +188 -188
  142. package/src/scale.ts +7 -0
  143. package/src/shader/fsColor.c +7 -7
  144. package/src/shader/fsColors.c +7 -7
  145. package/src/shader/fsCube.c +8 -8
  146. package/src/shader/fsImage.c +8 -8
  147. package/src/shader/vsColor.c +17 -17
  148. package/src/shader/vsColors.c +13 -13
  149. package/src/shader/vsCube.c +13 -13
  150. package/src/shader/vsImage.c +13 -13
  151. package/src/throttle.ts +51 -51
  152. package/src/viewHandler.ts +158 -158
  153. package/types/Buffer.d.ts +23 -23
  154. package/types/Canvas.d.ts +300 -300
  155. package/types/CanvasConfig.d.ts +106 -106
  156. package/types/CanvasOption.d.ts +7 -7
  157. package/types/Cardinal.d.ts +13 -13
  158. package/types/Geometry.d.ts +40 -40
  159. package/types/GeometryOption.d.ts +11 -11
  160. package/types/GeometryResult.d.ts +18 -18
  161. package/types/Gradient.d.ts +14 -14
  162. package/types/Hermite.d.ts +18 -18
  163. package/types/Map.d.ts +9 -9
  164. package/types/Matrix4.d.ts +42 -42
  165. package/types/Object3D.d.ts +114 -114
  166. package/types/SVG.d.ts +238 -215
  167. package/types/SVGConfig.d.ts +76 -76
  168. package/types/Scene3D.d.ts +6 -6
  169. package/types/Shader.d.ts +21 -21
  170. package/types/Texture.d.ts +16 -16
  171. package/types/Tree.d.ts +69 -69
  172. package/types/TreeConfig.d.ts +24 -24
  173. package/types/TreeLayout.d.ts +54 -54
  174. package/types/TreeOption.d.ts +48 -48
  175. package/types/WebGL.d.ts +38 -38
  176. package/types/WebGLOption.d.ts +7 -7
  177. package/types/animation.d.ts +6 -6
  178. package/types/formatColor.d.ts +2 -2
  179. package/types/getLoopColors.d.ts +2 -2
  180. package/types/getWebGLContext.d.ts +2 -2
  181. package/types/index.d.ts +175 -169
  182. package/types/move.d.ts +3 -0
  183. package/types/painterConfig.d.ts +2 -2
  184. package/types/resizeObserver.d.ts +2 -2
  185. package/types/rotate.d.ts +2 -2
  186. package/types/ruler.d.ts +7 -7
  187. package/types/scale.d.ts +3 -0
  188. package/types/throttle.d.ts +4 -4
  189. package/types/throttleOption.d.ts +21 -21
  190. package/types/viewHandler.d.ts +13 -13
  191. package/uni-app/ui-canvas.vue +226 -226
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.5.2-alpha.1
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: Thu Oct 12 2023 15:44:35 GMT+0800 (China Standard Time)
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 initText = function (el, config, x, y, deg) {
121
- if (el.nodeName.toLowerCase() !== "text")
122
- throw new Error("Need a <text> !");
123
- setAttribute(el, "dy", {
124
- top: config["fontSize"] * 0.5,
125
- middle: 0,
126
- bottom: -config["fontSize"] * 0.5,
127
- }[config.textBaseline]);
128
- setStyle(el, {
129
- "text-anchor": {
130
- left: "start",
131
- right: "end",
132
- center: "middle",
133
- }[config.textAlign],
134
- "dominant-baseline": "central",
135
- "font-size": config["fontSize"] + "px",
136
- "font-family": config["fontFamily"],
137
- });
138
- setAttribute(el, "x", x);
139
- setAttribute(el, "y", y);
140
- if (typeof deg == "number") {
141
- deg = deg % 360;
142
- setAttribute(el, "transform", "rotate(" + deg + "," + x + "," + y + ")");
143
- }
144
- };
145
- var initCircle = function (el, cx, cy, r) {
146
- if (el.nodeName.toLowerCase() !== "circle")
147
- throw new Error("Need a <circle> !");
148
- setAttribute(el, "cx", cx);
149
- setAttribute(el, "cy", cy);
150
- setAttribute(el, "r", r);
151
- };
152
- var initPath = function (el, path) {
153
- if (el.nodeName.toLowerCase() !== "path")
154
- throw new Error("Need a <path> !");
155
- setAttribute(el, "d", path);
156
- };
157
- var initRect = function (el, x, y, width, height) {
158
- if (el.nodeName.toLowerCase() !== "rect")
159
- throw new Error("Need a <rect> !");
160
- if (height < 0) {
161
- height *= -1;
162
- y -= height;
163
- }
164
- if (width < 0) {
165
- width *= -1;
166
- x -= width;
167
- }
168
- setAttribute(el, "x", x);
169
- setAttribute(el, "y", y);
170
- setAttribute(el, "width", width);
171
- setAttribute(el, "height", height);
172
- };
173
- var initArc = function (el, config, cx, cy, r1, r2, beginDeg, deg) {
174
- if (el.nodeName.toLowerCase() !== "path")
175
- throw new Error("Need a <path> !");
176
- beginDeg = (beginDeg / 180) * Math.PI;
177
- deg = (deg / 180) * Math.PI;
178
- beginDeg = beginDeg % (Math.PI * 2);
179
- if (r1 > r2) {
180
- var temp = r1;
181
- r1 = r2;
182
- r2 = temp;
183
- }
184
- if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
185
- deg = Math.PI * 1.999999;
186
- }
187
- else {
188
- deg = deg % (Math.PI * 2);
189
- }
190
- arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
191
- var f = endA - beginA > Math.PI ? 1 : 0, d = "M" + begInnerX + " " + begInnerY;
192
- if (r < 0)
193
- r = -r;
194
- d +=
195
- "A" + r1 + " " + r1 + " 0 " + f + " 1 " + endInnerX + " " + endInnerY;
196
- if (config.arcEndCap == "round")
197
- d += "A" + r + " " + r + " " + " 0 1 0 " + endOuterX + " " + endOuterY;
198
- else if (config.arcEndCap == "-round")
199
- d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
200
- else
201
- d += "L" + endOuterX + " " + endOuterY;
202
- d +=
203
- "A" + r2 + " " + r2 + " 0 " + f + " 0 " + begOuterX + " " + begOuterY;
204
- if (config.arcStartCap == "round")
205
- d += "A" + r + " " + r + " " + " 0 1 0 " + begInnerX + " " + begInnerY;
206
- else if (config.arcStartCap == "-round")
207
- d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
208
- else
209
- d += "L" + begInnerX + " " + begInnerY;
210
- if (config.arcStartCap == "butt")
211
- d += "Z";
212
- setAttribute(el, "d", d);
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 oldAttrName = {
225
- "font-size": "fontSize",
226
- "font-family": "fontFamily",
227
- "arc-start-cap": "arcStartCap",
228
- "arc-end-cap": "arcEndCap",
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
- var SVG$1 = (function () {
231
- function SVG(svg) {
232
- this.name = "SVG";
233
- this.__config = {
234
- fillStyle: "#000",
235
- strokeStyle: "#000",
236
- lineWidth: 1,
237
- textAlign: "left",
238
- textBaseline: "middle",
239
- "fontSize": 16,
240
- "fontFamily": "sans-serif",
241
- "arcStartCap": "butt",
242
- "arcEndCap": "butt",
243
- lineDash: [],
244
- };
245
- this.__path = "";
246
- this.__currentPosition = [];
247
- this.__svg = svg;
248
- }
249
- SVG.prototype.config = function (params) {
250
- if (typeof params !== "object") {
251
- return this.__config[oldAttrName[params] || params];
252
- }
253
- else {
254
- for (var key in params) {
255
- var _key = oldAttrName[key] || key;
256
- this.__config[_key] = params[key];
257
- }
258
- }
259
- return this;
260
- };
261
- SVG.prototype.useEl = function (el) {
262
- this.__useEl = el;
263
- return this;
264
- };
265
- SVG.prototype.getEl = function () {
266
- return this.__useEl;
267
- };
268
- SVG.prototype.appendEl = function (el, context) {
269
- context = context || this.__svg;
270
- if (typeof el == "string")
271
- el = toNode(el);
272
- context.appendChild(el);
273
- this.__useEl = el;
274
- return this;
275
- };
276
- SVG.prototype.appendBoard = function (el, context) {
277
- var _el = el;
278
- if (typeof el == "string")
279
- _el =
280
- {
281
- text: "text",
282
- path: "path",
283
- arc: "path",
284
- circle: "circle",
285
- rect: "rect",
286
- }[el] || "";
287
- if (_el == "")
288
- throw new Error("Unsupported drawing method:" + el);
289
- return this.appendEl(_el, context);
290
- };
291
- SVG.prototype.remove = function () {
292
- if (!this.__useEl) {
293
- throw new Error("Currently, no node can be deleted.");
294
- }
295
- else {
296
- this.__useEl.parentNode.removeChild(this.__useEl);
297
- }
298
- return this;
299
- };
300
- SVG.prototype.attr = function (params) {
301
- if (!this.__useEl)
302
- throw new Error("Currently, no node can be modified or viewed.");
303
- if (typeof params !== "object") {
304
- return getAttribute(this.__useEl, params);
305
- }
306
- else {
307
- for (var key in params) {
308
- setAttribute(this.__useEl, key, params[key]);
309
- }
310
- return this;
311
- }
312
- };
313
- SVG.prototype.fillText = function (text, x, y, deg) {
314
- if (deg === void 0) { deg = 0; }
315
- initText(this.__useEl, this.__config, x, y, deg);
316
- this.__useEl.textContent = text;
317
- fill(this.__useEl, this.__config);
318
- return this;
319
- };
320
- SVG.prototype.strokeText = function (text, x, y, deg) {
321
- if (deg === void 0) { deg = 0; }
322
- initText(this.__useEl, this.__config, x, y, deg);
323
- this.__useEl.textContent = text;
324
- stroke(this.__useEl, this.__config);
325
- return this;
326
- };
327
- SVG.prototype.fullText = function (text, x, y, deg) {
328
- if (deg === void 0) { deg = 0; }
329
- initText(this.__useEl, this.__config, x, y, deg);
330
- this.__useEl.textContent = text;
331
- full(this.__useEl, this.__config);
332
- return this;
333
- };
334
- SVG.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
335
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
336
- fill(this.__useEl, this.__config);
337
- return this;
338
- };
339
- SVG.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
340
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
341
- stroke(this.__useEl, this.__config);
342
- return this;
343
- };
344
- SVG.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
345
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
346
- full(this.__useEl, this.__config);
347
- return this;
348
- };
349
- SVG.prototype.fillCircle = function (cx, cy, r) {
350
- initCircle(this.__useEl, cx, cy, r);
351
- fill(this.__useEl, this.__config);
352
- return this;
353
- };
354
- SVG.prototype.strokeCircle = function (cx, cy, r) {
355
- initCircle(this.__useEl, cx, cy, r);
356
- stroke(this.__useEl, this.__config);
357
- return this;
358
- };
359
- SVG.prototype.fullCircle = function (cx, cy, r) {
360
- initCircle(this.__useEl, cx, cy, r);
361
- full(this.__useEl, this.__config);
362
- return this;
363
- };
364
- SVG.prototype.fillRect = function (x, y, width, height) {
365
- initRect(this.__useEl, x, y, width, height);
366
- fill(this.__useEl, this.__config);
367
- return this;
368
- };
369
- SVG.prototype.strokeRect = function (x, y, width, height) {
370
- initRect(this.__useEl, x, y, width, height);
371
- stroke(this.__useEl, this.__config);
372
- return this;
373
- };
374
- SVG.prototype.fullRect = function (x, y, width, height) {
375
- initRect(this.__useEl, x, y, width, height);
376
- full(this.__useEl, this.__config);
377
- return this;
378
- };
379
- SVG.prototype.beginPath = function () {
380
- this.__currentPosition = [];
381
- this.__path = "";
382
- return this;
383
- };
384
- SVG.prototype.closePath = function () {
385
- this.__path += "Z";
386
- return this;
387
- };
388
- SVG.prototype.moveTo = function (x, y) {
389
- this.__currentPosition = [x, y];
390
- this.__path += "M" + x + " " + y;
391
- return this;
392
- };
393
- SVG.prototype.lineTo = function (x, y) {
394
- this.__currentPosition = [x, y];
395
- this.__path += (this.__path == "" ? "M" : "L") + x + " " + y;
396
- return this;
397
- };
398
- SVG.prototype.fill = function () {
399
- initPath(this.__useEl, this.__path);
400
- fill(this.__useEl, this.__config);
401
- return this;
402
- };
403
- SVG.prototype.stroke = function () {
404
- initPath(this.__useEl, this.__path);
405
- stroke(this.__useEl, this.__config);
406
- return this;
407
- };
408
- SVG.prototype.full = function () {
409
- initPath(this.__useEl, this.__path);
410
- full(this.__useEl, this.__config);
411
- return this;
412
- };
413
- SVG.prototype.arc = function (x, y, r, beginDeg, deg) {
414
- var begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y);
415
- var endPosition = rotate(x, y, ((beginDeg + deg) / 180) * Math.PI, x + r, y);
416
- if (this.__path == "") {
417
- this.__path += "M" + begPosition[0] + "," + begPosition[1];
418
- }
419
- else if (begPosition[0] != this.__currentPosition[0] ||
420
- begPosition[1] != this.__currentPosition[1]) {
421
- this.__path += "L" + begPosition[0] + "," + begPosition[1];
422
- }
423
- this.__path +=
424
- "A" +
425
- r +
426
- "," +
427
- r +
428
- " 0 " +
429
- (deg > 180 || deg < -180 ? 1 : 0) +
430
- "," +
431
- (deg > 0 ? 1 : 0) +
432
- " " +
433
- endPosition[0] +
434
- "," +
435
- endPosition[1];
436
- return this;
437
- };
438
- SVG.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
439
- this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y;
440
- return this;
441
- };
442
- SVG.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
443
- this.__path +=
444
- "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y;
445
- return this;
446
- };
447
- SVG.prototype.bind = function (eventType, callback) {
448
- this.__useEl.addEventListener(eventType, function (event) {
449
- callback.call(this, event, this);
450
- }, false);
451
- return this;
452
- };
453
- return SVG;
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;