vislite 0.1.1 → 0.2.0-alpha.8
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/AUTHORS.txt +6 -6
- package/CHANGELOG +20 -1
- package/LICENSE +20 -20
- package/README.md +53 -52
- package/lib/Canvas/index.umd.js +135 -46
- package/lib/Canvas/index.umd.min.js +7 -3
- package/lib/Cardinal/index.umd.js +6 -2
- package/lib/Cardinal/index.umd.min.js +6 -2
- package/lib/Eoap/index.umd.js +9 -5
- package/lib/Eoap/index.umd.min.js +6 -2
- package/lib/Hermite/index.umd.js +6 -2
- package/lib/Hermite/index.umd.min.js +6 -2
- package/lib/Matrix4/index.umd.js +6 -2
- package/lib/Matrix4/index.umd.min.js +6 -2
- package/lib/Mercator/index.umd.js +42 -0
- package/lib/Mercator/index.umd.min.js +15 -0
- package/lib/OralCanvas/index.es.js +124 -44
- package/lib/OralCanvas/index.es.min.js +7 -3
- package/lib/OralWebGL/index.es.js +568 -0
- package/lib/OralWebGL/index.es.min.js +15 -0
- package/lib/SVG/index.umd.js +16 -5
- package/lib/SVG/index.umd.min.js +7 -3
- package/lib/WebGL/index.umd.js +627 -0
- package/lib/WebGL/index.umd.min.js +15 -0
- package/lib/animation/index.umd.js +6 -2
- package/lib/animation/index.umd.min.js +6 -2
- package/lib/getLoopColors/index.umd.js +6 -2
- package/lib/getLoopColors/index.umd.min.js +6 -2
- package/lib/index.umd.js +1514 -862
- package/lib/index.umd.min.js +7 -3
- package/lib/rotate/index.umd.js +6 -2
- package/lib/rotate/index.umd.min.js +6 -2
- package/lib/ruler/index.umd.js +6 -2
- package/lib/ruler/index.umd.min.js +6 -2
- package/lib/viewHandler/index.umd.js +129 -0
- package/lib/viewHandler/index.umd.min.js +15 -0
- package/miniprogram/ui-canvas/index.js +21 -7
- 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/Canvas/index.ts +1 -1
- package/package/Cardinal/index.ts +2 -2
- package/package/Eoap/index.ts +2 -2
- package/package/Hermite/index.ts +2 -2
- package/package/Matrix4/index.ts +2 -2
- package/package/Mercator/index.ts +3 -0
- package/package/OralCanvas/index.ts +1 -1
- package/package/OralWebGL/index.ts +2 -0
- package/package/SVG/index.ts +2 -2
- package/package/WebGL/index.ts +2 -0
- package/package/animation/index.ts +2 -2
- package/package/getLoopColors/index.ts +2 -2
- package/package/index.ts +32 -9
- package/package/rotate/index.ts +2 -2
- package/package/ruler/index.ts +2 -2
- package/package/viewHandler/index.ts +3 -0
- package/package.json +11 -2
- package/src/Canvas.ts +10 -1
- package/src/Eoap.ts +5 -5
- 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 -0
- package/src/SVG.ts +1 -1
- package/src/WebGL.ts +53 -0
- package/src/animation.ts +99 -99
- package/src/common/assemble.ts +23 -0
- package/src/common/canvas/arc.ts +50 -50
- package/src/common/canvas/config.ts +7 -6
- package/src/common/canvas/index.ts +29 -28
- package/src/common/canvas/painter.ts +51 -8
- package/src/common/canvas/texts.ts +19 -0
- package/src/common/setStyle.ts +5 -5
- package/src/common/svg/config.ts +127 -126
- package/src/common/svg/index.ts +13 -3
- package/src/common/svg/tool.ts +43 -42
- package/src/common/webgl/buffer.ts +80 -0
- package/src/common/webgl/doDraw.ts +97 -0
- package/src/common/webgl/getColorFactory.ts +27 -0
- package/src/common/webgl/getShader.ts +70 -0
- package/src/common/webgl/getTexture.ts +12 -0
- package/src/common/webgl/getWebGLContext.ts +28 -0
- package/src/common/webgl/index.ts +213 -0
- package/src/common/webgl/shader.ts +76 -0
- package/src/common/webgl/texture.ts +100 -0
- package/src/getLoopColors.ts +42 -42
- package/src/interpolation/Cardinal.ts +91 -91
- package/src/interpolation/Hermite.ts +65 -65
- package/src/rotate.ts +7 -7
- package/src/ruler.ts +99 -99
- package/src/viewHandler.ts +140 -0
- package/types/Canvas.d.ts +220 -283
- package/types/CanvasConfig.d.ts +81 -0
- package/types/Cardinal.d.ts +13 -13
- package/types/Hermite.d.ts +18 -18
- package/types/Map.d.ts +10 -0
- package/types/Matrix4.d.ts +42 -42
- package/types/Object3D.d.ts +107 -0
- package/types/SVG.d.ts +210 -264
- package/types/SVGConfig.d.ts +59 -0
- package/types/Scene3D.d.ts +7 -0
- package/types/WebGL.d.ts +39 -0
- package/types/animation.d.ts +6 -6
- package/types/getLoopColors.d.ts +2 -2
- package/types/index.d.ts +70 -26
- package/types/rotate.d.ts +2 -2
- package/types/ruler.d.ts +2 -2
- package/types/viewHandler.d.ts +13 -0
- package/uni-app/ui-canvas.vue +111 -15
- package/types/Eoap.d.ts +0 -10
package/lib/index.umd.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.8
|
|
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
|
-
*
|
|
9
|
+
* 本版本系测试版本,请认真阅读下述说明再使用:
|
|
10
|
+
*
|
|
11
|
+
*【测试版本细则】
|
|
12
|
+
* alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
|
|
13
|
+
* beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
|
|
10
14
|
*/
|
|
11
15
|
(function (global, factory) {
|
|
12
16
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -14,446 +18,6 @@
|
|
|
14
18
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite = factory());
|
|
15
19
|
})(this, (function () { 'use strict';
|
|
16
20
|
|
|
17
|
-
/******************************************************************************
|
|
18
|
-
Copyright (c) Microsoft Corporation.
|
|
19
|
-
|
|
20
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
21
|
-
purpose with or without fee is hereby granted.
|
|
22
|
-
|
|
23
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
24
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
25
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
26
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
27
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
28
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
29
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
30
|
-
***************************************************************************** */
|
|
31
|
-
/* global Reflect, Promise */
|
|
32
|
-
|
|
33
|
-
var extendStatics = function(d, b) {
|
|
34
|
-
extendStatics = Object.setPrototypeOf ||
|
|
35
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
36
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
37
|
-
return extendStatics(d, b);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function __extends(d, b) {
|
|
41
|
-
if (typeof b !== "function" && b !== null)
|
|
42
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
43
|
-
extendStatics(d, b);
|
|
44
|
-
function __() { this.constructor = d; }
|
|
45
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var rotate$1 = function (cx, cy, deg, x, y) {
|
|
49
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
50
|
-
return [
|
|
51
|
-
+((x - cx) * cos - (y - cy) * sin + cx).toFixed(7),
|
|
52
|
-
+((x - cx) * sin + (y - cy) * cos + cy).toFixed(7)
|
|
53
|
-
];
|
|
54
|
-
};
|
|
55
|
-
function arc (beginA, rotateA, cx, cy, r1, r2, doback) {
|
|
56
|
-
if (rotateA < 0) {
|
|
57
|
-
beginA += rotateA;
|
|
58
|
-
rotateA *= -1;
|
|
59
|
-
}
|
|
60
|
-
var temp = [], p;
|
|
61
|
-
p = rotate$1(0, 0, beginA, r1, 0);
|
|
62
|
-
temp[0] = p[0];
|
|
63
|
-
temp[1] = p[1];
|
|
64
|
-
p = rotate$1(0, 0, rotateA, p[0], p[1]);
|
|
65
|
-
temp[2] = p[0];
|
|
66
|
-
temp[3] = p[1];
|
|
67
|
-
p = rotate$1(0, 0, beginA, r2, 0);
|
|
68
|
-
temp[4] = p[0];
|
|
69
|
-
temp[5] = p[1];
|
|
70
|
-
p = rotate$1(0, 0, rotateA, p[0], p[1]);
|
|
71
|
-
temp[6] = p[0];
|
|
72
|
-
temp[7] = p[1];
|
|
73
|
-
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);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var initText$1 = function (painter, config, x, y, deg) {
|
|
77
|
-
painter.beginPath();
|
|
78
|
-
painter.translate(x, y);
|
|
79
|
-
painter.rotate(deg);
|
|
80
|
-
painter.font = config['font-style'] + " " + config["font-weight"] + " " + config['font-size'] + "px " + config['font-family'];
|
|
81
|
-
return painter;
|
|
82
|
-
};
|
|
83
|
-
var initArc$1 = function (painter, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
84
|
-
if (r1 > r2) {
|
|
85
|
-
var temp = r1;
|
|
86
|
-
r1 = r2;
|
|
87
|
-
r2 = temp;
|
|
88
|
-
}
|
|
89
|
-
beginDeg = beginDeg % (Math.PI * 2);
|
|
90
|
-
if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
|
|
91
|
-
deg = Math.PI * 2;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
deg = deg % (Math.PI * 2);
|
|
95
|
-
}
|
|
96
|
-
arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
|
|
97
|
-
if (r < 0)
|
|
98
|
-
r = -r;
|
|
99
|
-
painter.beginPath();
|
|
100
|
-
painter.moveTo(begInnerX, begInnerY);
|
|
101
|
-
painter.arc(cx, cy, r1, beginA, endA, false);
|
|
102
|
-
if (config["arc-end-cap"] != 'round')
|
|
103
|
-
painter.lineTo(endOuterX, endOuterY);
|
|
104
|
-
else
|
|
105
|
-
painter.arc((endInnerX + endOuterX) * 0.5, (endInnerY + endOuterY) * 0.5, r, endA - Math.PI, endA, true);
|
|
106
|
-
painter.arc(cx, cy, r2, endA, beginA, true);
|
|
107
|
-
if (config["arc-start-cap"] != 'round')
|
|
108
|
-
painter.lineTo(begInnerX, begInnerY);
|
|
109
|
-
else
|
|
110
|
-
painter.arc((begInnerX + begOuterX) * 0.5, (begInnerY + begOuterY) * 0.5, r, beginA, beginA - Math.PI, true);
|
|
111
|
-
});
|
|
112
|
-
if (config["arc-start-cap"] == 'butt')
|
|
113
|
-
painter.closePath();
|
|
114
|
-
return painter;
|
|
115
|
-
};
|
|
116
|
-
var initCircle$1 = function (painter, cx, cy, r) {
|
|
117
|
-
painter.beginPath();
|
|
118
|
-
painter.moveTo(cx + r, cy);
|
|
119
|
-
painter.arc(cx, cy, r, 0, Math.PI * 2);
|
|
120
|
-
return painter;
|
|
121
|
-
};
|
|
122
|
-
var initRect$1 = function (painter, x, y, width, height) {
|
|
123
|
-
painter.beginPath();
|
|
124
|
-
painter.rect(x, y, width, height);
|
|
125
|
-
return painter;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
var Painter = (function () {
|
|
129
|
-
function Painter(canvas, opts, region) {
|
|
130
|
-
if (opts === void 0) { opts = {}; }
|
|
131
|
-
this.__region = null;
|
|
132
|
-
this.__specialConfig = {
|
|
133
|
-
"font-size": 16,
|
|
134
|
-
"font-family": "sans-serif",
|
|
135
|
-
"font-weight": 400,
|
|
136
|
-
"font-style": "normal",
|
|
137
|
-
"arc-start-cap": 'butt',
|
|
138
|
-
"arc-end-cap": 'butt'
|
|
139
|
-
};
|
|
140
|
-
this.__initConfig = {
|
|
141
|
-
"fillStyle": 'black',
|
|
142
|
-
"strokeStyle": 'black',
|
|
143
|
-
"lineWidth": 1,
|
|
144
|
-
"textAlign": 'left',
|
|
145
|
-
"textBaseline": 'middle',
|
|
146
|
-
"lineDash": [],
|
|
147
|
-
"shadowBlur": 0,
|
|
148
|
-
"shadowColor": "black"
|
|
149
|
-
};
|
|
150
|
-
this.painter = canvas.getContext("2d", opts);
|
|
151
|
-
this.__region = region;
|
|
152
|
-
this.painter.textBaseline = 'middle';
|
|
153
|
-
this.painter.textAlign = 'left';
|
|
154
|
-
}
|
|
155
|
-
Painter.prototype.useConfig = function (key, value) {
|
|
156
|
-
if (this.__region) {
|
|
157
|
-
if (['fillStyle', 'strokeStyle', 'shadowBlur', 'shadowColor'].indexOf(key) < 0) {
|
|
158
|
-
this.__region.useConfig(key, value);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (key == 'lineDash') {
|
|
162
|
-
if (this.painter.setLineDash)
|
|
163
|
-
this.painter.setLineDash(value);
|
|
164
|
-
}
|
|
165
|
-
else if (key in this.__specialConfig) {
|
|
166
|
-
this.__specialConfig[key] = value;
|
|
167
|
-
}
|
|
168
|
-
else if (key in this.__initConfig) {
|
|
169
|
-
this.painter[key] = value;
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
throw new Error('Illegal configuration item of painter : ' + key + " !");
|
|
173
|
-
}
|
|
174
|
-
return this;
|
|
175
|
-
};
|
|
176
|
-
Painter.prototype.fillText = function (text, x, y, deg) {
|
|
177
|
-
if (deg === void 0) { deg = 0; }
|
|
178
|
-
if (this.__region)
|
|
179
|
-
this.__region.fillText(text, x, y, deg);
|
|
180
|
-
this.painter.save();
|
|
181
|
-
initText$1(this.painter, this.__specialConfig, x, y, deg).fillText(text, 0, 0);
|
|
182
|
-
this.painter.restore();
|
|
183
|
-
return this;
|
|
184
|
-
};
|
|
185
|
-
Painter.prototype.strokeText = function (text, x, y, deg) {
|
|
186
|
-
if (deg === void 0) { deg = 0; }
|
|
187
|
-
if (this.__region)
|
|
188
|
-
this.__region.strokeText(text, x, y, deg);
|
|
189
|
-
this.painter.save();
|
|
190
|
-
initText$1(this.painter, this.__specialConfig, x, y, deg || 0).strokeText(text, 0, 0);
|
|
191
|
-
this.painter.restore();
|
|
192
|
-
return this;
|
|
193
|
-
};
|
|
194
|
-
Painter.prototype.fullText = function (text, x, y, deg) {
|
|
195
|
-
if (deg === void 0) { deg = 0; }
|
|
196
|
-
if (this.__region)
|
|
197
|
-
this.__region.fullText(text, x, y, deg);
|
|
198
|
-
this.painter.save();
|
|
199
|
-
initText$1(this.painter, this.__specialConfig, x, y, deg || 0);
|
|
200
|
-
this.painter.fillText(text, 0, 0);
|
|
201
|
-
this.painter.strokeText(text, 0, 0);
|
|
202
|
-
this.painter.restore();
|
|
203
|
-
return this;
|
|
204
|
-
};
|
|
205
|
-
Painter.prototype.beginPath = function () {
|
|
206
|
-
if (this.__region)
|
|
207
|
-
this.__region.beginPath();
|
|
208
|
-
this.painter.beginPath();
|
|
209
|
-
return this;
|
|
210
|
-
};
|
|
211
|
-
Painter.prototype.closePath = function () {
|
|
212
|
-
if (this.__region)
|
|
213
|
-
this.__region.closePath();
|
|
214
|
-
this.painter.closePath();
|
|
215
|
-
return this;
|
|
216
|
-
};
|
|
217
|
-
Painter.prototype.moveTo = function (x, y) {
|
|
218
|
-
if (this.__region)
|
|
219
|
-
this.__region.moveTo(x, y);
|
|
220
|
-
this.painter.moveTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
221
|
-
return this;
|
|
222
|
-
};
|
|
223
|
-
Painter.prototype.lineTo = function (x, y) {
|
|
224
|
-
if (this.__region)
|
|
225
|
-
this.__region.lineTo(x, y);
|
|
226
|
-
this.painter.lineTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
227
|
-
return this;
|
|
228
|
-
};
|
|
229
|
-
Painter.prototype.arc = function (x, y, r, beginDeg, deg) {
|
|
230
|
-
if (this.__region)
|
|
231
|
-
this.__region.arc(x, y, r, beginDeg, deg);
|
|
232
|
-
this.painter.arc(x, y, r, beginDeg, beginDeg + deg, deg < 0);
|
|
233
|
-
return this;
|
|
234
|
-
};
|
|
235
|
-
Painter.prototype.fill = function () {
|
|
236
|
-
if (this.__region)
|
|
237
|
-
this.__region.fill();
|
|
238
|
-
this.painter.fill();
|
|
239
|
-
return this;
|
|
240
|
-
};
|
|
241
|
-
Painter.prototype.stroke = function () {
|
|
242
|
-
if (this.__region)
|
|
243
|
-
this.__region.stroke();
|
|
244
|
-
this.painter.stroke();
|
|
245
|
-
return this;
|
|
246
|
-
};
|
|
247
|
-
Painter.prototype.full = function () {
|
|
248
|
-
if (this.__region)
|
|
249
|
-
this.__region.full();
|
|
250
|
-
this.painter.fill();
|
|
251
|
-
this.painter.stroke();
|
|
252
|
-
return this;
|
|
253
|
-
};
|
|
254
|
-
Painter.prototype.save = function () {
|
|
255
|
-
if (this.__region)
|
|
256
|
-
this.__region.save();
|
|
257
|
-
this.painter.save();
|
|
258
|
-
return this;
|
|
259
|
-
};
|
|
260
|
-
Painter.prototype.restore = function () {
|
|
261
|
-
if (this.__region)
|
|
262
|
-
this.__region.restore();
|
|
263
|
-
this.painter.restore();
|
|
264
|
-
return this;
|
|
265
|
-
};
|
|
266
|
-
Painter.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
267
|
-
if (this.__region)
|
|
268
|
-
this.__region.quadraticCurveTo(cpx, cpy, x, y);
|
|
269
|
-
this.painter.quadraticCurveTo(cpx, cpy, x, y);
|
|
270
|
-
return this;
|
|
271
|
-
};
|
|
272
|
-
Painter.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
273
|
-
if (this.__region)
|
|
274
|
-
this.__region.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
275
|
-
this.painter.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
276
|
-
return this;
|
|
277
|
-
};
|
|
278
|
-
Painter.prototype.clearRect = function (x, y, w, h) {
|
|
279
|
-
if (this.__region)
|
|
280
|
-
this.__region.clearRect(x, y, w, h);
|
|
281
|
-
this.painter.clearRect(x, y, w, h);
|
|
282
|
-
return this;
|
|
283
|
-
};
|
|
284
|
-
Painter.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
285
|
-
if (this.__region)
|
|
286
|
-
this.__region.fillArc(cx, cy, r1, r2, beginDeg, deg);
|
|
287
|
-
initArc$1(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).fill();
|
|
288
|
-
return this;
|
|
289
|
-
};
|
|
290
|
-
Painter.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
291
|
-
if (this.__region)
|
|
292
|
-
this.__region.strokeArc(cx, cy, r1, r2, beginDeg, deg);
|
|
293
|
-
initArc$1(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).stroke();
|
|
294
|
-
return this;
|
|
295
|
-
};
|
|
296
|
-
Painter.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
297
|
-
if (this.__region)
|
|
298
|
-
this.__region.fullArc(cx, cy, r1, r2, beginDeg, deg);
|
|
299
|
-
initArc$1(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg);
|
|
300
|
-
this.painter.fill();
|
|
301
|
-
this.painter.stroke();
|
|
302
|
-
return this;
|
|
303
|
-
};
|
|
304
|
-
Painter.prototype.fillCircle = function (cx, cy, r) {
|
|
305
|
-
if (this.__region)
|
|
306
|
-
this.__region.fillCircle(cx, cy, r);
|
|
307
|
-
initCircle$1(this.painter, cx, cy, r).fill();
|
|
308
|
-
return this;
|
|
309
|
-
};
|
|
310
|
-
Painter.prototype.strokeCircle = function (cx, cy, r) {
|
|
311
|
-
if (this.__region)
|
|
312
|
-
this.__region.strokeCircle(cx, cy, r);
|
|
313
|
-
initCircle$1(this.painter, cx, cy, r).stroke();
|
|
314
|
-
return this;
|
|
315
|
-
};
|
|
316
|
-
Painter.prototype.fullCircle = function (cx, cy, r) {
|
|
317
|
-
if (this.__region)
|
|
318
|
-
this.__region.fullCircle(cx, cy, r);
|
|
319
|
-
initCircle$1(this.painter, cx, cy, r);
|
|
320
|
-
this.painter.fill();
|
|
321
|
-
this.painter.stroke();
|
|
322
|
-
return this;
|
|
323
|
-
};
|
|
324
|
-
Painter.prototype.fillRect = function (x, y, width, height) {
|
|
325
|
-
if (this.__region)
|
|
326
|
-
this.__region.fillRect(x, y, width, height);
|
|
327
|
-
initRect$1(this.painter, x, y, width, height).fill();
|
|
328
|
-
return this;
|
|
329
|
-
};
|
|
330
|
-
Painter.prototype.strokeRect = function (x, y, width, height) {
|
|
331
|
-
if (this.__region)
|
|
332
|
-
this.__region.strokeRect(x, y, width, height);
|
|
333
|
-
initRect$1(this.painter, x, y, width, height).stroke();
|
|
334
|
-
return this;
|
|
335
|
-
};
|
|
336
|
-
Painter.prototype.fullRect = function (x, y, width, height) {
|
|
337
|
-
if (this.__region)
|
|
338
|
-
this.__region.fullRect(x, y, width, height);
|
|
339
|
-
initRect$1(this.painter, x, y, width, height);
|
|
340
|
-
this.painter.fill();
|
|
341
|
-
this.painter.stroke();
|
|
342
|
-
return this;
|
|
343
|
-
};
|
|
344
|
-
return Painter;
|
|
345
|
-
}());
|
|
346
|
-
|
|
347
|
-
var Canvas$1 = (function (_super) {
|
|
348
|
-
__extends(Canvas, _super);
|
|
349
|
-
function Canvas(ViewCanvas, RegionCanvas) {
|
|
350
|
-
var _this_1 = _super.call(this, ViewCanvas, {}, new Painter(RegionCanvas, {
|
|
351
|
-
willReadFrequently: true
|
|
352
|
-
})) || this;
|
|
353
|
-
_this_1.name = "Canvas";
|
|
354
|
-
_this_1.__regionList = {};
|
|
355
|
-
_this_1.__rgb = [0, 0, 0];
|
|
356
|
-
_this_1.__p = 'r';
|
|
357
|
-
_this_1.setRegion("");
|
|
358
|
-
return _this_1;
|
|
359
|
-
}
|
|
360
|
-
Canvas.prototype.config = function (configs) {
|
|
361
|
-
for (var key in configs) {
|
|
362
|
-
this.useConfig(key, configs[key]);
|
|
363
|
-
}
|
|
364
|
-
return this;
|
|
365
|
-
};
|
|
366
|
-
Canvas.prototype.setRegion = function (regionName) {
|
|
367
|
-
var _this = this;
|
|
368
|
-
if (regionName) {
|
|
369
|
-
if (this.__regionList[regionName] == undefined) {
|
|
370
|
-
this.__regionList[regionName] = {
|
|
371
|
-
'r': function () {
|
|
372
|
-
_this.__rgb[0] += 1;
|
|
373
|
-
_this.__p = 'g';
|
|
374
|
-
return 'rgb(' + _this.__rgb[0] + ',' + _this.__rgb[1] + ',' + _this.__rgb[2] + ')';
|
|
375
|
-
},
|
|
376
|
-
'g': function () {
|
|
377
|
-
_this.__rgb[1] += 1;
|
|
378
|
-
_this.__p = 'b';
|
|
379
|
-
return 'rgb(' + _this.__rgb[0] + ',' + _this.__rgb[1] + ',' + _this.__rgb[2] + ')';
|
|
380
|
-
},
|
|
381
|
-
'b': function () {
|
|
382
|
-
_this.__rgb[2] += 1;
|
|
383
|
-
_this.__p = 'r';
|
|
384
|
-
return 'rgb(' + _this.__rgb[0] + ',' + _this.__rgb[1] + ',' + _this.__rgb[2] + ')';
|
|
385
|
-
}
|
|
386
|
-
}[this.__p]();
|
|
387
|
-
}
|
|
388
|
-
this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
|
|
389
|
-
this.__region.useConfig("strokeStyle", this.__regionList[regionName]);
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
this.__region.useConfig("fillStyle", "#000000") &&
|
|
393
|
-
this.__region.useConfig("strokeStyle", "#000000");
|
|
394
|
-
}
|
|
395
|
-
return this;
|
|
396
|
-
};
|
|
397
|
-
Canvas.prototype.getRegion = function (x, y) {
|
|
398
|
-
var _this_1 = this;
|
|
399
|
-
return new Promise(function (resolve, reject) {
|
|
400
|
-
var imgData = _this_1.__region.painter.getImageData(x - 0.5, y - 0.5, 1, 1);
|
|
401
|
-
var currentRGBA = imgData.data;
|
|
402
|
-
var doit = function () {
|
|
403
|
-
for (var key in _this_1.__regionList) {
|
|
404
|
-
if ("rgb(" + currentRGBA[0] + "," + currentRGBA[1] + "," + currentRGBA[2] + ")" == _this_1.__regionList[key]) {
|
|
405
|
-
resolve(key);
|
|
406
|
-
break;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
resolve("");
|
|
410
|
-
};
|
|
411
|
-
if (currentRGBA) {
|
|
412
|
-
doit();
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
imgData.then(function (data) {
|
|
416
|
-
currentRGBA = data;
|
|
417
|
-
doit();
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
};
|
|
422
|
-
return Canvas;
|
|
423
|
-
}(Painter));
|
|
424
|
-
|
|
425
|
-
var Canvas = (function (_super) {
|
|
426
|
-
__extends(Canvas, _super);
|
|
427
|
-
function Canvas(el) {
|
|
428
|
-
if (!el) {
|
|
429
|
-
throw new Error("VISLite Canvas:The mount point requires an HTMLElement type but encountered null.");
|
|
430
|
-
}
|
|
431
|
-
var width = el.clientWidth, height = el.clientHeight;
|
|
432
|
-
var ViewCanvas, RegionCanvas;
|
|
433
|
-
var _el = el;
|
|
434
|
-
if (_el._vislite_canvas_) {
|
|
435
|
-
ViewCanvas = _el._vislite_canvas_[0];
|
|
436
|
-
RegionCanvas = _el._vislite_canvas_[1];
|
|
437
|
-
}
|
|
438
|
-
else {
|
|
439
|
-
ViewCanvas = document.createElement('canvas');
|
|
440
|
-
el.appendChild(ViewCanvas);
|
|
441
|
-
RegionCanvas = document.createElement('canvas');
|
|
442
|
-
_el._vislite_canvas_ = [ViewCanvas, RegionCanvas];
|
|
443
|
-
el.setAttribute('vislite', 'inited');
|
|
444
|
-
}
|
|
445
|
-
for (var _i = 0, _a = [ViewCanvas, RegionCanvas]; _i < _a.length; _i++) {
|
|
446
|
-
var canvas = _a[_i];
|
|
447
|
-
canvas.style.width = width + "px";
|
|
448
|
-
canvas.setAttribute('width', width + "");
|
|
449
|
-
canvas.style.height = height + "px";
|
|
450
|
-
canvas.setAttribute('height', height + "");
|
|
451
|
-
}
|
|
452
|
-
return _super.call(this, ViewCanvas, RegionCanvas) || this;
|
|
453
|
-
}
|
|
454
|
-
return Canvas;
|
|
455
|
-
}(Canvas$1));
|
|
456
|
-
|
|
457
21
|
var Hermite = (function () {
|
|
458
22
|
function Hermite(u) {
|
|
459
23
|
if (u === void 0) { u = 0.5; }
|
|
@@ -494,117 +58,47 @@
|
|
|
494
58
|
function Cardinal(t) {
|
|
495
59
|
if (t === void 0) { t = 0; }
|
|
496
60
|
this.name = 'Cardinal';
|
|
497
|
-
this.__t = t;
|
|
498
|
-
}
|
|
499
|
-
Cardinal.prototype.setP = function (points) {
|
|
500
|
-
this.__HS = {
|
|
501
|
-
"x": [],
|
|
502
|
-
"h": []
|
|
503
|
-
};
|
|
504
|
-
var flag, slope = (points[1][1] - points[0][1]) / (points[1][0] - points[0][0]), temp;
|
|
505
|
-
this.__HS.x[0] = points[0][0];
|
|
506
|
-
for (flag = 1; flag < points.length; flag++) {
|
|
507
|
-
if (points[flag][0] <= points[flag - 1][0])
|
|
508
|
-
throw new Error('The point position should be increamented!');
|
|
509
|
-
this.__HS.x[flag] = points[flag][0];
|
|
510
|
-
temp = flag < points.length - 1 ?
|
|
511
|
-
(points[flag + 1][1] - points[flag - 1][1]) / (points[flag + 1][0] - points[flag - 1][0]) :
|
|
512
|
-
(points[flag][1] - points[flag - 1][1]) / (points[flag][0] - points[flag - 1][0]);
|
|
513
|
-
this.__HS.h[flag - 1] = new Hermite((1 - this.__t) * 0.5).setP(points[flag - 1][0], points[flag - 1][1], points[flag][0], points[flag][1], slope, temp);
|
|
514
|
-
slope = temp;
|
|
515
|
-
}
|
|
516
|
-
return this;
|
|
517
|
-
};
|
|
518
|
-
Cardinal.prototype.use = function (x) {
|
|
519
|
-
if (this.__HS) {
|
|
520
|
-
this.__i = -1;
|
|
521
|
-
while (this.__i + 1 < this.__HS.x.length && (x > this.__HS.x[this.__i + 1] || (this.__i == -1 && x >= this.__HS.x[this.__i + 1]))) {
|
|
522
|
-
this.__i += 1;
|
|
523
|
-
}
|
|
524
|
-
if (this.__i < 0) {
|
|
525
|
-
return this.__HS.h[0].use(this.__HS.x[0]);
|
|
526
|
-
}
|
|
527
|
-
else if (this.__i >= this.__HS.h.length) {
|
|
528
|
-
return this.__HS.h[this.__HS.h.length - 1].use(this.__HS.x[this.__HS.x.length - 1]);
|
|
529
|
-
}
|
|
530
|
-
return this.__HS.h[this.__i].use(x);
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
throw new Error('You shoud first set the position!');
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
return Cardinal;
|
|
537
|
-
}());
|
|
538
|
-
|
|
539
|
-
var rotateX = function (deg, x, y, z) {
|
|
540
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
541
|
-
return [x, y * cos - z * sin, y * sin + z * cos];
|
|
542
|
-
};
|
|
543
|
-
var rotateY = function (deg, x, y, z) {
|
|
544
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
545
|
-
return [z * sin + x * cos, y, z * cos - x * sin];
|
|
546
|
-
};
|
|
547
|
-
var rotateZ = function (deg, x, y, z) {
|
|
548
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
549
|
-
return [x * cos - y * sin, x * sin + y * cos, z];
|
|
550
|
-
};
|
|
551
|
-
var Eoap = (function () {
|
|
552
|
-
function Eoap(scale, center) {
|
|
553
|
-
if (scale === void 0) { scale = 7; }
|
|
554
|
-
if (center === void 0) { center = [107, 36]; }
|
|
555
|
-
this.name = 'Eoap';
|
|
556
|
-
this.__scale = scale;
|
|
557
|
-
this.__center = center;
|
|
558
|
-
}
|
|
559
|
-
Eoap.prototype.use = function (longitude, latitude) {
|
|
560
|
-
var p = rotateY((360 - latitude) / 180 * Math.PI, 100 * this.__scale, 0, 0);
|
|
561
|
-
p = rotateZ(longitude / 180 * Math.PI, p[0], p[1], p[2]);
|
|
562
|
-
p = rotateZ((90 - this.__center[0]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
563
|
-
p = rotateX((90 - this.__center[1]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
564
|
-
return [
|
|
565
|
-
-p[0],
|
|
566
|
-
p[1],
|
|
567
|
-
p[2]
|
|
568
|
-
];
|
|
569
|
-
};
|
|
570
|
-
return Eoap;
|
|
571
|
-
}());
|
|
572
|
-
|
|
573
|
-
function getLoopColors (num, alpha) {
|
|
574
|
-
if (alpha === void 0) { alpha = 1; }
|
|
575
|
-
var colorList = [
|
|
576
|
-
'rgba(84,112,198,' + alpha + ")", 'rgba(145,204,117,' + alpha + ")",
|
|
577
|
-
'rgba(250,200,88,' + alpha + ")", 'rgba(238,102,102,' + alpha + ")",
|
|
578
|
-
'rgba(115,192,222,' + alpha + ")", 'rgba(59,162,114,' + alpha + ")",
|
|
579
|
-
'rgba(252,132,82,' + alpha + ")", 'rgba(154,96,180,' + alpha + ")",
|
|
580
|
-
'rgba(234,124,204,' + alpha + ")"
|
|
581
|
-
];
|
|
582
|
-
var colors = [];
|
|
583
|
-
if (num <= colorList.length) {
|
|
584
|
-
return colorList;
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
if (num % colorList.length == 0) {
|
|
588
|
-
for (var i = 0; i < (num / colorList.length); i++) {
|
|
589
|
-
colors = colors.concat(colorList);
|
|
590
|
-
}
|
|
61
|
+
this.__t = t;
|
|
62
|
+
}
|
|
63
|
+
Cardinal.prototype.setP = function (points) {
|
|
64
|
+
this.__HS = {
|
|
65
|
+
"x": [],
|
|
66
|
+
"h": []
|
|
67
|
+
};
|
|
68
|
+
var flag, slope = (points[1][1] - points[0][1]) / (points[1][0] - points[0][0]), temp;
|
|
69
|
+
this.__HS.x[0] = points[0][0];
|
|
70
|
+
for (flag = 1; flag < points.length; flag++) {
|
|
71
|
+
if (points[flag][0] <= points[flag - 1][0])
|
|
72
|
+
throw new Error('The point position should be increamented!');
|
|
73
|
+
this.__HS.x[flag] = points[flag][0];
|
|
74
|
+
temp = flag < points.length - 1 ?
|
|
75
|
+
(points[flag + 1][1] - points[flag - 1][1]) / (points[flag + 1][0] - points[flag - 1][0]) :
|
|
76
|
+
(points[flag][1] - points[flag - 1][1]) / (points[flag][0] - points[flag - 1][0]);
|
|
77
|
+
this.__HS.h[flag - 1] = new Hermite((1 - this.__t) * 0.5).setP(points[flag - 1][0], points[flag - 1][1], points[flag][0], points[flag][1], slope, temp);
|
|
78
|
+
slope = temp;
|
|
591
79
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
80
|
+
return this;
|
|
81
|
+
};
|
|
82
|
+
Cardinal.prototype.use = function (x) {
|
|
83
|
+
if (this.__HS) {
|
|
84
|
+
this.__i = -1;
|
|
85
|
+
while (this.__i + 1 < this.__HS.x.length && (x > this.__HS.x[this.__i + 1] || (this.__i == -1 && x >= this.__HS.x[this.__i + 1]))) {
|
|
86
|
+
this.__i += 1;
|
|
595
87
|
}
|
|
596
|
-
if (
|
|
597
|
-
|
|
88
|
+
if (this.__i < 0) {
|
|
89
|
+
return this.__HS.h[0].use(this.__HS.x[0]);
|
|
598
90
|
}
|
|
599
|
-
else {
|
|
600
|
-
|
|
601
|
-
colors = colors.concat(colorList[k]);
|
|
602
|
-
}
|
|
91
|
+
else if (this.__i >= this.__HS.h.length) {
|
|
92
|
+
return this.__HS.h[this.__HS.h.length - 1].use(this.__HS.x[this.__HS.x.length - 1]);
|
|
603
93
|
}
|
|
94
|
+
return this.__HS.h[this.__i].use(x);
|
|
604
95
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
96
|
+
else {
|
|
97
|
+
throw new Error('You shoud first set the position!');
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return Cardinal;
|
|
101
|
+
}());
|
|
608
102
|
|
|
609
103
|
function _move (d, a, b, c) {
|
|
610
104
|
if (c === void 0) { c = 0; }
|
|
@@ -733,7 +227,7 @@
|
|
|
733
227
|
return Matrix4;
|
|
734
228
|
}());
|
|
735
229
|
|
|
736
|
-
function rotate (cx, cy, deg, x, y) {
|
|
230
|
+
function rotate$1 (cx, cy, deg, x, y) {
|
|
737
231
|
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
738
232
|
return [
|
|
739
233
|
(x - cx) * cos - (y - cy) * sin + cx,
|
|
@@ -741,6 +235,218 @@
|
|
|
741
235
|
];
|
|
742
236
|
}
|
|
743
237
|
|
|
238
|
+
function getLoopColors (num, alpha) {
|
|
239
|
+
if (alpha === void 0) { alpha = 1; }
|
|
240
|
+
var colorList = [
|
|
241
|
+
'rgba(84,112,198,' + alpha + ")", 'rgba(145,204,117,' + alpha + ")",
|
|
242
|
+
'rgba(250,200,88,' + alpha + ")", 'rgba(238,102,102,' + alpha + ")",
|
|
243
|
+
'rgba(115,192,222,' + alpha + ")", 'rgba(59,162,114,' + alpha + ")",
|
|
244
|
+
'rgba(252,132,82,' + alpha + ")", 'rgba(154,96,180,' + alpha + ")",
|
|
245
|
+
'rgba(234,124,204,' + alpha + ")"
|
|
246
|
+
];
|
|
247
|
+
var colors = [];
|
|
248
|
+
if (num <= colorList.length) {
|
|
249
|
+
return colorList;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
if (num % colorList.length == 0) {
|
|
253
|
+
for (var i = 0; i < (num / colorList.length); i++) {
|
|
254
|
+
colors = colors.concat(colorList);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
for (var j = 1; j < (num / colorList.length); j++) {
|
|
259
|
+
colors = colors.concat(colorList);
|
|
260
|
+
}
|
|
261
|
+
if (num % colorList.length == 1) {
|
|
262
|
+
colors = colors.concat(colorList[4]);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
for (var k = 0; k < num % colorList.length; k++) {
|
|
266
|
+
colors = colors.concat(colorList[k]);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return colors;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
var $timers = [];
|
|
275
|
+
var $interval = 13;
|
|
276
|
+
var $timerId;
|
|
277
|
+
function animation (doback, duration, callback) {
|
|
278
|
+
if (duration === void 0) { duration = 400; }
|
|
279
|
+
if (callback === void 0) { callback = function () { }; }
|
|
280
|
+
var clock = {
|
|
281
|
+
"timer": function (tick, duration, callback) {
|
|
282
|
+
if (!tick) {
|
|
283
|
+
throw new Error('Tick is required!');
|
|
284
|
+
}
|
|
285
|
+
var id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
|
|
286
|
+
$timers.push({
|
|
287
|
+
"id": id,
|
|
288
|
+
"createTime": new Date(),
|
|
289
|
+
"tick": tick,
|
|
290
|
+
"duration": duration,
|
|
291
|
+
"callback": callback
|
|
292
|
+
});
|
|
293
|
+
clock.start();
|
|
294
|
+
return id;
|
|
295
|
+
},
|
|
296
|
+
"start": function () {
|
|
297
|
+
if (!$timerId) {
|
|
298
|
+
$timerId = setInterval(clock.tick, $interval);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"tick": function () {
|
|
302
|
+
var createTime, flag, tick, callback, timer, duration, passTime, timers = $timers;
|
|
303
|
+
$timers = [];
|
|
304
|
+
$timers.length = 0;
|
|
305
|
+
for (flag = 0; flag < timers.length; flag++) {
|
|
306
|
+
timer = timers[flag];
|
|
307
|
+
createTime = timer.createTime;
|
|
308
|
+
tick = timer.tick;
|
|
309
|
+
duration = timer.duration;
|
|
310
|
+
callback = timer.callback;
|
|
311
|
+
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
312
|
+
passTime = passTime > 1 ? 1 : passTime;
|
|
313
|
+
tick(passTime);
|
|
314
|
+
if (passTime < 1 && timer.id) {
|
|
315
|
+
$timers.push(timer);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
callback(passTime);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if ($timers.length <= 0) {
|
|
322
|
+
clock.stop();
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
"stop": function () {
|
|
326
|
+
if ($timerId) {
|
|
327
|
+
clearInterval($timerId);
|
|
328
|
+
$timerId = null;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
var id = clock.timer(function (deep) {
|
|
333
|
+
doback(deep);
|
|
334
|
+
}, duration, callback);
|
|
335
|
+
return function () {
|
|
336
|
+
var i;
|
|
337
|
+
for (i in $timers) {
|
|
338
|
+
if ($timers[i].id == id) {
|
|
339
|
+
$timers[i].id = undefined;
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function ruler (maxValue, minValue, num) {
|
|
347
|
+
if (maxValue < minValue) {
|
|
348
|
+
var temp = minValue;
|
|
349
|
+
minValue = maxValue;
|
|
350
|
+
maxValue = temp;
|
|
351
|
+
}
|
|
352
|
+
else if (maxValue == minValue) {
|
|
353
|
+
return [maxValue];
|
|
354
|
+
}
|
|
355
|
+
var times100 = (function (_value) {
|
|
356
|
+
var _times100_base = (_value < 100 && _value > -100) ? 10 : 0.1;
|
|
357
|
+
var _times100 = -1, _tiemsValue = _value;
|
|
358
|
+
while (_times100_base == 10 ?
|
|
359
|
+
(_tiemsValue >= -100 && _tiemsValue <= 100)
|
|
360
|
+
:
|
|
361
|
+
(_tiemsValue <= -100 || _tiemsValue >= 100)) {
|
|
362
|
+
_times100 += 1;
|
|
363
|
+
_tiemsValue *= _times100_base;
|
|
364
|
+
}
|
|
365
|
+
if (_times100_base == 10) {
|
|
366
|
+
return Math.pow(10, _times100);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
var temp = "0.";
|
|
370
|
+
for (var i = 1; i < _times100; i++) {
|
|
371
|
+
temp += "0";
|
|
372
|
+
}
|
|
373
|
+
return +(temp + "1");
|
|
374
|
+
}
|
|
375
|
+
})(maxValue - minValue);
|
|
376
|
+
var distance100 = Math.ceil((maxValue - minValue) * times100 / num);
|
|
377
|
+
distance100 = {
|
|
378
|
+
3: 2,
|
|
379
|
+
4: 5,
|
|
380
|
+
6: 5,
|
|
381
|
+
7: 5,
|
|
382
|
+
8: 10,
|
|
383
|
+
9: 10,
|
|
384
|
+
11: 10,
|
|
385
|
+
12: 10,
|
|
386
|
+
13: 15,
|
|
387
|
+
14: 15,
|
|
388
|
+
16: 15,
|
|
389
|
+
17: 15,
|
|
390
|
+
18: 20,
|
|
391
|
+
19: 20,
|
|
392
|
+
21: 20,
|
|
393
|
+
22: 20,
|
|
394
|
+
23: 25,
|
|
395
|
+
24: 25,
|
|
396
|
+
26: 25,
|
|
397
|
+
27: 25
|
|
398
|
+
}[distance100] || distance100;
|
|
399
|
+
var distance = distance100 / times100;
|
|
400
|
+
var begin = Math.floor(minValue / distance) * distance;
|
|
401
|
+
var rulerArray = [];
|
|
402
|
+
rulerArray.push(begin);
|
|
403
|
+
for (var index = 1; rulerArray[rulerArray.length - 1] < maxValue; index++) {
|
|
404
|
+
rulerArray.push(begin + distance * index);
|
|
405
|
+
}
|
|
406
|
+
return rulerArray;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/******************************************************************************
|
|
410
|
+
Copyright (c) Microsoft Corporation.
|
|
411
|
+
|
|
412
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
413
|
+
purpose with or without fee is hereby granted.
|
|
414
|
+
|
|
415
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
416
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
417
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
418
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
419
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
420
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
421
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
422
|
+
***************************************************************************** */
|
|
423
|
+
/* global Reflect, Promise */
|
|
424
|
+
|
|
425
|
+
var extendStatics = function(d, b) {
|
|
426
|
+
extendStatics = Object.setPrototypeOf ||
|
|
427
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
428
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
429
|
+
return extendStatics(d, b);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
function __extends(d, b) {
|
|
433
|
+
if (typeof b !== "function" && b !== null)
|
|
434
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
435
|
+
extendStatics(d, b);
|
|
436
|
+
function __() { this.constructor = d; }
|
|
437
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function __spreadArray(to, from, pack) {
|
|
441
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
442
|
+
if (ar || !(i in from)) {
|
|
443
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
444
|
+
ar[i] = from[i];
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
448
|
+
}
|
|
449
|
+
|
|
744
450
|
var XLINK_ATTRIBUTE = ["href", "title", "show", "type", "role", "actuate"];
|
|
745
451
|
|
|
746
452
|
function toNode(tagname) {
|
|
@@ -780,7 +486,35 @@
|
|
|
780
486
|
}
|
|
781
487
|
}
|
|
782
488
|
|
|
783
|
-
var
|
|
489
|
+
var rotate = function (cx, cy, deg, x, y) {
|
|
490
|
+
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
491
|
+
return [
|
|
492
|
+
+((x - cx) * cos - (y - cy) * sin + cx).toFixed(7),
|
|
493
|
+
+((x - cx) * sin + (y - cy) * cos + cy).toFixed(7)
|
|
494
|
+
];
|
|
495
|
+
};
|
|
496
|
+
function arc (beginA, rotateA, cx, cy, r1, r2, doback) {
|
|
497
|
+
if (rotateA < 0) {
|
|
498
|
+
beginA += rotateA;
|
|
499
|
+
rotateA *= -1;
|
|
500
|
+
}
|
|
501
|
+
var temp = [], p;
|
|
502
|
+
p = rotate(0, 0, beginA, r1, 0);
|
|
503
|
+
temp[0] = p[0];
|
|
504
|
+
temp[1] = p[1];
|
|
505
|
+
p = rotate(0, 0, rotateA, p[0], p[1]);
|
|
506
|
+
temp[2] = p[0];
|
|
507
|
+
temp[3] = p[1];
|
|
508
|
+
p = rotate(0, 0, beginA, r2, 0);
|
|
509
|
+
temp[4] = p[0];
|
|
510
|
+
temp[5] = p[1];
|
|
511
|
+
p = rotate(0, 0, rotateA, p[0], p[1]);
|
|
512
|
+
temp[6] = p[0];
|
|
513
|
+
temp[7] = p[1];
|
|
514
|
+
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);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
var initText$1 = function (el, config, x, y, deg) {
|
|
784
518
|
if (el.nodeName.toLowerCase() !== 'text')
|
|
785
519
|
throw new Error('Need a <text> !');
|
|
786
520
|
setAttribute(el, "dy", {
|
|
@@ -805,7 +539,7 @@
|
|
|
805
539
|
setAttribute(el, "transform", "rotate(" + deg + "," + x + "," + y + ")");
|
|
806
540
|
}
|
|
807
541
|
};
|
|
808
|
-
var initCircle = function (el, cx, cy, r) {
|
|
542
|
+
var initCircle$1 = function (el, cx, cy, r) {
|
|
809
543
|
if (el.nodeName.toLowerCase() !== 'circle')
|
|
810
544
|
throw new Error('Need a <circle> !');
|
|
811
545
|
setAttribute(el, 'cx', cx);
|
|
@@ -817,7 +551,7 @@
|
|
|
817
551
|
throw new Error('Need a <path> !');
|
|
818
552
|
setAttribute(el, 'd', path);
|
|
819
553
|
};
|
|
820
|
-
var initRect = function (el, x, y, width, height) {
|
|
554
|
+
var initRect$1 = function (el, x, y, width, height) {
|
|
821
555
|
if (el.nodeName.toLowerCase() !== 'rect')
|
|
822
556
|
throw new Error('Need a <rect> !');
|
|
823
557
|
if (height < 0) {
|
|
@@ -828,420 +562,1338 @@
|
|
|
828
562
|
width *= -1;
|
|
829
563
|
x -= width;
|
|
830
564
|
}
|
|
831
|
-
setAttribute(el, 'x', x);
|
|
832
|
-
setAttribute(el, 'y', y);
|
|
833
|
-
setAttribute(el, 'width', width);
|
|
834
|
-
setAttribute(el, 'height', height);
|
|
565
|
+
setAttribute(el, 'x', x);
|
|
566
|
+
setAttribute(el, 'y', y);
|
|
567
|
+
setAttribute(el, 'width', width);
|
|
568
|
+
setAttribute(el, 'height', height);
|
|
569
|
+
};
|
|
570
|
+
var initArc$1 = function (el, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
571
|
+
if (el.nodeName.toLowerCase() !== 'path')
|
|
572
|
+
throw new Error('Need a <path> !');
|
|
573
|
+
beginDeg = beginDeg % (Math.PI * 2);
|
|
574
|
+
if (r1 > r2) {
|
|
575
|
+
var temp = r1;
|
|
576
|
+
r1 = r2;
|
|
577
|
+
r2 = temp;
|
|
578
|
+
}
|
|
579
|
+
if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
|
|
580
|
+
deg = Math.PI * 1.999999;
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
deg = deg % (Math.PI * 2);
|
|
584
|
+
}
|
|
585
|
+
arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
|
|
586
|
+
var f = (endA - beginA) > Math.PI ? 1 : 0, d = "M" + begInnerX + " " + begInnerY;
|
|
587
|
+
if (r < 0)
|
|
588
|
+
r = -r;
|
|
589
|
+
d +=
|
|
590
|
+
"A" + r1 + " " + r1 + " 0 " + f + " 1 " + endInnerX + " " + endInnerY;
|
|
591
|
+
if (config["arc-end-cap"] == 'round')
|
|
592
|
+
d += "A" + r + " " + r + " " + " 0 1 0 " + endOuterX + " " + endOuterY;
|
|
593
|
+
else if (config["arc-end-cap"] == '-round')
|
|
594
|
+
d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
|
|
595
|
+
else
|
|
596
|
+
d += "L" + endOuterX + " " + endOuterY;
|
|
597
|
+
d += "A" + r2 + " " + r2 + " 0 " + f + " 0 " + begOuterX + " " + begOuterY;
|
|
598
|
+
if (config["arc-start-cap"] == 'round')
|
|
599
|
+
d += "A" + r + " " + r + " " + " 0 1 0 " + begInnerX + " " + begInnerY;
|
|
600
|
+
else if (config["arc-start-cap"] == '-round')
|
|
601
|
+
d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
|
|
602
|
+
else
|
|
603
|
+
d += "L" + begInnerX + " " + begInnerY;
|
|
604
|
+
if (config["arc-start-cap"] == 'butt')
|
|
605
|
+
d += "Z";
|
|
606
|
+
setAttribute(el, 'd', d);
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
var oldAttrName$1 = {
|
|
611
|
+
"font-size": "fontSize",
|
|
612
|
+
"font-family": "fontFamily",
|
|
613
|
+
"arc-start-cap": "arcStartCap",
|
|
614
|
+
"arc-end-cap": "arcEndCap"
|
|
615
|
+
};
|
|
616
|
+
var SVG$1 = (function () {
|
|
617
|
+
function SVG(svg) {
|
|
618
|
+
this.name = "SVG";
|
|
619
|
+
this.__config = {
|
|
620
|
+
"fillStyle": "#000",
|
|
621
|
+
"strokeStyle": "#000",
|
|
622
|
+
"lineWidth": 1,
|
|
623
|
+
"textAlign": "left",
|
|
624
|
+
"textBaseline": "middle",
|
|
625
|
+
"font-size": 16,
|
|
626
|
+
"font-family": "sans-serif",
|
|
627
|
+
"arc-start-cap": "butt",
|
|
628
|
+
"arc-end-cap": "butt",
|
|
629
|
+
"lineDash": []
|
|
630
|
+
};
|
|
631
|
+
this.__path = "";
|
|
632
|
+
this.__currentPosition = [];
|
|
633
|
+
this.__svg = svg;
|
|
634
|
+
}
|
|
635
|
+
SVG.prototype.config = function (params) {
|
|
636
|
+
if (typeof params !== 'object') {
|
|
637
|
+
return this.__config[oldAttrName$1[params] || params];
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
for (var key in params) {
|
|
641
|
+
var _key = oldAttrName$1[key] || key;
|
|
642
|
+
this.__config[_key] = params[key];
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return this;
|
|
646
|
+
};
|
|
647
|
+
SVG.prototype.useEl = function (el) {
|
|
648
|
+
this.__useEl = el;
|
|
649
|
+
return this;
|
|
650
|
+
};
|
|
651
|
+
SVG.prototype.getEl = function () {
|
|
652
|
+
return this.__useEl;
|
|
653
|
+
};
|
|
654
|
+
SVG.prototype.appendEl = function (el, context) {
|
|
655
|
+
context = context || this.__svg;
|
|
656
|
+
if (typeof el == 'string')
|
|
657
|
+
el = toNode(el);
|
|
658
|
+
context.appendChild(el);
|
|
659
|
+
this.__useEl = el;
|
|
660
|
+
return this;
|
|
661
|
+
};
|
|
662
|
+
SVG.prototype.appendBoard = function (el, context) {
|
|
663
|
+
var _el = el;
|
|
664
|
+
if (typeof el == 'string')
|
|
665
|
+
_el = {
|
|
666
|
+
text: "text",
|
|
667
|
+
path: "path",
|
|
668
|
+
arc: "path",
|
|
669
|
+
circle: "circle",
|
|
670
|
+
rect: "rect"
|
|
671
|
+
}[el] || "";
|
|
672
|
+
if (_el == "")
|
|
673
|
+
throw new Error("Unsupported drawing method:" + el);
|
|
674
|
+
return this.appendEl(_el, context);
|
|
675
|
+
};
|
|
676
|
+
SVG.prototype.remove = function () {
|
|
677
|
+
if (!this.__useEl) {
|
|
678
|
+
throw new Error("Currently, no node can be deleted.");
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
this.__useEl.parentNode.removeChild(this.__useEl);
|
|
682
|
+
}
|
|
683
|
+
return this;
|
|
684
|
+
};
|
|
685
|
+
SVG.prototype.attr = function (params) {
|
|
686
|
+
if (!this.__useEl)
|
|
687
|
+
throw new Error("Currently, no node can be modified or viewed.");
|
|
688
|
+
if (typeof params !== 'object') {
|
|
689
|
+
return getAttribute(this.__useEl, params);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
for (var key in params) {
|
|
693
|
+
setAttribute(this.__useEl, key, params[key]);
|
|
694
|
+
}
|
|
695
|
+
return this;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
SVG.prototype.fillText = function (text, x, y, deg) {
|
|
699
|
+
if (deg === void 0) { deg = 0; }
|
|
700
|
+
initText$1(this.__useEl, this.__config, x, y, deg);
|
|
701
|
+
this.__useEl.textContent = text;
|
|
702
|
+
fill(this.__useEl, this.__config);
|
|
703
|
+
return this;
|
|
704
|
+
};
|
|
705
|
+
SVG.prototype.strokeText = function (text, x, y, deg) {
|
|
706
|
+
if (deg === void 0) { deg = 0; }
|
|
707
|
+
initText$1(this.__useEl, this.__config, x, y, deg);
|
|
708
|
+
this.__useEl.textContent = text;
|
|
709
|
+
stroke(this.__useEl, this.__config);
|
|
710
|
+
return this;
|
|
711
|
+
};
|
|
712
|
+
SVG.prototype.fullText = function (text, x, y, deg) {
|
|
713
|
+
if (deg === void 0) { deg = 0; }
|
|
714
|
+
initText$1(this.__useEl, this.__config, x, y, deg);
|
|
715
|
+
this.__useEl.textContent = text;
|
|
716
|
+
full(this.__useEl, this.__config);
|
|
717
|
+
return this;
|
|
718
|
+
};
|
|
719
|
+
SVG.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
720
|
+
initArc$1(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
|
|
721
|
+
fill(this.__useEl, this.__config);
|
|
722
|
+
return this;
|
|
723
|
+
};
|
|
724
|
+
SVG.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
725
|
+
initArc$1(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
|
|
726
|
+
stroke(this.__useEl, this.__config);
|
|
727
|
+
return this;
|
|
728
|
+
};
|
|
729
|
+
SVG.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
730
|
+
initArc$1(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
|
|
731
|
+
full(this.__useEl, this.__config);
|
|
732
|
+
return this;
|
|
733
|
+
};
|
|
734
|
+
SVG.prototype.fillCircle = function (cx, cy, r) {
|
|
735
|
+
initCircle$1(this.__useEl, cx, cy, r);
|
|
736
|
+
fill(this.__useEl, this.__config);
|
|
737
|
+
return this;
|
|
738
|
+
};
|
|
739
|
+
SVG.prototype.strokeCircle = function (cx, cy, r) {
|
|
740
|
+
initCircle$1(this.__useEl, cx, cy, r);
|
|
741
|
+
stroke(this.__useEl, this.__config);
|
|
742
|
+
return this;
|
|
743
|
+
};
|
|
744
|
+
SVG.prototype.fullCircle = function (cx, cy, r) {
|
|
745
|
+
initCircle$1(this.__useEl, cx, cy, r);
|
|
746
|
+
full(this.__useEl, this.__config);
|
|
747
|
+
return this;
|
|
748
|
+
};
|
|
749
|
+
SVG.prototype.fillRect = function (x, y, width, height) {
|
|
750
|
+
initRect$1(this.__useEl, x, y, width, height);
|
|
751
|
+
fill(this.__useEl, this.__config);
|
|
752
|
+
return this;
|
|
753
|
+
};
|
|
754
|
+
SVG.prototype.strokeRect = function (x, y, width, height) {
|
|
755
|
+
initRect$1(this.__useEl, x, y, width, height);
|
|
756
|
+
stroke(this.__useEl, this.__config);
|
|
757
|
+
return this;
|
|
758
|
+
};
|
|
759
|
+
SVG.prototype.fullRect = function (x, y, width, height) {
|
|
760
|
+
initRect$1(this.__useEl, x, y, width, height);
|
|
761
|
+
full(this.__useEl, this.__config);
|
|
762
|
+
return this;
|
|
763
|
+
};
|
|
764
|
+
SVG.prototype.beginPath = function () {
|
|
765
|
+
this.__currentPosition = [];
|
|
766
|
+
this.__path = "";
|
|
767
|
+
return this;
|
|
768
|
+
};
|
|
769
|
+
SVG.prototype.closePath = function () {
|
|
770
|
+
this.__path += "Z";
|
|
771
|
+
return this;
|
|
772
|
+
};
|
|
773
|
+
SVG.prototype.moveTo = function (x, y) {
|
|
774
|
+
this.__currentPosition = [x, y];
|
|
775
|
+
this.__path += "M" + x + " " + y;
|
|
776
|
+
return this;
|
|
777
|
+
};
|
|
778
|
+
SVG.prototype.lineTo = function (x, y) {
|
|
779
|
+
this.__currentPosition = [x, y];
|
|
780
|
+
this.__path += (this.__path == "" ? "M" : "L") + x + " " + y;
|
|
781
|
+
return this;
|
|
782
|
+
};
|
|
783
|
+
SVG.prototype.fill = function () {
|
|
784
|
+
initPath(this.__useEl, this.__path);
|
|
785
|
+
fill(this.__useEl, this.__config);
|
|
786
|
+
return this;
|
|
787
|
+
};
|
|
788
|
+
SVG.prototype.stroke = function () {
|
|
789
|
+
initPath(this.__useEl, this.__path);
|
|
790
|
+
stroke(this.__useEl, this.__config);
|
|
791
|
+
return this;
|
|
792
|
+
};
|
|
793
|
+
SVG.prototype.full = function () {
|
|
794
|
+
initPath(this.__useEl, this.__path);
|
|
795
|
+
full(this.__useEl, this.__config);
|
|
796
|
+
return this;
|
|
797
|
+
};
|
|
798
|
+
SVG.prototype.arc = function (x, y, r, beginDeg, deg) {
|
|
799
|
+
var begPosition = rotate$1(x, y, beginDeg, x + r, y);
|
|
800
|
+
var endPosition = rotate$1(x, y, beginDeg + deg, x + r, y);
|
|
801
|
+
beginDeg = beginDeg / Math.PI * 180;
|
|
802
|
+
deg = deg / Math.PI * 180;
|
|
803
|
+
if (this.__path == '') {
|
|
804
|
+
this.__path += "M" + begPosition[0] + "," + begPosition[1];
|
|
805
|
+
}
|
|
806
|
+
else if (begPosition[0] != this.__currentPosition[0] || begPosition[1] != this.__currentPosition[1]) {
|
|
807
|
+
this.__path += "L" + begPosition[0] + "," + begPosition[1];
|
|
808
|
+
}
|
|
809
|
+
this.__path += "A" + r + "," + r + " 0 " + ((deg > 180 || deg < -180) ? 1 : 0) + "," + (deg > 0 ? 1 : 0) + " " + endPosition[0] + "," + endPosition[1];
|
|
810
|
+
return this;
|
|
811
|
+
};
|
|
812
|
+
SVG.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
813
|
+
this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y;
|
|
814
|
+
return this;
|
|
815
|
+
};
|
|
816
|
+
SVG.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
817
|
+
this.__path += "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y;
|
|
818
|
+
return this;
|
|
819
|
+
};
|
|
820
|
+
return SVG;
|
|
821
|
+
}());
|
|
822
|
+
|
|
823
|
+
var SVG = (function (_super) {
|
|
824
|
+
__extends(SVG, _super);
|
|
825
|
+
function SVG(el) {
|
|
826
|
+
if (!el) {
|
|
827
|
+
throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");
|
|
828
|
+
}
|
|
829
|
+
var width = el.clientWidth, height = el.clientHeight;
|
|
830
|
+
var ViewSVG = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
|
|
831
|
+
el.appendChild(ViewSVG);
|
|
832
|
+
ViewSVG.setAttribute("width", width + "");
|
|
833
|
+
ViewSVG.setAttribute("height", height + "");
|
|
834
|
+
ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height);
|
|
835
|
+
return _super.call(this, ViewSVG) || this;
|
|
836
|
+
}
|
|
837
|
+
return SVG;
|
|
838
|
+
}(SVG$1));
|
|
839
|
+
|
|
840
|
+
var initText = function (painter, config, x, y, deg) {
|
|
841
|
+
painter.beginPath();
|
|
842
|
+
painter.translate(x, y);
|
|
843
|
+
painter.rotate(deg);
|
|
844
|
+
painter.font = config.fontStyle + " " + config.fontWeight + " " + config.fontSize + "px " + config.fontFamily;
|
|
845
|
+
return painter;
|
|
835
846
|
};
|
|
836
|
-
var initArc = function (
|
|
837
|
-
if (el.nodeName.toLowerCase() !== 'path')
|
|
838
|
-
throw new Error('Need a <path> !');
|
|
839
|
-
beginDeg = beginDeg % (Math.PI * 2);
|
|
847
|
+
var initArc = function (painter, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
840
848
|
if (r1 > r2) {
|
|
841
849
|
var temp = r1;
|
|
842
850
|
r1 = r2;
|
|
843
851
|
r2 = temp;
|
|
844
852
|
}
|
|
853
|
+
beginDeg = beginDeg % (Math.PI * 2);
|
|
845
854
|
if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
|
|
846
|
-
deg = Math.PI *
|
|
855
|
+
deg = Math.PI * 2;
|
|
847
856
|
}
|
|
848
857
|
else {
|
|
849
858
|
deg = deg % (Math.PI * 2);
|
|
850
859
|
}
|
|
851
860
|
arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
|
|
852
|
-
var f = (endA - beginA) > Math.PI ? 1 : 0, d = "M" + begInnerX + " " + begInnerY;
|
|
853
861
|
if (r < 0)
|
|
854
862
|
r = -r;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
|
|
863
|
+
painter.beginPath();
|
|
864
|
+
painter.moveTo(begInnerX, begInnerY);
|
|
865
|
+
painter.arc(cx, cy, r1, beginA, endA, false);
|
|
866
|
+
if (config.arcEndCap != 'round')
|
|
867
|
+
painter.lineTo(endOuterX, endOuterY);
|
|
861
868
|
else
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
if (config
|
|
865
|
-
|
|
866
|
-
else if (config["arc-start-cap"] == '-round')
|
|
867
|
-
d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
|
|
869
|
+
painter.arc((endInnerX + endOuterX) * 0.5, (endInnerY + endOuterY) * 0.5, r, endA - Math.PI, endA, true);
|
|
870
|
+
painter.arc(cx, cy, r2, endA, beginA, true);
|
|
871
|
+
if (config.arcStartCap != 'round')
|
|
872
|
+
painter.lineTo(begInnerX, begInnerY);
|
|
868
873
|
else
|
|
869
|
-
|
|
870
|
-
if (config["arc-start-cap"] == 'butt')
|
|
871
|
-
d += "Z";
|
|
872
|
-
setAttribute(el, 'd', d);
|
|
874
|
+
painter.arc((begInnerX + begOuterX) * 0.5, (begInnerY + begOuterY) * 0.5, r, beginA, beginA - Math.PI, true);
|
|
873
875
|
});
|
|
876
|
+
if (config.arcStartCap == 'butt')
|
|
877
|
+
painter.closePath();
|
|
878
|
+
return painter;
|
|
879
|
+
};
|
|
880
|
+
var initCircle = function (painter, cx, cy, r) {
|
|
881
|
+
painter.beginPath();
|
|
882
|
+
painter.moveTo(cx + r, cy);
|
|
883
|
+
painter.arc(cx, cy, r, 0, Math.PI * 2);
|
|
884
|
+
return painter;
|
|
885
|
+
};
|
|
886
|
+
var initRect = function (painter, x, y, width, height) {
|
|
887
|
+
painter.beginPath();
|
|
888
|
+
painter.rect(x, y, width, height);
|
|
889
|
+
return painter;
|
|
874
890
|
};
|
|
875
891
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
892
|
+
function texts (painter, contents, width, height, doback) {
|
|
893
|
+
var lineNumber = 0, content = "";
|
|
894
|
+
for (var i = 0; i < contents.length; i++) {
|
|
895
|
+
if (painter.measureText(content + contents[i]).width > width) {
|
|
896
|
+
lineNumber += 1;
|
|
897
|
+
doback(content, (lineNumber - 0.5) * height);
|
|
898
|
+
content = contents[i];
|
|
899
|
+
}
|
|
900
|
+
else if (i == contents.length - 1) {
|
|
901
|
+
lineNumber += 1;
|
|
902
|
+
doback(content + contents[i], (lineNumber - 0.5) * height);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
content += contents[i];
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return lineNumber * height;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
var Painter = (function () {
|
|
912
|
+
function Painter(canvas, opts, region) {
|
|
913
|
+
if (opts === void 0) { opts = {}; }
|
|
914
|
+
this.__region = null;
|
|
915
|
+
this.__specialConfig = {
|
|
916
|
+
"fontSize": 16,
|
|
917
|
+
"fontFamily": "sans-serif",
|
|
918
|
+
"fontWeight": 400,
|
|
919
|
+
"fontStyle": "normal",
|
|
920
|
+
"arcStartCap": 'butt',
|
|
921
|
+
"arcEndCap": 'butt'
|
|
922
|
+
};
|
|
923
|
+
this.__initConfig = {
|
|
924
|
+
"fillStyle": 'black',
|
|
925
|
+
"strokeStyle": 'black',
|
|
882
926
|
"lineWidth": 1,
|
|
883
|
-
"textAlign":
|
|
884
|
-
"textBaseline":
|
|
885
|
-
"
|
|
886
|
-
"
|
|
887
|
-
"
|
|
888
|
-
"arc-end-cap": "butt",
|
|
889
|
-
"lineDash": []
|
|
927
|
+
"textAlign": 'left',
|
|
928
|
+
"textBaseline": 'middle',
|
|
929
|
+
"lineDash": [],
|
|
930
|
+
"shadowBlur": 0,
|
|
931
|
+
"shadowColor": "black"
|
|
890
932
|
};
|
|
891
|
-
this.
|
|
892
|
-
this.
|
|
893
|
-
this.
|
|
933
|
+
this.painter = canvas.getContext("2d", opts);
|
|
934
|
+
this.__region = region;
|
|
935
|
+
this.painter.textBaseline = 'middle';
|
|
936
|
+
this.painter.textAlign = 'left';
|
|
894
937
|
}
|
|
895
|
-
|
|
896
|
-
if (
|
|
897
|
-
|
|
938
|
+
Painter.prototype.useConfig = function (key, value) {
|
|
939
|
+
if (this.__region) {
|
|
940
|
+
if (['fillStyle', 'strokeStyle', 'shadowBlur', 'shadowColor'].indexOf(key) < 0) {
|
|
941
|
+
this.__region.useConfig(key, value);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
if (key == 'lineDash') {
|
|
945
|
+
if (this.painter.setLineDash)
|
|
946
|
+
this.painter.setLineDash(value);
|
|
947
|
+
}
|
|
948
|
+
else if (key in this.__specialConfig) {
|
|
949
|
+
this.__specialConfig[key] = value;
|
|
950
|
+
}
|
|
951
|
+
else if (key in this.__initConfig) {
|
|
952
|
+
this.painter[key] = value;
|
|
898
953
|
}
|
|
899
954
|
else {
|
|
900
|
-
|
|
901
|
-
this.__config[key] = params[key];
|
|
902
|
-
}
|
|
955
|
+
throw new Error('Illegal configuration item of painter : ' + key + " !");
|
|
903
956
|
}
|
|
904
957
|
return this;
|
|
905
958
|
};
|
|
906
|
-
|
|
907
|
-
|
|
959
|
+
Painter.prototype.fillText = function (text, x, y, deg) {
|
|
960
|
+
if (deg === void 0) { deg = 0; }
|
|
961
|
+
if (this.__region)
|
|
962
|
+
this.__region.fillText(text, x, y, deg);
|
|
963
|
+
this.painter.save();
|
|
964
|
+
initText(this.painter, this.__specialConfig, x, y, deg).fillText(text, 0, 0);
|
|
965
|
+
this.painter.restore();
|
|
908
966
|
return this;
|
|
909
967
|
};
|
|
910
|
-
|
|
911
|
-
|
|
968
|
+
Painter.prototype.strokeText = function (text, x, y, deg) {
|
|
969
|
+
if (deg === void 0) { deg = 0; }
|
|
970
|
+
if (this.__region)
|
|
971
|
+
this.__region.strokeText(text, x, y, deg);
|
|
972
|
+
this.painter.save();
|
|
973
|
+
initText(this.painter, this.__specialConfig, x, y, deg).strokeText(text, 0, 0);
|
|
974
|
+
this.painter.restore();
|
|
975
|
+
return this;
|
|
912
976
|
};
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
if (
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
this.
|
|
977
|
+
Painter.prototype.fullText = function (text, x, y, deg) {
|
|
978
|
+
if (deg === void 0) { deg = 0; }
|
|
979
|
+
if (this.__region)
|
|
980
|
+
this.__region.fullText(text, x, y, deg);
|
|
981
|
+
this.painter.save();
|
|
982
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
983
|
+
this.painter.fillText(text, 0, 0);
|
|
984
|
+
this.painter.strokeText(text, 0, 0);
|
|
985
|
+
this.painter.restore();
|
|
919
986
|
return this;
|
|
920
987
|
};
|
|
921
|
-
|
|
922
|
-
var
|
|
923
|
-
if (
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
return
|
|
988
|
+
Painter.prototype.fillTexts = function (contents, x, y, width, lineHeight, deg) {
|
|
989
|
+
var _this = this;
|
|
990
|
+
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
991
|
+
if (deg === void 0) { deg = 0; }
|
|
992
|
+
if (this.__region)
|
|
993
|
+
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
994
|
+
this.painter.save();
|
|
995
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
996
|
+
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
997
|
+
_this.painter.fillText(content, 0, top);
|
|
998
|
+
});
|
|
999
|
+
this.painter.restore();
|
|
1000
|
+
return height;
|
|
934
1001
|
};
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
this.
|
|
941
|
-
|
|
1002
|
+
Painter.prototype.strokeTexts = function (contents, x, y, width, lineHeight, deg) {
|
|
1003
|
+
var _this = this;
|
|
1004
|
+
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
1005
|
+
if (deg === void 0) { deg = 0; }
|
|
1006
|
+
if (this.__region)
|
|
1007
|
+
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1008
|
+
this.painter.save();
|
|
1009
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
1010
|
+
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
1011
|
+
_this.painter.strokeText(content, 0, top);
|
|
1012
|
+
});
|
|
1013
|
+
this.painter.restore();
|
|
1014
|
+
return height;
|
|
1015
|
+
};
|
|
1016
|
+
Painter.prototype.fullTexts = function (contents, x, y, width, lineHeight, deg) {
|
|
1017
|
+
var _this = this;
|
|
1018
|
+
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
1019
|
+
if (deg === void 0) { deg = 0; }
|
|
1020
|
+
if (this.__region)
|
|
1021
|
+
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1022
|
+
this.painter.save();
|
|
1023
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
1024
|
+
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
1025
|
+
_this.painter.fillText(content, 0, top);
|
|
1026
|
+
_this.painter.strokeText(content, 0, top);
|
|
1027
|
+
});
|
|
1028
|
+
this.painter.restore();
|
|
1029
|
+
return height;
|
|
1030
|
+
};
|
|
1031
|
+
Painter.prototype.beginPath = function () {
|
|
1032
|
+
if (this.__region)
|
|
1033
|
+
this.__region.beginPath();
|
|
1034
|
+
this.painter.beginPath();
|
|
1035
|
+
return this;
|
|
1036
|
+
};
|
|
1037
|
+
Painter.prototype.closePath = function () {
|
|
1038
|
+
if (this.__region)
|
|
1039
|
+
this.__region.closePath();
|
|
1040
|
+
this.painter.closePath();
|
|
1041
|
+
return this;
|
|
1042
|
+
};
|
|
1043
|
+
Painter.prototype.moveTo = function (x, y) {
|
|
1044
|
+
if (this.__region)
|
|
1045
|
+
this.__region.moveTo(x, y);
|
|
1046
|
+
this.painter.moveTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
1047
|
+
return this;
|
|
1048
|
+
};
|
|
1049
|
+
Painter.prototype.lineTo = function (x, y) {
|
|
1050
|
+
if (this.__region)
|
|
1051
|
+
this.__region.lineTo(x, y);
|
|
1052
|
+
this.painter.lineTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
1053
|
+
return this;
|
|
1054
|
+
};
|
|
1055
|
+
Painter.prototype.arc = function (x, y, r, beginDeg, deg) {
|
|
1056
|
+
if (this.__region)
|
|
1057
|
+
this.__region.arc(x, y, r, beginDeg, deg);
|
|
1058
|
+
this.painter.arc(x, y, r, beginDeg, beginDeg + deg, deg < 0);
|
|
1059
|
+
return this;
|
|
1060
|
+
};
|
|
1061
|
+
Painter.prototype.fill = function () {
|
|
1062
|
+
if (this.__region)
|
|
1063
|
+
this.__region.fill();
|
|
1064
|
+
this.painter.fill();
|
|
1065
|
+
return this;
|
|
1066
|
+
};
|
|
1067
|
+
Painter.prototype.stroke = function () {
|
|
1068
|
+
if (this.__region)
|
|
1069
|
+
this.__region.stroke();
|
|
1070
|
+
this.painter.stroke();
|
|
1071
|
+
return this;
|
|
1072
|
+
};
|
|
1073
|
+
Painter.prototype.full = function () {
|
|
1074
|
+
if (this.__region)
|
|
1075
|
+
this.__region.full();
|
|
1076
|
+
this.painter.fill();
|
|
1077
|
+
this.painter.stroke();
|
|
1078
|
+
return this;
|
|
1079
|
+
};
|
|
1080
|
+
Painter.prototype.save = function () {
|
|
1081
|
+
if (this.__region)
|
|
1082
|
+
this.__region.save();
|
|
1083
|
+
this.painter.save();
|
|
1084
|
+
return this;
|
|
1085
|
+
};
|
|
1086
|
+
Painter.prototype.restore = function () {
|
|
1087
|
+
if (this.__region)
|
|
1088
|
+
this.__region.restore();
|
|
1089
|
+
this.painter.restore();
|
|
942
1090
|
return this;
|
|
943
1091
|
};
|
|
944
|
-
|
|
945
|
-
if (
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
for (var key in params) {
|
|
952
|
-
setAttribute(this.__useEl, key, params[key]);
|
|
953
|
-
}
|
|
954
|
-
return this;
|
|
955
|
-
}
|
|
1092
|
+
Painter.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
1093
|
+
if (this.__region)
|
|
1094
|
+
this.__region.quadraticCurveTo(cpx, cpy, x, y);
|
|
1095
|
+
this.painter.quadraticCurveTo(cpx, cpy, x, y);
|
|
1096
|
+
return this;
|
|
956
1097
|
};
|
|
957
|
-
|
|
958
|
-
if (
|
|
959
|
-
|
|
960
|
-
this.
|
|
961
|
-
fill(this.__useEl, this.__config);
|
|
1098
|
+
Painter.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
1099
|
+
if (this.__region)
|
|
1100
|
+
this.__region.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
1101
|
+
this.painter.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
962
1102
|
return this;
|
|
963
1103
|
};
|
|
964
|
-
|
|
965
|
-
if (
|
|
966
|
-
|
|
967
|
-
this.
|
|
968
|
-
stroke(this.__useEl, this.__config);
|
|
1104
|
+
Painter.prototype.clearRect = function (x, y, w, h) {
|
|
1105
|
+
if (this.__region)
|
|
1106
|
+
this.__region.clearRect(x, y, w, h);
|
|
1107
|
+
this.painter.clearRect(x, y, w, h);
|
|
969
1108
|
return this;
|
|
970
1109
|
};
|
|
971
|
-
|
|
972
|
-
if (
|
|
973
|
-
|
|
974
|
-
this.
|
|
975
|
-
full(this.__useEl, this.__config);
|
|
1110
|
+
Painter.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
1111
|
+
if (this.__region)
|
|
1112
|
+
this.__region.fillArc(cx, cy, r1, r2, beginDeg, deg);
|
|
1113
|
+
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).fill();
|
|
976
1114
|
return this;
|
|
977
1115
|
};
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1116
|
+
Painter.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
1117
|
+
if (this.__region)
|
|
1118
|
+
this.__region.strokeArc(cx, cy, r1, r2, beginDeg, deg);
|
|
1119
|
+
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).stroke();
|
|
981
1120
|
return this;
|
|
982
1121
|
};
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1122
|
+
Painter.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
1123
|
+
if (this.__region)
|
|
1124
|
+
this.__region.fullArc(cx, cy, r1, r2, beginDeg, deg);
|
|
1125
|
+
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg);
|
|
1126
|
+
this.painter.fill();
|
|
1127
|
+
this.painter.stroke();
|
|
986
1128
|
return this;
|
|
987
1129
|
};
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1130
|
+
Painter.prototype.fillCircle = function (cx, cy, r) {
|
|
1131
|
+
if (this.__region)
|
|
1132
|
+
this.__region.fillCircle(cx, cy, r);
|
|
1133
|
+
initCircle(this.painter, cx, cy, r).fill();
|
|
991
1134
|
return this;
|
|
992
1135
|
};
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1136
|
+
Painter.prototype.strokeCircle = function (cx, cy, r) {
|
|
1137
|
+
if (this.__region)
|
|
1138
|
+
this.__region.strokeCircle(cx, cy, r);
|
|
1139
|
+
initCircle(this.painter, cx, cy, r).stroke();
|
|
996
1140
|
return this;
|
|
997
1141
|
};
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1142
|
+
Painter.prototype.fullCircle = function (cx, cy, r) {
|
|
1143
|
+
if (this.__region)
|
|
1144
|
+
this.__region.fullCircle(cx, cy, r);
|
|
1145
|
+
initCircle(this.painter, cx, cy, r);
|
|
1146
|
+
this.painter.fill();
|
|
1147
|
+
this.painter.stroke();
|
|
1001
1148
|
return this;
|
|
1002
1149
|
};
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1150
|
+
Painter.prototype.fillRect = function (x, y, width, height) {
|
|
1151
|
+
if (this.__region)
|
|
1152
|
+
this.__region.fillRect(x, y, width, height);
|
|
1153
|
+
initRect(this.painter, x, y, width, height).fill();
|
|
1006
1154
|
return this;
|
|
1007
1155
|
};
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1156
|
+
Painter.prototype.strokeRect = function (x, y, width, height) {
|
|
1157
|
+
if (this.__region)
|
|
1158
|
+
this.__region.strokeRect(x, y, width, height);
|
|
1159
|
+
initRect(this.painter, x, y, width, height).stroke();
|
|
1011
1160
|
return this;
|
|
1012
1161
|
};
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1162
|
+
Painter.prototype.fullRect = function (x, y, width, height) {
|
|
1163
|
+
if (this.__region)
|
|
1164
|
+
this.__region.fullRect(x, y, width, height);
|
|
1165
|
+
initRect(this.painter, x, y, width, height);
|
|
1166
|
+
this.painter.fill();
|
|
1167
|
+
this.painter.stroke();
|
|
1016
1168
|
return this;
|
|
1017
1169
|
};
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1170
|
+
return Painter;
|
|
1171
|
+
}());
|
|
1172
|
+
|
|
1173
|
+
function assemble (begin, end, step, count) {
|
|
1174
|
+
var val = [];
|
|
1175
|
+
for (var index = 0; index < count; index++)
|
|
1176
|
+
val[index] = begin;
|
|
1177
|
+
return function () {
|
|
1178
|
+
for (var i = 0; i < count; i++) {
|
|
1179
|
+
if (val[i] < end) {
|
|
1180
|
+
val[i] = +(val[i] + step).toFixed(7);
|
|
1181
|
+
break;
|
|
1182
|
+
}
|
|
1183
|
+
else if (i < count - 1) {
|
|
1184
|
+
val[i] = begin;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
return val;
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
var oldAttrName = {
|
|
1192
|
+
"font-size": "fontSize",
|
|
1193
|
+
"font-family": "fontFamily",
|
|
1194
|
+
"font-weight": "fontWeight",
|
|
1195
|
+
"font-style": "fontStyle",
|
|
1196
|
+
"arc-start-cap": "arcStartCap",
|
|
1197
|
+
"arc-end-cap": "arcEndCap"
|
|
1198
|
+
};
|
|
1199
|
+
var Canvas$1 = (function (_super) {
|
|
1200
|
+
__extends(Canvas, _super);
|
|
1201
|
+
function Canvas(ViewCanvas, RegionCanvas) {
|
|
1202
|
+
var _this = _super.call(this, ViewCanvas, {}, new Painter(RegionCanvas, {
|
|
1203
|
+
willReadFrequently: true
|
|
1204
|
+
})) || this;
|
|
1205
|
+
_this.name = "Canvas";
|
|
1206
|
+
_this.__regionList = {};
|
|
1207
|
+
_this.__regionAssemble = assemble(0, 255, 1, 3);
|
|
1208
|
+
_this.setRegion("");
|
|
1209
|
+
return _this;
|
|
1210
|
+
}
|
|
1211
|
+
Canvas.prototype.config = function (configs) {
|
|
1212
|
+
for (var key in configs) {
|
|
1213
|
+
var _key = oldAttrName[key] || key;
|
|
1214
|
+
this.useConfig(_key, configs[key]);
|
|
1215
|
+
}
|
|
1021
1216
|
return this;
|
|
1022
1217
|
};
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1218
|
+
Canvas.prototype.setRegion = function (regionName) {
|
|
1219
|
+
if (regionName) {
|
|
1220
|
+
if (this.__regionList[regionName] == undefined) {
|
|
1221
|
+
var tempColor = this.__regionAssemble();
|
|
1222
|
+
this.__regionList[regionName] = "rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")";
|
|
1223
|
+
}
|
|
1224
|
+
this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
|
|
1225
|
+
this.__region.useConfig("strokeStyle", this.__regionList[regionName]);
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
this.__region.useConfig("fillStyle", "#000000") &&
|
|
1229
|
+
this.__region.useConfig("strokeStyle", "#000000");
|
|
1230
|
+
}
|
|
1026
1231
|
return this;
|
|
1027
1232
|
};
|
|
1028
|
-
|
|
1029
|
-
|
|
1233
|
+
Canvas.prototype.getRegion = function (x, y) {
|
|
1234
|
+
var _this = this;
|
|
1235
|
+
return new Promise(function (resolve, reject) {
|
|
1236
|
+
var imgData = _this.__region.painter.getImageData(x - 0.5, y - 0.5, 1, 1);
|
|
1237
|
+
var currentRGBA = imgData.data;
|
|
1238
|
+
var doit = function () {
|
|
1239
|
+
for (var key in _this.__regionList) {
|
|
1240
|
+
if ("rgb(" + currentRGBA[0] + "," + currentRGBA[1] + "," + currentRGBA[2] + ")" == _this.__regionList[key]) {
|
|
1241
|
+
resolve(key);
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
resolve("");
|
|
1246
|
+
};
|
|
1247
|
+
if (currentRGBA) {
|
|
1248
|
+
doit();
|
|
1249
|
+
}
|
|
1250
|
+
else {
|
|
1251
|
+
imgData.then(function (data) {
|
|
1252
|
+
currentRGBA = data;
|
|
1253
|
+
doit();
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
};
|
|
1258
|
+
Canvas.prototype.getContext = function (isRegion) {
|
|
1259
|
+
if (isRegion === void 0) { isRegion = false; }
|
|
1260
|
+
return isRegion ? this.__region.painter : this.painter;
|
|
1261
|
+
};
|
|
1262
|
+
return Canvas;
|
|
1263
|
+
}(Painter));
|
|
1264
|
+
|
|
1265
|
+
var Canvas = (function (_super) {
|
|
1266
|
+
__extends(Canvas, _super);
|
|
1267
|
+
function Canvas(el) {
|
|
1268
|
+
var _this = this;
|
|
1269
|
+
if (!el) {
|
|
1270
|
+
throw new Error("VISLite Canvas:The mount point requires an HTMLElement type but encountered null.");
|
|
1271
|
+
}
|
|
1272
|
+
var width = el.clientWidth, height = el.clientHeight;
|
|
1273
|
+
var ViewCanvas, RegionCanvas;
|
|
1274
|
+
var _el = el;
|
|
1275
|
+
if (_el._vislite_canvas_) {
|
|
1276
|
+
ViewCanvas = _el._vislite_canvas_[0];
|
|
1277
|
+
RegionCanvas = _el._vislite_canvas_[1];
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
ViewCanvas = document.createElement('canvas');
|
|
1281
|
+
el.appendChild(ViewCanvas);
|
|
1282
|
+
RegionCanvas = document.createElement('canvas');
|
|
1283
|
+
_el._vislite_canvas_ = [ViewCanvas, RegionCanvas];
|
|
1284
|
+
el.setAttribute('vislite', 'Canvas');
|
|
1285
|
+
}
|
|
1286
|
+
for (var _i = 0, _a = [ViewCanvas, RegionCanvas]; _i < _a.length; _i++) {
|
|
1287
|
+
var canvas = _a[_i];
|
|
1288
|
+
canvas.style.width = width + "px";
|
|
1289
|
+
canvas.setAttribute('width', width + "");
|
|
1290
|
+
canvas.style.height = height + "px";
|
|
1291
|
+
canvas.setAttribute('height', height + "");
|
|
1292
|
+
}
|
|
1293
|
+
_this = _super.call(this, ViewCanvas, RegionCanvas) || this;
|
|
1294
|
+
_this.__canvas = ViewCanvas;
|
|
1295
|
+
return _this;
|
|
1296
|
+
}
|
|
1297
|
+
Canvas.prototype.toDataURL = function () {
|
|
1298
|
+
var _this = this;
|
|
1299
|
+
return new Promise(function (resolve) {
|
|
1300
|
+
resolve(_this.__canvas.toDataURL());
|
|
1301
|
+
});
|
|
1302
|
+
};
|
|
1303
|
+
return Canvas;
|
|
1304
|
+
}(Canvas$1));
|
|
1305
|
+
|
|
1306
|
+
function getWebGLContext (canvas, scale, opts) {
|
|
1307
|
+
if (opts === void 0) { opts = {}; }
|
|
1308
|
+
var names = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], painter = null;
|
|
1309
|
+
for (var i = 0; i < names.length; i++) {
|
|
1310
|
+
try {
|
|
1311
|
+
painter = canvas.getContext(names[i], opts);
|
|
1312
|
+
}
|
|
1313
|
+
catch (e) { }
|
|
1314
|
+
if (painter)
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
if (!painter)
|
|
1318
|
+
throw new Error('Non canvas or browser does not support webgl.');
|
|
1319
|
+
var width = painter.canvas.width, height = painter.canvas.height;
|
|
1320
|
+
var viewWidth = width * scale;
|
|
1321
|
+
var viewHeight = height * scale;
|
|
1322
|
+
painter.viewport((width - viewWidth) * 0.5, (height - viewHeight) * 0.5, viewWidth, viewHeight);
|
|
1323
|
+
painter.depthFunc(painter.LEQUAL);
|
|
1324
|
+
painter.enable(painter.DEPTH_TEST);
|
|
1325
|
+
return painter;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
function getColorFactory (painter) {
|
|
1329
|
+
var width = painter.drawingBufferWidth, height = painter.drawingBufferHeight;
|
|
1330
|
+
var pixels = new Uint8Array(4 * width * height);
|
|
1331
|
+
painter.readPixels(0, 0, width, height, painter.RGBA, painter.UNSIGNED_BYTE, pixels);
|
|
1332
|
+
return function (x, y) {
|
|
1333
|
+
y = height - y;
|
|
1334
|
+
var pixelR = pixels[4 * (y * width + x)];
|
|
1335
|
+
var pixelG = pixels[4 * (y * width + x) + 1];
|
|
1336
|
+
var pixelB = pixels[4 * (y * width + x) + 2];
|
|
1337
|
+
var pixelA = pixels[4 * (y * width + x) + 3];
|
|
1338
|
+
return "rgba(" + pixelR + "," + pixelG + "," + pixelB + "," + pixelA + ")";
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
var newBuffer = function (painter) {
|
|
1343
|
+
return painter.createBuffer();
|
|
1344
|
+
};
|
|
1345
|
+
var writeBuffer = function (painter, data, isElement, usage) {
|
|
1346
|
+
var TYPE = isElement ? painter.ELEMENT_ARRAY_BUFFER : painter.ARRAY_BUFFER;
|
|
1347
|
+
painter.bufferData(TYPE, data, usage);
|
|
1348
|
+
};
|
|
1349
|
+
var useBuffer = function (painter, location, size, type, stride, offset, normalized) {
|
|
1350
|
+
painter.vertexAttribPointer(location, size, type, normalized, stride, offset);
|
|
1351
|
+
painter.enableVertexAttribArray(location);
|
|
1352
|
+
};
|
|
1353
|
+
var BufferObject = (function () {
|
|
1354
|
+
function BufferObject(painter, isElement) {
|
|
1355
|
+
if (isElement === void 0) { isElement = false; }
|
|
1356
|
+
this.__painter = painter;
|
|
1357
|
+
this.__isElement = isElement;
|
|
1358
|
+
this.__buffer = newBuffer(painter);
|
|
1359
|
+
this.__type = isElement ? painter.ELEMENT_ARRAY_BUFFER : painter.ARRAY_BUFFER;
|
|
1360
|
+
}
|
|
1361
|
+
BufferObject.prototype.use = function () {
|
|
1362
|
+
this.__painter.bindBuffer(this.__type, this.__buffer);
|
|
1030
1363
|
return this;
|
|
1031
1364
|
};
|
|
1032
|
-
|
|
1033
|
-
this.
|
|
1034
|
-
this.
|
|
1365
|
+
BufferObject.prototype.write = function (data) {
|
|
1366
|
+
writeBuffer(this.__painter, data, this.__isElement, this.__painter.STATIC_DRAW);
|
|
1367
|
+
this.__fsize = data.BYTES_PER_ELEMENT;
|
|
1035
1368
|
return this;
|
|
1036
1369
|
};
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
this.
|
|
1370
|
+
BufferObject.prototype.divide = function (location, size, stride, offset) {
|
|
1371
|
+
if (offset === void 0) { offset = 0; }
|
|
1372
|
+
useBuffer(this.__painter, location, size, this.__painter.FLOAT, stride * this.__fsize, offset * this.__fsize, false);
|
|
1040
1373
|
return this;
|
|
1041
1374
|
};
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1375
|
+
return BufferObject;
|
|
1376
|
+
}());
|
|
1377
|
+
|
|
1378
|
+
var initTexture = function (painter, type, unit) {
|
|
1379
|
+
var texture = painter.createTexture();
|
|
1380
|
+
if (type == painter.TEXTURE_2D) {
|
|
1381
|
+
painter.activeTexture(painter['TEXTURE' + unit]);
|
|
1382
|
+
}
|
|
1383
|
+
painter.bindTexture(type, texture);
|
|
1384
|
+
return texture;
|
|
1385
|
+
};
|
|
1386
|
+
var linkImage = function (painter, type, level, format, textureType, image) {
|
|
1387
|
+
painter.texImage2D(type, level, format, format, textureType, image);
|
|
1388
|
+
};
|
|
1389
|
+
var linkCube = function (painter, type, level, format, textureType, images, width, height, texture) {
|
|
1390
|
+
var types = [
|
|
1391
|
+
painter.TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
1392
|
+
painter.TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
1393
|
+
painter.TEXTURE_CUBE_MAP_POSITIVE_Y,
|
|
1394
|
+
painter.TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
1395
|
+
painter.TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
1396
|
+
painter.TEXTURE_CUBE_MAP_NEGATIVE_Z
|
|
1397
|
+
], target;
|
|
1398
|
+
for (var i = 0; i < types.length; i++) {
|
|
1399
|
+
if (images[i]) {
|
|
1400
|
+
target = types[i];
|
|
1401
|
+
painter.texImage2D(target, level, format, width, height, 0, format, textureType, null);
|
|
1402
|
+
painter.bindTexture(type, texture);
|
|
1403
|
+
painter.texImage2D(target, level, format, format, textureType, images[i]);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
painter.generateMipmap(type);
|
|
1407
|
+
};
|
|
1408
|
+
var TextureObject = (function () {
|
|
1409
|
+
function TextureObject(painter, type, unit) {
|
|
1410
|
+
if (unit === void 0) { unit = 0; }
|
|
1411
|
+
this.__painter = painter;
|
|
1412
|
+
this.__type = {
|
|
1413
|
+
"2d": painter.TEXTURE_2D,
|
|
1414
|
+
"cube": painter.TEXTURE_CUBE_MAP
|
|
1415
|
+
}[type];
|
|
1416
|
+
this.__texture = initTexture(painter, this.__type, unit);
|
|
1417
|
+
painter.texParameteri(this.__type, painter.TEXTURE_MIN_FILTER, painter.NEAREST);
|
|
1418
|
+
painter.texParameteri(this.__type, painter.TEXTURE_MAG_FILTER, painter.NEAREST);
|
|
1419
|
+
painter.texParameteri(this.__type, painter.TEXTURE_WRAP_S, painter.CLAMP_TO_EDGE);
|
|
1420
|
+
painter.texParameteri(this.__type, painter.TEXTURE_WRAP_T, painter.CLAMP_TO_EDGE);
|
|
1421
|
+
}
|
|
1422
|
+
TextureObject.prototype.useImage = function (image) {
|
|
1423
|
+
linkImage(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, image);
|
|
1045
1424
|
return this;
|
|
1046
1425
|
};
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
stroke(this.__useEl, this.__config);
|
|
1426
|
+
TextureObject.prototype.useCube = function (images, width, height) {
|
|
1427
|
+
linkCube(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, images, width, height, this.__texture);
|
|
1050
1428
|
return this;
|
|
1051
1429
|
};
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1430
|
+
return TextureObject;
|
|
1431
|
+
}());
|
|
1432
|
+
|
|
1433
|
+
var textures = {};
|
|
1434
|
+
function getTexture (type, painter, kind) {
|
|
1435
|
+
var uniqueName = type + "-" + kind;
|
|
1436
|
+
if (!textures[uniqueName]) {
|
|
1437
|
+
textures[uniqueName] = new TextureObject(painter, kind);
|
|
1438
|
+
}
|
|
1439
|
+
return textures[uniqueName];
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
var loadShader = function (painter, type, source) {
|
|
1443
|
+
var shader = painter.createShader(type);
|
|
1444
|
+
if (shader == null)
|
|
1445
|
+
throw new Error('Unable to create shader!');
|
|
1446
|
+
painter.shaderSource(shader, source);
|
|
1447
|
+
painter.compileShader(shader);
|
|
1448
|
+
if (!painter.getShaderParameter(shader, painter.COMPILE_STATUS))
|
|
1449
|
+
throw new Error('Failed to compile shader:' + painter.getShaderInfoLog(shader));
|
|
1450
|
+
return shader;
|
|
1451
|
+
};
|
|
1452
|
+
var useShader = function (painter, vshaderSource, fshaderSource) {
|
|
1453
|
+
var vertexShader = loadShader(painter, painter.VERTEX_SHADER, vshaderSource);
|
|
1454
|
+
var fragmentShader = loadShader(painter, painter.FRAGMENT_SHADER, fshaderSource);
|
|
1455
|
+
var glProgram = painter.createProgram();
|
|
1456
|
+
painter.attachShader(glProgram, vertexShader);
|
|
1457
|
+
painter.attachShader(glProgram, fragmentShader);
|
|
1458
|
+
painter.linkProgram(glProgram);
|
|
1459
|
+
if (!painter.getProgramParameter(glProgram, painter.LINK_STATUS))
|
|
1460
|
+
throw new Error('Failed to link program: ' + painter.getProgramInfoLog(glProgram));
|
|
1461
|
+
return glProgram;
|
|
1462
|
+
};
|
|
1463
|
+
var ShaderObject = (function () {
|
|
1464
|
+
function ShaderObject(painter) {
|
|
1465
|
+
this.__painter = painter;
|
|
1466
|
+
}
|
|
1467
|
+
ShaderObject.prototype.use = function () {
|
|
1468
|
+
this.__painter.useProgram(this.program);
|
|
1055
1469
|
return this;
|
|
1056
1470
|
};
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1471
|
+
ShaderObject.prototype.compile = function (vshaderSource, fshaderSource) {
|
|
1472
|
+
this.program = useShader(this.__painter, vshaderSource, fshaderSource);
|
|
1473
|
+
return this;
|
|
1474
|
+
};
|
|
1475
|
+
return ShaderObject;
|
|
1476
|
+
}());
|
|
1477
|
+
|
|
1478
|
+
var shaders = {};
|
|
1479
|
+
function getShader (type, painter, mesh) {
|
|
1480
|
+
var uniqueName = type +
|
|
1481
|
+
(mesh.geometry.attributes.normal ? "1" : "0") +
|
|
1482
|
+
(mesh.material.image ? "1" : "0") +
|
|
1483
|
+
(mesh.material.color ? "1" : "0") +
|
|
1484
|
+
(mesh.material.cube ? "1" : "0");
|
|
1485
|
+
if (shaders[uniqueName])
|
|
1486
|
+
return shaders[uniqueName].use();
|
|
1487
|
+
var vertexShader = "\n attribute vec4 a_position;\n\n ".concat(mesh.geometry.attributes.normal ? 'attribute vec4 a_normal;varying vec3 v_normal;' : '', "\n\n uniform mat4 u_matrix_world;\n uniform mat4 u_matrix_mesh;\n uniform mat4 u_matrix_proporion;\n\n ").concat(mesh.material.image ? 'attribute vec2 a_textcoord;varying vec2 v_textcoord;' : '', "\n\n void main(){\n vec4 temp = a_position;\n\n // \u5E94\u7528\u53D8\u6362\u77E9\u9635\uFF1A\u5C4F\u5E55\u6BD4\u8C03\u5E73\u77E9\u9635\u3001\u4E16\u754C\u77E9\u9635\u3001\u7269\u4F53\u77E9\u9635\n temp = u_matrix_proporion * u_matrix_world * u_matrix_mesh * temp;\n\n // \u628A\u539F\u751F\u7684WebGL\u4F7F\u7528\u7684\u5DE6\u624B\u5750\u6807\u7CFB\u53D8\u6210\u4E86\u53F3\u624B\u5750\u6807\u7CFB\n temp.z = -1.0 * temp.z;\n\n // \u8868\u793A\u773C\u775B\u8DDD\u79BBvec4(0.0,0.0,1.0)\u7684\u8DDD\u79BB\n float dist = 4.0;\n\n // \u4F7F\u7528\u6295\u5F71\u76F4\u63A5\u8BA1\u7B97\n // \u4E3A\u4FDD\u8BC1\u7EB9\u7406\u548C\u76F8\u5BF9\u4F4D\u7F6E\u6B63\u786E\n // x\u3001y\u3001z\u7684\u6539\u53D8\u6EE1\u8DB3\u7EBF\u6027\u53D8\u6362\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n ").concat(mesh.geometry.attributes.normal ? 'v_normal = normalize(vec3(a_normal));' : '', "\n ").concat(mesh.material.image ? 'v_textcoord = a_textcoord;' : '', "\n }\n ");
|
|
1488
|
+
var fragmentShader = "\n precision mediump float;\n\n ".concat(mesh.geometry.attributes.normal ? 'varying vec3 v_normal;' : '', "\n ").concat(mesh.material.color ? 'uniform vec4 u_color;' : '', "\n ").concat(mesh.material.cube ? 'uniform samplerCube u_texture;' : '', "\n ").concat(mesh.material.image ? 'uniform sampler2D u_sampler;varying vec2 v_textcoord;' : '', "\n\n void main(){\n ").concat(mesh.material.color ? 'gl_FragColor = u_color;' : '', "\n ").concat(mesh.material.cube ? 'gl_FragColor = textureCube(u_texture,normalize(v_normal));' : '', "\n ").concat(mesh.material.image ? 'gl_FragColor = texture2D(u_sampler,v_textcoord);' : '', "\n }\n ");
|
|
1489
|
+
var shader = new ShaderObject(painter).compile(vertexShader, fragmentShader).use();
|
|
1490
|
+
shaders[uniqueName] = shader;
|
|
1491
|
+
return shader;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
function doDraw (type, painter, mesh, meshWorld, globalWorld) {
|
|
1495
|
+
var shader = getShader(type, painter, mesh);
|
|
1496
|
+
new BufferObject(painter).use()
|
|
1497
|
+
.write(mesh.geometry.attributes.position.array)
|
|
1498
|
+
.divide(painter.getAttribLocation(shader.program, "a_position"), mesh.geometry.attributes.position.itemSize, 3, 0);
|
|
1499
|
+
painter.uniformMatrix4fv(painter.getUniformLocation(shader.program, "u_matrix_world"), false, globalWorld.matrix);
|
|
1500
|
+
painter.uniformMatrix4fv(painter.getUniformLocation(shader.program, "u_matrix_proporion"), false, globalWorld.proporion);
|
|
1501
|
+
painter.uniformMatrix4fv(painter.getUniformLocation(shader.program, "u_matrix_mesh"), false, meshWorld.matrix);
|
|
1502
|
+
if (mesh.geometry.attributes.normal) {
|
|
1503
|
+
new BufferObject(painter).use()
|
|
1504
|
+
.write(mesh.geometry.attributes.normal.array)
|
|
1505
|
+
.divide(painter.getAttribLocation(shader.program, "a_normal"), mesh.geometry.attributes.normal.itemSize, 3, 0);
|
|
1506
|
+
}
|
|
1507
|
+
if ("color" in mesh.material) {
|
|
1508
|
+
painter.uniform4f(painter.getUniformLocation(shader.program, "u_color"), mesh.material.color.r, mesh.material.color.g, mesh.material.color.b, mesh.material.color.alpha);
|
|
1509
|
+
}
|
|
1510
|
+
else if ("cube" in mesh.material) {
|
|
1511
|
+
var size = mesh.material.cube.right.image.value.width;
|
|
1512
|
+
getTexture(type, painter, 'cube').useCube([
|
|
1513
|
+
mesh.material.cube.right.image.value,
|
|
1514
|
+
mesh.material.cube.left.image.value,
|
|
1515
|
+
mesh.material.cube.top.image.value,
|
|
1516
|
+
mesh.material.cube.bottom.image.value,
|
|
1517
|
+
mesh.material.cube.far.image.value,
|
|
1518
|
+
mesh.material.cube.near.image.value
|
|
1519
|
+
], size, size);
|
|
1520
|
+
}
|
|
1521
|
+
else if ("image" in mesh.material) {
|
|
1522
|
+
painter.uniform1i(painter.getUniformLocation(shader.program, "u_sampler"), 0);
|
|
1523
|
+
new BufferObject(painter).use()
|
|
1524
|
+
.write(mesh.geometry.attributes.uv.array)
|
|
1525
|
+
.divide(painter.getAttribLocation(shader.program, "a_textcoord"), mesh.geometry.attributes.uv.itemSize, 2, 0);
|
|
1526
|
+
getTexture(type, painter, '2d').useImage(mesh.material.image.value);
|
|
1527
|
+
}
|
|
1528
|
+
if (mesh.geometry.index) {
|
|
1529
|
+
new BufferObject(painter, true).use()
|
|
1530
|
+
.write(mesh.geometry.index.array);
|
|
1531
|
+
painter.drawElements(painter[mesh.geometry.type], mesh.geometry.index.count, painter.UNSIGNED_BYTE, 0);
|
|
1532
|
+
}
|
|
1533
|
+
else {
|
|
1534
|
+
painter.drawArrays(painter[mesh.geometry.type], 0, mesh.geometry.attributes.position.count);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
var needUpdate = false;
|
|
1539
|
+
var scale = 10;
|
|
1540
|
+
var WebGL$1 = (function () {
|
|
1541
|
+
function WebGL(ViewCanvas, RegionCanvas) {
|
|
1542
|
+
this.name = "WebGL";
|
|
1543
|
+
this.__getColor = function (x, y) { return "rgba(0,0,0,1)"; };
|
|
1544
|
+
this.__regionList = {};
|
|
1545
|
+
this.__regionAssemble = assemble(0, 1, 0.2, 3);
|
|
1546
|
+
this.__regionName = "";
|
|
1547
|
+
this.__regionColor = [0, 0, 0, 1];
|
|
1548
|
+
this.__scene = {
|
|
1549
|
+
children: [],
|
|
1550
|
+
matrix: new Matrix4([
|
|
1551
|
+
1, 0, 0, 0,
|
|
1552
|
+
0, 1, 0, 0,
|
|
1553
|
+
0, 0, 1, 0,
|
|
1554
|
+
0, 0, 0, scale
|
|
1555
|
+
])
|
|
1556
|
+
};
|
|
1557
|
+
this.__unique = new Date().valueOf();
|
|
1558
|
+
this.painter = getWebGLContext(ViewCanvas, scale);
|
|
1559
|
+
this.__regionPainter = getWebGLContext(RegionCanvas, scale, {});
|
|
1560
|
+
var proportion = this.painter.canvas.width / this.painter.canvas.height;
|
|
1561
|
+
var xProportion = 1;
|
|
1562
|
+
var yProportion = 1;
|
|
1563
|
+
if (proportion > 1) {
|
|
1564
|
+
xProportion = 1 / proportion;
|
|
1064
1565
|
}
|
|
1065
|
-
else
|
|
1066
|
-
|
|
1566
|
+
else {
|
|
1567
|
+
yProportion = proportion;
|
|
1067
1568
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1569
|
+
var zProportion = Math.min(xProportion, yProportion);
|
|
1570
|
+
this.__proporion = [
|
|
1571
|
+
xProportion, 0, 0, 0,
|
|
1572
|
+
0, yProportion, 0, 0,
|
|
1573
|
+
0, 0, zProportion, 0,
|
|
1574
|
+
0, 0, 0, 1
|
|
1575
|
+
];
|
|
1576
|
+
}
|
|
1577
|
+
WebGL.prototype.matrix = function (initMatrix4) {
|
|
1578
|
+
return new Matrix4(initMatrix4);
|
|
1070
1579
|
};
|
|
1071
|
-
|
|
1072
|
-
this.
|
|
1073
|
-
return this;
|
|
1580
|
+
WebGL.prototype.getMatrix = function () {
|
|
1581
|
+
return this.__scene.matrix;
|
|
1074
1582
|
};
|
|
1075
|
-
|
|
1076
|
-
this.
|
|
1077
|
-
return this;
|
|
1583
|
+
WebGL.prototype.getObject3D = function () {
|
|
1584
|
+
return this.__scene.children;
|
|
1078
1585
|
};
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
function SVG(el) {
|
|
1085
|
-
if (!el) {
|
|
1086
|
-
throw new Error("VISLite SVG :The mount point requires an HTMLElement type but encountered null.");
|
|
1586
|
+
WebGL.prototype.review = function (isUpdateRegion) {
|
|
1587
|
+
if (isUpdateRegion === void 0) { isUpdateRegion = false; }
|
|
1588
|
+
if (isUpdateRegion) {
|
|
1589
|
+
this.__regionPainter.clearColor(1, 1, 1, 1);
|
|
1590
|
+
this.__regionPainter.clear(this.__regionPainter.COLOR_BUFFER_BIT);
|
|
1087
1591
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1592
|
+
else {
|
|
1593
|
+
this.painter.clearColor(1, 1, 1, 1);
|
|
1594
|
+
this.painter.clear(this.painter.COLOR_BUFFER_BIT);
|
|
1595
|
+
}
|
|
1596
|
+
for (var index = 0; index < this.__scene.children.length; index++) {
|
|
1597
|
+
this.draw(this.__scene.children[index], isUpdateRegion);
|
|
1598
|
+
}
|
|
1599
|
+
return this;
|
|
1600
|
+
};
|
|
1601
|
+
WebGL.prototype.draw = function (object3D, isUpdateRegion) {
|
|
1602
|
+
if (isUpdateRegion === void 0) { isUpdateRegion = false; }
|
|
1603
|
+
if (!isUpdateRegion)
|
|
1604
|
+
needUpdate = true;
|
|
1605
|
+
var meshWorld = {
|
|
1606
|
+
matrix: object3D.matrix.value()
|
|
1607
|
+
};
|
|
1608
|
+
var globalWorld = {
|
|
1609
|
+
matrix: this.__scene.matrix.value(),
|
|
1610
|
+
proporion: this.__proporion
|
|
1611
|
+
};
|
|
1612
|
+
this.setRegion(object3D.region);
|
|
1613
|
+
for (var index = 0; index < object3D.mesh.length; index++) {
|
|
1614
|
+
if (isUpdateRegion) {
|
|
1615
|
+
doDraw("painter" + this.__unique, this.__regionPainter, {
|
|
1616
|
+
geometry: object3D.mesh[index].geometry,
|
|
1617
|
+
material: {
|
|
1618
|
+
color: {
|
|
1619
|
+
r: this.__regionColor[0],
|
|
1620
|
+
g: this.__regionColor[1],
|
|
1621
|
+
b: this.__regionColor[2],
|
|
1622
|
+
alpha: this.__regionColor[3]
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}, meshWorld, globalWorld);
|
|
1626
|
+
this.__getColor = getColorFactory(this.__regionPainter);
|
|
1109
1627
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
"id": id,
|
|
1113
|
-
"createTime": new Date(),
|
|
1114
|
-
"tick": tick,
|
|
1115
|
-
"duration": duration,
|
|
1116
|
-
"callback": callback
|
|
1117
|
-
});
|
|
1118
|
-
clock.start();
|
|
1119
|
-
return id;
|
|
1120
|
-
},
|
|
1121
|
-
"start": function () {
|
|
1122
|
-
if (!$timerId) {
|
|
1123
|
-
$timerId = setInterval(clock.tick, $interval);
|
|
1628
|
+
else {
|
|
1629
|
+
doDraw("region" + this.__unique, this.painter, object3D.mesh[index], meshWorld, globalWorld);
|
|
1124
1630
|
}
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
1137
|
-
passTime = passTime > 1 ? 1 : passTime;
|
|
1138
|
-
tick(passTime);
|
|
1139
|
-
if (passTime < 1 && timer.id) {
|
|
1140
|
-
$timers.push(timer);
|
|
1141
|
-
}
|
|
1142
|
-
else {
|
|
1143
|
-
callback(passTime);
|
|
1144
|
-
}
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
WebGL.prototype.render = function (object3D) {
|
|
1634
|
+
if (!('matrix' in object3D))
|
|
1635
|
+
object3D.matrix = new Matrix4();
|
|
1636
|
+
if (!('region' in object3D))
|
|
1637
|
+
object3D.region = "";
|
|
1638
|
+
for (var index = 0; index < object3D.mesh.length; index++) {
|
|
1639
|
+
var mesh = object3D.mesh[index];
|
|
1640
|
+
if (mesh.geometry.attributes.normal && Array.isArray(mesh.geometry.attributes.normal.array)) {
|
|
1641
|
+
mesh.geometry.attributes.normal.array = new Float32Array(mesh.geometry.attributes.normal.array);
|
|
1145
1642
|
}
|
|
1146
|
-
if (
|
|
1147
|
-
|
|
1643
|
+
if (mesh.geometry.attributes.position && Array.isArray(mesh.geometry.attributes.position.array)) {
|
|
1644
|
+
mesh.geometry.attributes.position.array = new Float32Array(mesh.geometry.attributes.position.array);
|
|
1148
1645
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1646
|
+
if (mesh.geometry.attributes.uv && Array.isArray(mesh.geometry.attributes.uv.array)) {
|
|
1647
|
+
mesh.geometry.attributes.uv.array = new Float32Array(mesh.geometry.attributes.uv.array);
|
|
1648
|
+
}
|
|
1649
|
+
if (mesh.geometry.index && Array.isArray(mesh.geometry.index.array)) {
|
|
1650
|
+
mesh.geometry.index.array = new Uint8Array(mesh.geometry.index.array);
|
|
1154
1651
|
}
|
|
1155
1652
|
}
|
|
1653
|
+
this.__scene.children.push(object3D);
|
|
1654
|
+
this.draw(object3D);
|
|
1156
1655
|
};
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
for (i in $timers) {
|
|
1163
|
-
if ($timers[i].id == id) {
|
|
1164
|
-
$timers[i].id = undefined;
|
|
1165
|
-
return;
|
|
1656
|
+
WebGL.prototype.setRegion = function (regionName) {
|
|
1657
|
+
this.__regionName = regionName + "";
|
|
1658
|
+
if (regionName) {
|
|
1659
|
+
if (this.__regionList[regionName] == undefined) {
|
|
1660
|
+
this.__regionList[regionName] = __spreadArray(__spreadArray([], this.__regionAssemble(), true), [1], false);
|
|
1166
1661
|
}
|
|
1662
|
+
this.__regionColor = this.__regionList[regionName];
|
|
1167
1663
|
}
|
|
1664
|
+
else {
|
|
1665
|
+
this.__regionColor = [0, 0, 0, 1];
|
|
1666
|
+
}
|
|
1667
|
+
return this;
|
|
1168
1668
|
};
|
|
1169
|
-
|
|
1669
|
+
WebGL.prototype.getRegion = function (x, y) {
|
|
1670
|
+
var _this = this;
|
|
1671
|
+
if (needUpdate)
|
|
1672
|
+
this.review(true);
|
|
1673
|
+
needUpdate = false;
|
|
1674
|
+
return new Promise(function (resolve, reject) {
|
|
1675
|
+
var rgba = _this.__getColor(x, y);
|
|
1676
|
+
for (var key in _this.__regionList) {
|
|
1677
|
+
var currentRGBA = _this.__regionList[key];
|
|
1678
|
+
if ("rgba(" + currentRGBA[0] * 255 + "," + currentRGBA[1] * 255 + "," + currentRGBA[2] * 255 + "," + currentRGBA[3] * 255 + ")" == rgba) {
|
|
1679
|
+
resolve(key);
|
|
1680
|
+
break;
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
resolve("");
|
|
1684
|
+
});
|
|
1685
|
+
};
|
|
1686
|
+
return WebGL;
|
|
1687
|
+
}());
|
|
1170
1688
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1689
|
+
var WebGL = (function (_super) {
|
|
1690
|
+
__extends(WebGL, _super);
|
|
1691
|
+
function WebGL(el) {
|
|
1692
|
+
if (!el) {
|
|
1693
|
+
throw new Error("VISLite WebGL:The mount point requires an HTMLElement type but encountered null.");
|
|
1694
|
+
}
|
|
1695
|
+
var width = el.clientWidth, height = el.clientHeight;
|
|
1696
|
+
var ViewCanvas, RegionCanvas;
|
|
1697
|
+
var _el = el;
|
|
1698
|
+
if (_el._vislite_canvas_) {
|
|
1699
|
+
ViewCanvas = _el._vislite_canvas_[0];
|
|
1700
|
+
RegionCanvas = _el._vislite_canvas_[1];
|
|
1701
|
+
}
|
|
1702
|
+
else {
|
|
1703
|
+
RegionCanvas = document.createElement('canvas');
|
|
1704
|
+
el.appendChild(RegionCanvas);
|
|
1705
|
+
RegionCanvas.style.position = 'absolute';
|
|
1706
|
+
RegionCanvas.style.zIndex = "-1";
|
|
1707
|
+
ViewCanvas = document.createElement('canvas');
|
|
1708
|
+
el.appendChild(ViewCanvas);
|
|
1709
|
+
_el._vislite_canvas_ = [ViewCanvas, RegionCanvas];
|
|
1710
|
+
el.setAttribute('vislite', 'WebGL');
|
|
1711
|
+
}
|
|
1712
|
+
for (var _i = 0, _a = [ViewCanvas, RegionCanvas]; _i < _a.length; _i++) {
|
|
1713
|
+
var canvas = _a[_i];
|
|
1714
|
+
canvas.style.width = width + "px";
|
|
1715
|
+
canvas.setAttribute('width', width + "");
|
|
1716
|
+
canvas.style.height = height + "px";
|
|
1717
|
+
canvas.setAttribute('height', height + "");
|
|
1718
|
+
}
|
|
1719
|
+
return _super.call(this, ViewCanvas, RegionCanvas) || this;
|
|
1176
1720
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1721
|
+
return WebGL;
|
|
1722
|
+
}(WebGL$1));
|
|
1723
|
+
|
|
1724
|
+
var rotateX = function (deg, x, y, z) {
|
|
1725
|
+
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
1726
|
+
return [x, y * cos - z * sin, y * sin + z * cos];
|
|
1727
|
+
};
|
|
1728
|
+
var rotateY = function (deg, x, y, z) {
|
|
1729
|
+
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
1730
|
+
return [z * sin + x * cos, y, z * cos - x * sin];
|
|
1731
|
+
};
|
|
1732
|
+
var rotateZ = function (deg, x, y, z) {
|
|
1733
|
+
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
1734
|
+
return [x * cos - y * sin, x * sin + y * cos, z];
|
|
1735
|
+
};
|
|
1736
|
+
var Eoap = (function () {
|
|
1737
|
+
function Eoap(scale, center) {
|
|
1738
|
+
if (scale === void 0) { scale = 7; }
|
|
1739
|
+
if (center === void 0) { center = [107, 36]; }
|
|
1740
|
+
this.name = 'Eoap';
|
|
1741
|
+
this.__scale = scale;
|
|
1742
|
+
this.__center = center;
|
|
1179
1743
|
}
|
|
1180
|
-
|
|
1181
|
-
var
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1744
|
+
Eoap.prototype.use = function (λ, φ) {
|
|
1745
|
+
var p = rotateY((360 - φ) / 180 * Math.PI, 100 * this.__scale, 0, 0);
|
|
1746
|
+
p = rotateZ(λ / 180 * Math.PI, p[0], p[1], p[2]);
|
|
1747
|
+
p = rotateZ((90 - this.__center[0]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
1748
|
+
p = rotateX((90 - this.__center[1]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
1749
|
+
return [
|
|
1750
|
+
-p[0],
|
|
1751
|
+
p[1],
|
|
1752
|
+
p[2]
|
|
1753
|
+
];
|
|
1754
|
+
};
|
|
1755
|
+
return Eoap;
|
|
1756
|
+
}());
|
|
1757
|
+
|
|
1758
|
+
var Mercator = (function () {
|
|
1759
|
+
function Mercator(scale, center) {
|
|
1760
|
+
if (scale === void 0) { scale = 7; }
|
|
1761
|
+
if (center === void 0) { center = [107, 36]; }
|
|
1762
|
+
this.name = 'Mercator';
|
|
1763
|
+
var perimeter = 100 * scale * Math.PI;
|
|
1764
|
+
var help = perimeter / 180;
|
|
1765
|
+
var cx = help * center[0];
|
|
1766
|
+
var cy = -1 * help * center[1];
|
|
1767
|
+
this.use = function (λ, φ) {
|
|
1768
|
+
return [
|
|
1769
|
+
(help * λ - cx) * 0.8,
|
|
1770
|
+
-1 * help * φ - cy
|
|
1771
|
+
];
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
return Mercator;
|
|
1775
|
+
}());
|
|
1776
|
+
|
|
1777
|
+
var mousePosition = function (el, event) {
|
|
1778
|
+
var bounding = el.getBoundingClientRect();
|
|
1779
|
+
return {
|
|
1780
|
+
"x": event.clientX - bounding.left,
|
|
1781
|
+
"y": event.clientY - bounding.top
|
|
1782
|
+
};
|
|
1783
|
+
};
|
|
1784
|
+
var getKeyString = function (event) {
|
|
1785
|
+
return {
|
|
1786
|
+
37: "left",
|
|
1787
|
+
38: "up",
|
|
1788
|
+
39: "right",
|
|
1789
|
+
40: "down",
|
|
1790
|
+
}[event.keyCode || event.which];
|
|
1791
|
+
};
|
|
1792
|
+
function viewHandler (callback) {
|
|
1793
|
+
var el = document.getElementsByTagName('body')[0];
|
|
1794
|
+
el.addEventListener("keydown", function (event) {
|
|
1795
|
+
var keyCode = getKeyString(event);
|
|
1796
|
+
if (keyCode == 'up') {
|
|
1797
|
+
callback({
|
|
1798
|
+
type: "lookUp",
|
|
1799
|
+
normal: [],
|
|
1800
|
+
value: 0.1
|
|
1801
|
+
});
|
|
1189
1802
|
}
|
|
1190
|
-
if (
|
|
1191
|
-
|
|
1803
|
+
else if (keyCode == 'down') {
|
|
1804
|
+
callback({
|
|
1805
|
+
type: "lookDown",
|
|
1806
|
+
normal: [],
|
|
1807
|
+
value: 0.1
|
|
1808
|
+
});
|
|
1192
1809
|
}
|
|
1193
|
-
else {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1810
|
+
else if (keyCode == 'left') {
|
|
1811
|
+
callback({
|
|
1812
|
+
type: "lookLeft",
|
|
1813
|
+
normal: [],
|
|
1814
|
+
value: 0.1
|
|
1815
|
+
});
|
|
1199
1816
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1817
|
+
else if (keyCode == 'right') {
|
|
1818
|
+
callback({
|
|
1819
|
+
type: "lookRight",
|
|
1820
|
+
normal: [],
|
|
1821
|
+
value: 0.1
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
var mouseP = null;
|
|
1826
|
+
var doMove = function (event) {
|
|
1827
|
+
if (mouseP == null)
|
|
1828
|
+
return;
|
|
1829
|
+
var tempMouseP = mousePosition(el, event);
|
|
1830
|
+
var normal = [tempMouseP.x - mouseP.x, tempMouseP.y - mouseP.y];
|
|
1831
|
+
var rotateNormal = [
|
|
1832
|
+
normal[1],
|
|
1833
|
+
normal[0],
|
|
1834
|
+
0
|
|
1835
|
+
];
|
|
1836
|
+
if (rotateNormal[0] == 0 && rotateNormal[1] == 0)
|
|
1837
|
+
return;
|
|
1838
|
+
callback({
|
|
1839
|
+
type: "rotate",
|
|
1840
|
+
normal: rotateNormal,
|
|
1841
|
+
value: (Math.abs(tempMouseP.x - mouseP.x) + Math.abs(tempMouseP.y - mouseP.y)) * 0.01
|
|
1842
|
+
});
|
|
1843
|
+
mouseP = tempMouseP;
|
|
1844
|
+
};
|
|
1845
|
+
el.addEventListener("mousedown", function (event) {
|
|
1846
|
+
mouseP = mousePosition(el, event);
|
|
1847
|
+
});
|
|
1848
|
+
el.addEventListener("mouseup", function (event) {
|
|
1849
|
+
mouseP = null;
|
|
1850
|
+
});
|
|
1851
|
+
el.addEventListener("mousemove", function (event) {
|
|
1852
|
+
doMove(event);
|
|
1853
|
+
});
|
|
1854
|
+
el.addEventListener("touchend", function (event) {
|
|
1855
|
+
mouseP = null;
|
|
1856
|
+
});
|
|
1857
|
+
el.addEventListener("touchstart", function (event) {
|
|
1858
|
+
mouseP = mousePosition(el, event);
|
|
1859
|
+
});
|
|
1860
|
+
el.addEventListener("touchmove", function (event) {
|
|
1861
|
+
doMove(event.touches[0]);
|
|
1862
|
+
});
|
|
1863
|
+
var doScale = function (value) {
|
|
1864
|
+
if (value == 0)
|
|
1865
|
+
return;
|
|
1866
|
+
var baseTimes = 0.899;
|
|
1867
|
+
callback({
|
|
1868
|
+
type: "scale",
|
|
1869
|
+
value: value < 0 ? baseTimes : 2 - baseTimes,
|
|
1870
|
+
normal: []
|
|
1871
|
+
});
|
|
1872
|
+
};
|
|
1873
|
+
el.addEventListener("mousewheel", function (event) {
|
|
1874
|
+
doScale(event.wheelDelta);
|
|
1875
|
+
});
|
|
1876
|
+
if (window.addEventListener) {
|
|
1877
|
+
window.addEventListener('DOMMouseScroll', function (event) {
|
|
1878
|
+
doScale(-1 * event.detail);
|
|
1879
|
+
}, false);
|
|
1230
1880
|
}
|
|
1231
|
-
return rulerArray;
|
|
1232
1881
|
}
|
|
1233
1882
|
|
|
1234
1883
|
var index = {
|
|
1235
|
-
Canvas: Canvas,
|
|
1236
1884
|
Cardinal: Cardinal,
|
|
1237
|
-
Eoap: Eoap,
|
|
1238
|
-
getLoopColors: getLoopColors,
|
|
1239
1885
|
Hermite: Hermite,
|
|
1240
1886
|
Matrix4: Matrix4,
|
|
1241
|
-
rotate: rotate,
|
|
1242
|
-
|
|
1887
|
+
rotate: rotate$1,
|
|
1888
|
+
getLoopColors: getLoopColors,
|
|
1243
1889
|
animation: animation,
|
|
1244
|
-
ruler: ruler
|
|
1890
|
+
ruler: ruler,
|
|
1891
|
+
SVG: SVG,
|
|
1892
|
+
Canvas: Canvas,
|
|
1893
|
+
WebGL: WebGL,
|
|
1894
|
+
Eoap: Eoap,
|
|
1895
|
+
Mercator: Mercator,
|
|
1896
|
+
viewHandler: viewHandler
|
|
1245
1897
|
};
|
|
1246
1898
|
|
|
1247
1899
|
return index;
|