vislite 0.4.1-alpha.2 → 0.4.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +19 -0
- package/CHANGELOG +17 -8
- package/README.md +16 -1
- package/lib/Buffer/index.umd.js +2 -2
- package/lib/Buffer/index.umd.min.js +2 -2
- package/lib/Canvas/index.umd.js +89 -10
- package/lib/Canvas/index.umd.min.js +3 -3
- package/lib/Cardinal/index.umd.js +2 -2
- package/lib/Cardinal/index.umd.min.js +2 -2
- package/lib/Eoap/index.umd.js +2 -2
- package/lib/Eoap/index.umd.min.js +2 -2
- package/lib/Hermite/index.umd.js +2 -2
- package/lib/Hermite/index.umd.min.js +2 -2
- package/lib/Matrix4/index.umd.js +2 -2
- package/lib/Matrix4/index.umd.min.js +2 -2
- package/lib/Mercator/index.umd.js +2 -2
- package/lib/Mercator/index.umd.min.js +2 -2
- package/lib/OralCanvas/index.es.js +79 -8
- package/lib/OralCanvas/index.es.min.js +3 -3
- package/lib/OralWebGL/index.es.js +35 -10
- package/lib/OralWebGL/index.es.min.js +3 -3
- package/lib/SVG/index.umd.js +2 -2
- package/lib/SVG/index.umd.min.js +2 -2
- package/lib/Shader/index.umd.js +82 -3
- package/lib/Shader/index.umd.min.js +3 -3
- package/lib/Texture/index.umd.js +3 -5
- package/lib/Texture/index.umd.min.js +3 -3
- package/lib/TreeLayout/index.umd.js +427 -0
- package/lib/TreeLayout/index.umd.min.js +11 -0
- package/lib/WebGL/index.umd.js +45 -12
- package/lib/WebGL/index.umd.min.js +3 -3
- package/lib/animation/index.umd.js +3 -3
- package/lib/animation/index.umd.min.js +2 -2
- package/lib/formatColor/index.umd.js +59 -0
- package/lib/formatColor/index.umd.min.js +11 -0
- package/lib/getLoopColors/index.umd.js +2 -2
- package/lib/getLoopColors/index.umd.min.js +2 -2
- package/lib/getWebGLContext/index.umd.js +2 -2
- package/lib/getWebGLContext/index.umd.min.js +2 -2
- package/lib/index.umd.js +555 -23
- package/lib/index.umd.min.js +3 -3
- package/lib/resizeObserver/index.umd.js +48 -0
- package/lib/resizeObserver/index.umd.min.js +11 -0
- package/lib/rotate/index.umd.js +2 -2
- package/lib/rotate/index.umd.min.js +2 -2
- package/lib/ruler/index.umd.js +2 -2
- package/lib/ruler/index.umd.min.js +2 -2
- package/lib/throttle/index.umd.js +68 -0
- package/lib/throttle/index.umd.min.js +11 -0
- package/lib/viewHandler/index.umd.js +2 -2
- package/lib/viewHandler/index.umd.min.js +2 -2
- package/package/Buffer/index.ts +1 -0
- package/package/Canvas/index.ts +1 -0
- package/package/OralCanvas/index.ts +1 -0
- package/package/OralWebGL/index.ts +1 -0
- package/package/Shader/index.ts +39 -1
- package/package/Texture/index.ts +1 -0
- package/package/TreeLayout/index.ts +3 -0
- package/package/WebGL/index.ts +1 -0
- package/package/formatColor/index.ts +3 -0
- package/package/index.ts +12 -1
- package/package/resizeObserver/index.ts +3 -0
- package/package/throttle/index.ts +3 -0
- package/package.json +1 -1
- package/src/Canvas.ts +7 -3
- package/src/Eoap.ts +1 -1
- package/src/Matrix4/index.ts +1 -1
- package/src/Mercator.ts +1 -1
- package/src/SVG.ts +2 -1
- package/src/TreeLayout/index.ts +186 -0
- package/src/WebGL.ts +7 -3
- package/src/animation.ts +2 -3
- package/src/common/canvas/config.ts +2 -1
- package/src/common/canvas/index.ts +10 -3
- package/src/common/canvas/painter.ts +74 -5
- package/src/common/mergeOption.ts +7 -0
- package/src/common/svg/config.ts +2 -1
- package/src/common/svg/index.ts +2 -1
- package/src/common/svg/tool.ts +2 -1
- package/src/common/tree/index.ts +26 -0
- package/src/common/tree/toInnerTree.ts +57 -0
- package/src/common/tree/toPlainTree.ts +132 -0
- package/src/common/webgl/doDraw.ts +2 -0
- package/src/common/webgl/getShader.ts +25 -52
- package/src/common/webgl/index.ts +4 -3
- package/src/common/webgl/texture.ts +2 -5
- package/src/formatColor.ts +45 -0
- package/src/interpolation/Cardinal.ts +2 -1
- package/src/interpolation/Hermite.ts +1 -1
- package/src/resizeObserver.ts +37 -0
- package/src/ruler.ts +1 -1
- package/src/shader/fsColor.c +8 -0
- package/src/shader/fsColors.c +8 -0
- package/src/shader/fsCube.c +9 -0
- package/src/shader/fsImage.c +9 -0
- package/src/shader/vsColor.c +18 -0
- package/src/shader/vsColors.c +14 -0
- package/src/shader/vsCube.c +14 -0
- package/src/shader/vsImage.c +14 -0
- package/src/throttle.ts +50 -0
- package/src/viewHandler.ts +1 -1
- package/types/Canvas.d.ts +12 -0
- package/types/CanvasOption.d.ts +2 -2
- package/types/Shader.d.ts +6 -0
- package/types/Tree.d.ts +38 -0
- package/types/TreeConfig.d.ts +25 -0
- package/types/TreeLayout.d.ts +49 -0
- package/types/TreeOption.d.ts +46 -0
- package/types/formatColor.d.ts +3 -0
- package/types/index.d.ts +24 -1
- package/types/resizeObserver.d.ts +3 -0
- package/types/throttle.d.ts +5 -0
- package/types/throttleOption.d.ts +20 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
var t,i;t=this,i=function(){"use strict";return function(){function t(t){void 0===t&&(t=.5),this.name="Hermite",this.__u=t}return t.prototype.setP=function(t,i,e,o,s,_){if(!(t<e))throw new Error("The point x-position should be increamented!");this.__a=t,this.__b=e;var n=this.__u*s,r=this.__u*_;return i/=e-t,o/=e-t,this.__MR=[2*i-2*o+n+r,3*o-3*i-2*n-r,n,i],this},t.prototype.use=function(t){if(this.__MR){var i=(t-this.__a)/(this.__b-this.__a),e=i*i;return(i*e*this.__MR[0]+e*this.__MR[1]+i*this.__MR[2]+this.__MR[3])*(this.__b-this.__a)}throw new Error("You shoud first set the position!")},t}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_Hermite=i();
|
package/lib/Matrix4/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
12
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
var t,r;t=this,r=function(){"use strict";var t=function(t,r){for(var i=[],e=0;e<4;e++)for(var o=0;o<r.length/4;o++)i[4*o+e]=t[e]*r[4*o]+t[e+4]*r[4*o+1]+t[e+8]*r[4*o+2]+t[e+12]*r[4*o+3];return i};return function(){function r(t){void 0===t&&(t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.name="Matrix4",this.__matrix4=t}return r.prototype.move=function(r,i,e,o){return void 0===o&&(o=0),this.__matrix4=t(function(t,r,i,e){void 0===e&&(e=0);var o=Math.sqrt(r*r+i*i+e*e);return[1,0,0,0,0,1,0,0,0,0,1,0,r*t/o,i*t/o,e*t/o,1]}(r,i,e,o),this.__matrix4),this},r.prototype.rotate=function(r,i,e,o,n,u,a){var f=function(t,r,i,e,o,n){if("number"==typeof t&&"number"==typeof r){if("number"!=typeof i?(i=0,e=t,o=r,n=1):"number"==typeof e&&"number"==typeof o&&"number"==typeof n||(e=t,o=r,n=i,t=0,r=0,i=0),t==e&&r==o&&i==n)throw new Error("It's not a legitimate ray!");var u=Math.sqrt((e-t)*(e-t)+(o-r)*(o-r)),a=0!=u?(o-r)/u:1,f=0!=u?(e-t)/u:0,s=(e-t)*f+(o-r)*a,h=n-i,m=Math.sqrt(s*s+h*h),p=0!=m?h/m:1,_=0!=m?s/m:0;return[[a,p*f,f*_,0,-f,a*p,a*_,0,0,-_,p,0,r*f-t*a,i*_-t*f*p-r*a*p,-t*f*_-r*a*_-i*p,1],[a,-f,0,0,p*f,p*a,-_,0,f*_,a*_,p,0,t,r,i,1]]}throw new Error("a1 and b1 is required!")}(i,e,o,n,u,a);return this.__matrix4=t(t(t(f[1],function(t){var r=Math.sin(t),i=Math.cos(t);return[i,r,0,0,-r,i,0,0,0,0,1,0,0,0,0,1]}(r)),f[0]),this.__matrix4),this},r.prototype.scale=function(r,i,e,o,n,u){return void 0===o&&(o=0),void 0===n&&(n=0),void 0===u&&(u=0),this.__matrix4=t(function(t,r,i,e,o,n){return void 0===e&&(e=0),void 0===o&&(o=0),void 0===n&&(n=0),[t,0,0,0,0,r,0,0,0,0,i,0,e-e*t,o-o*r,n-n*i,1]}(r,i,e,o,n,u),this.__matrix4),this},r.prototype.multiply=function(r,i){return void 0===i&&(i=!1),this.__matrix4=i?t(this.__matrix4,r):t(r,this.__matrix4),this},r.prototype.use=function(r,i,e,o){return void 0===e&&(e=0),void 0===o&&(o=1),t(this.__matrix4,[r,i,e,o])},r.prototype.value=function(){return this.__matrix4},r}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_Matrix4=r();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
12
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
var e,t;e=this,t=function(){"use strict";return function(e,t){void 0===e&&(e=7),void 0===t&&(t=[107,36]),this.name="Mercator";var o=100*e*Math.PI/180,i=o*t[0],n=-1*o*t[1];this.use=function(e,t){return[.8*(o*e-i),-1*o*t-n]}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_Mercator=t();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
/******************************************************************************
|
|
12
12
|
Copyright (c) Microsoft Corporation.
|
|
@@ -155,9 +155,11 @@ function texts (painter, contents, width, height, doback) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
var Painter = (function () {
|
|
158
|
-
function Painter(canvas, opts, region) {
|
|
158
|
+
function Painter(canvas, opts, region, isPainter) {
|
|
159
159
|
if (opts === void 0) { opts = {}; }
|
|
160
|
+
if (isPainter === void 0) { isPainter = false; }
|
|
160
161
|
this.__region = null;
|
|
162
|
+
this.__onlyRegion = false;
|
|
161
163
|
this.__specialConfig = {
|
|
162
164
|
"fontSize": 16,
|
|
163
165
|
"fontFamily": "sans-serif",
|
|
@@ -178,6 +180,7 @@ var Painter = (function () {
|
|
|
178
180
|
};
|
|
179
181
|
this.painter = canvas.getContext("2d", opts);
|
|
180
182
|
this.__region = region;
|
|
183
|
+
this.__isPainter = isPainter;
|
|
181
184
|
this.painter.textBaseline = 'middle';
|
|
182
185
|
this.painter.textAlign = 'left';
|
|
183
186
|
}
|
|
@@ -187,6 +190,8 @@ var Painter = (function () {
|
|
|
187
190
|
this.__region.useConfig(key, value);
|
|
188
191
|
}
|
|
189
192
|
}
|
|
193
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
194
|
+
return this;
|
|
190
195
|
if (key == 'lineDash') {
|
|
191
196
|
if (this.painter.setLineDash)
|
|
192
197
|
this.painter.setLineDash(value);
|
|
@@ -209,6 +214,8 @@ var Painter = (function () {
|
|
|
209
214
|
if (deg === void 0) { deg = 0; }
|
|
210
215
|
if (this.__region)
|
|
211
216
|
this.__region.fillText(text, x, y, deg);
|
|
217
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
218
|
+
return this;
|
|
212
219
|
this.painter.save();
|
|
213
220
|
initText(this.painter, this.__specialConfig, x, y, deg).fillText(text, 0, 0);
|
|
214
221
|
this.painter.restore();
|
|
@@ -218,6 +225,8 @@ var Painter = (function () {
|
|
|
218
225
|
if (deg === void 0) { deg = 0; }
|
|
219
226
|
if (this.__region)
|
|
220
227
|
this.__region.strokeText(text, x, y, deg);
|
|
228
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
229
|
+
return this;
|
|
221
230
|
this.painter.save();
|
|
222
231
|
initText(this.painter, this.__specialConfig, x, y, deg).strokeText(text, 0, 0);
|
|
223
232
|
this.painter.restore();
|
|
@@ -227,6 +236,8 @@ var Painter = (function () {
|
|
|
227
236
|
if (deg === void 0) { deg = 0; }
|
|
228
237
|
if (this.__region)
|
|
229
238
|
this.__region.fullText(text, x, y, deg);
|
|
239
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
240
|
+
return this;
|
|
230
241
|
this.painter.save();
|
|
231
242
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
232
243
|
this.painter.fillText(text, 0, 0);
|
|
@@ -238,8 +249,11 @@ var Painter = (function () {
|
|
|
238
249
|
var _this = this;
|
|
239
250
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
240
251
|
if (deg === void 0) { deg = 0; }
|
|
252
|
+
var h = 0;
|
|
241
253
|
if (this.__region)
|
|
242
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
254
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
255
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
256
|
+
return h;
|
|
243
257
|
this.painter.save();
|
|
244
258
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
245
259
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -252,8 +266,11 @@ var Painter = (function () {
|
|
|
252
266
|
var _this = this;
|
|
253
267
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
254
268
|
if (deg === void 0) { deg = 0; }
|
|
269
|
+
var h = 0;
|
|
255
270
|
if (this.__region)
|
|
256
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
271
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
272
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
273
|
+
return h;
|
|
257
274
|
this.painter.save();
|
|
258
275
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
259
276
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -266,8 +283,11 @@ var Painter = (function () {
|
|
|
266
283
|
var _this = this;
|
|
267
284
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
268
285
|
if (deg === void 0) { deg = 0; }
|
|
286
|
+
var h = 0;
|
|
269
287
|
if (this.__region)
|
|
270
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
288
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
289
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
290
|
+
return h;
|
|
271
291
|
this.painter.save();
|
|
272
292
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
273
293
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -280,48 +300,64 @@ var Painter = (function () {
|
|
|
280
300
|
Painter.prototype.beginPath = function () {
|
|
281
301
|
if (this.__region)
|
|
282
302
|
this.__region.beginPath();
|
|
303
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
304
|
+
return this;
|
|
283
305
|
this.painter.beginPath();
|
|
284
306
|
return this;
|
|
285
307
|
};
|
|
286
308
|
Painter.prototype.closePath = function () {
|
|
287
309
|
if (this.__region)
|
|
288
310
|
this.__region.closePath();
|
|
311
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
312
|
+
return this;
|
|
289
313
|
this.painter.closePath();
|
|
290
314
|
return this;
|
|
291
315
|
};
|
|
292
316
|
Painter.prototype.moveTo = function (x, y) {
|
|
293
317
|
if (this.__region)
|
|
294
318
|
this.__region.moveTo(x, y);
|
|
319
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
320
|
+
return this;
|
|
295
321
|
this.painter.moveTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
296
322
|
return this;
|
|
297
323
|
};
|
|
298
324
|
Painter.prototype.lineTo = function (x, y) {
|
|
299
325
|
if (this.__region)
|
|
300
326
|
this.__region.lineTo(x, y);
|
|
327
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
328
|
+
return this;
|
|
301
329
|
this.painter.lineTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
302
330
|
return this;
|
|
303
331
|
};
|
|
304
332
|
Painter.prototype.arc = function (x, y, r, beginDeg, deg) {
|
|
305
333
|
if (this.__region)
|
|
306
334
|
this.__region.arc(x, y, r, beginDeg, deg);
|
|
335
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
336
|
+
return this;
|
|
307
337
|
this.painter.arc(x, y, r, beginDeg, beginDeg + deg, deg < 0);
|
|
308
338
|
return this;
|
|
309
339
|
};
|
|
310
340
|
Painter.prototype.fill = function () {
|
|
311
341
|
if (this.__region)
|
|
312
342
|
this.__region.fill();
|
|
343
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
344
|
+
return this;
|
|
313
345
|
this.painter.fill();
|
|
314
346
|
return this;
|
|
315
347
|
};
|
|
316
348
|
Painter.prototype.stroke = function () {
|
|
317
349
|
if (this.__region)
|
|
318
350
|
this.__region.stroke();
|
|
351
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
352
|
+
return this;
|
|
319
353
|
this.painter.stroke();
|
|
320
354
|
return this;
|
|
321
355
|
};
|
|
322
356
|
Painter.prototype.full = function () {
|
|
323
357
|
if (this.__region)
|
|
324
358
|
this.__region.full();
|
|
359
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
360
|
+
return this;
|
|
325
361
|
this.painter.fill();
|
|
326
362
|
this.painter.stroke();
|
|
327
363
|
return this;
|
|
@@ -329,54 +365,72 @@ var Painter = (function () {
|
|
|
329
365
|
Painter.prototype.save = function () {
|
|
330
366
|
if (this.__region)
|
|
331
367
|
this.__region.save();
|
|
368
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
369
|
+
return this;
|
|
332
370
|
this.painter.save();
|
|
333
371
|
return this;
|
|
334
372
|
};
|
|
335
373
|
Painter.prototype.restore = function () {
|
|
336
374
|
if (this.__region)
|
|
337
375
|
this.__region.restore();
|
|
376
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
377
|
+
return this;
|
|
338
378
|
this.painter.restore();
|
|
339
379
|
return this;
|
|
340
380
|
};
|
|
341
381
|
Painter.prototype.clip = function () {
|
|
342
382
|
if (this.__region)
|
|
343
383
|
this.__region.clip();
|
|
384
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
385
|
+
return this;
|
|
344
386
|
this.painter.clip();
|
|
345
387
|
return this;
|
|
346
388
|
};
|
|
347
389
|
Painter.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
348
390
|
if (this.__region)
|
|
349
391
|
this.__region.quadraticCurveTo(cpx, cpy, x, y);
|
|
392
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
393
|
+
return this;
|
|
350
394
|
this.painter.quadraticCurveTo(cpx, cpy, x, y);
|
|
351
395
|
return this;
|
|
352
396
|
};
|
|
353
397
|
Painter.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
354
398
|
if (this.__region)
|
|
355
399
|
this.__region.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
400
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
401
|
+
return this;
|
|
356
402
|
this.painter.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
357
403
|
return this;
|
|
358
404
|
};
|
|
359
405
|
Painter.prototype.clearRect = function (x, y, w, h) {
|
|
360
406
|
if (this.__region)
|
|
361
407
|
this.__region.clearRect(x, y, w, h);
|
|
408
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
409
|
+
return this;
|
|
362
410
|
this.painter.clearRect(x, y, w, h);
|
|
363
411
|
return this;
|
|
364
412
|
};
|
|
365
413
|
Painter.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
366
414
|
if (this.__region)
|
|
367
415
|
this.__region.fillArc(cx, cy, r1, r2, beginDeg, deg);
|
|
416
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
417
|
+
return this;
|
|
368
418
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).fill();
|
|
369
419
|
return this;
|
|
370
420
|
};
|
|
371
421
|
Painter.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
372
422
|
if (this.__region)
|
|
373
423
|
this.__region.strokeArc(cx, cy, r1, r2, beginDeg, deg);
|
|
424
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
425
|
+
return this;
|
|
374
426
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).stroke();
|
|
375
427
|
return this;
|
|
376
428
|
};
|
|
377
429
|
Painter.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
378
430
|
if (this.__region)
|
|
379
431
|
this.__region.fullArc(cx, cy, r1, r2, beginDeg, deg);
|
|
432
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
433
|
+
return this;
|
|
380
434
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg);
|
|
381
435
|
this.painter.fill();
|
|
382
436
|
this.painter.stroke();
|
|
@@ -385,18 +439,24 @@ var Painter = (function () {
|
|
|
385
439
|
Painter.prototype.fillCircle = function (cx, cy, r) {
|
|
386
440
|
if (this.__region)
|
|
387
441
|
this.__region.fillCircle(cx, cy, r);
|
|
442
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
443
|
+
return this;
|
|
388
444
|
initCircle(this.painter, cx, cy, r).fill();
|
|
389
445
|
return this;
|
|
390
446
|
};
|
|
391
447
|
Painter.prototype.strokeCircle = function (cx, cy, r) {
|
|
392
448
|
if (this.__region)
|
|
393
449
|
this.__region.strokeCircle(cx, cy, r);
|
|
450
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
451
|
+
return this;
|
|
394
452
|
initCircle(this.painter, cx, cy, r).stroke();
|
|
395
453
|
return this;
|
|
396
454
|
};
|
|
397
455
|
Painter.prototype.fullCircle = function (cx, cy, r) {
|
|
398
456
|
if (this.__region)
|
|
399
457
|
this.__region.fullCircle(cx, cy, r);
|
|
458
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
459
|
+
return this;
|
|
400
460
|
initCircle(this.painter, cx, cy, r);
|
|
401
461
|
this.painter.fill();
|
|
402
462
|
this.painter.stroke();
|
|
@@ -405,23 +465,30 @@ var Painter = (function () {
|
|
|
405
465
|
Painter.prototype.fillRect = function (x, y, width, height) {
|
|
406
466
|
if (this.__region)
|
|
407
467
|
this.__region.fillRect(x, y, width, height);
|
|
468
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
469
|
+
return this;
|
|
408
470
|
initRect(this.painter, x, y, width, height).fill();
|
|
409
471
|
return this;
|
|
410
472
|
};
|
|
411
473
|
Painter.prototype.strokeRect = function (x, y, width, height) {
|
|
412
474
|
if (this.__region)
|
|
413
475
|
this.__region.strokeRect(x, y, width, height);
|
|
476
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
477
|
+
return this;
|
|
414
478
|
initRect(this.painter, x, y, width, height).stroke();
|
|
415
479
|
return this;
|
|
416
480
|
};
|
|
417
481
|
Painter.prototype.fullRect = function (x, y, width, height) {
|
|
418
482
|
if (this.__region)
|
|
419
483
|
this.__region.fullRect(x, y, width, height);
|
|
484
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
485
|
+
return this;
|
|
420
486
|
initRect(this.painter, x, y, width, height);
|
|
421
487
|
this.painter.fill();
|
|
422
488
|
this.painter.stroke();
|
|
423
489
|
return this;
|
|
424
490
|
};
|
|
491
|
+
Painter.prototype.draw = function () { };
|
|
425
492
|
return Painter;
|
|
426
493
|
}());
|
|
427
494
|
|
|
@@ -483,7 +550,7 @@ var Canvas = (function (_super) {
|
|
|
483
550
|
function Canvas(ViewCanvas, RegionCanvas) {
|
|
484
551
|
var _this = _super.call(this, ViewCanvas, {}, RegionCanvas ? new Painter(RegionCanvas, {
|
|
485
552
|
willReadFrequently: true,
|
|
486
|
-
}) : null) || this;
|
|
553
|
+
}) : null, true) || this;
|
|
487
554
|
_this.name = "Canvas";
|
|
488
555
|
_this.__regionList = {};
|
|
489
556
|
_this.__regionAssemble = assemble(0, 255, 10, 3);
|
|
@@ -497,10 +564,14 @@ var Canvas = (function (_super) {
|
|
|
497
564
|
}
|
|
498
565
|
return this;
|
|
499
566
|
};
|
|
567
|
+
Canvas.prototype.onlyRegion = function (flag) {
|
|
568
|
+
this.__onlyRegion = flag;
|
|
569
|
+
return this;
|
|
570
|
+
};
|
|
500
571
|
Canvas.prototype.setRegion = function (regionName) {
|
|
501
572
|
if (this.__region) {
|
|
502
573
|
if (regionName) {
|
|
503
|
-
if (this.__regionList[regionName] ==
|
|
574
|
+
if (this.__regionList[regionName] == void 0) {
|
|
504
575
|
var tempColor = this.__regionAssemble();
|
|
505
576
|
this.__regionList[regionName] =
|
|
506
577
|
"rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
|
-
var t=function(i,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])},t(i,e)};"function"==typeof SuppressedError&&SuppressedError;var i=function(t,i,e,r,n){var o=Math.cos(e),s=Math.sin(e);return[+((r-t)*o-(n-i)*s+t).toFixed(7),+((r-t)*s+(n-i)*o+i).toFixed(7)]};var e=function(t,i,e,r,n){return t.beginPath(),t.translate(e,r),t.rotate(n),t.font=i.fontStyle+" "+i.fontWeight+" "+i.fontSize+"px "+i.fontFamily,t},r=function(t,e,r,n,o,s,a,h){if(o>s){var _=o;o=s,s=_}return a%=2*Math.PI,h>=1.999999*Math.PI||h<=1.999999*-Math.PI?h=2*Math.PI:h%=2*Math.PI,function(t,e,r,n,o,s,a){e<0&&(t+=e,e*=-1);var h,_=[];h=i(0,0,t,o,0),_[0]=h[0],_[1]=h[1],h=i(0,0,e,h[0],h[1]),_[2]=h[0],_[3]=h[1],h=i(0,0,t,s,0),_[4]=h[0],_[5]=h[1],h=i(0,0,e,h[0],h[1]),_[6]=h[0],_[7]=h[1],a(t,t+e,_[0]+r,_[1]+n,_[4]+r,_[5]+n,_[2]+r,_[3]+n,_[6]+r,_[7]+n,.5*(s-o))}(a,h,r,n,o,s,(function(i,a,h,_,p,l,f,u,c,g,v){v<0&&(v=-v),t.beginPath(),t.moveTo(h,_),t.arc(r,n,o,i,a,!1),"round"==e.arcEndCap?t.arc(.5*(f+c),.5*(u+g),v,a-Math.PI,a,!0):"-round"==e.arcEndCap?t.arc(.5*(f+c),.5*(u+g),v,a-Math.PI,a,!1):t.lineTo(c,g),t.arc(r,n,s,a,i,!0),"round"==e.arcStartCap?t.arc(.5*(h+p),.5*(_+l),v,i,i-Math.PI,!0):"-round"==e.arcStartCap?t.arc(.5*(h+p),.5*(_+l),v,i,i-Math.PI,!1):t.lineTo(h,_)})),"butt"==e.arcStartCap&&t.closePath(),t},n=function(t,i,e,r){return t.beginPath(),t.moveTo(i+r,e),t.arc(i,e,r,0,2*Math.PI),t},o=function(t,i,e,r,n){return t.beginPath(),t.rect(i,e,r,n),t};function s(t,i,e,r,n){for(var o=0,s="",a=0;a<i.length;a++)t.measureText(s+i[a]).width>e||/\n$/.test(s)?(n(s,((o+=1)-.5)*r),s=i[a]):a==i.length-1?(o+=1,n(s+i[a],(o-.5)*r)):s+=i[a];return o*r}var a=function(){function t(t,i,e){void 0===i&&(i={}),this.__region=null,this.__specialConfig={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",arcStartCap:"butt",arcEndCap:"butt"},this.__initConfig={fillStyle:"black",strokeStyle:"black",lineWidth:1,textAlign:"left",textBaseline:"middle",lineDash:[],shadowBlur:0,shadowColor:"black"},this.painter=t.getContext("2d",i),this.__region=e,this.painter.textBaseline="middle",this.painter.textAlign="left"}return t.prototype.useConfig=function(t,i){if(this.__region&&["fillStyle","strokeStyle","shadowBlur","shadowColor"].indexOf(t)<0&&this.__region.useConfig(t,i),"lineDash"==t)this.painter.setLineDash&&this.painter.setLineDash(i);else if(t in this.__specialConfig)"fontSize"==t&&(i=Math.round(i)),this.__specialConfig[t]=i;else{if(!(t in this.__initConfig))throw new Error("Illegal configuration item of painter : "+t+" !");this.painter[t]=i}return this},t.prototype.fillText=function(t,i,r,n){return void 0===n&&(n=0),this.__region&&this.__region.fillText(t,i,r,n),this.painter.save(),e(this.painter,this.__specialConfig,i,r,n).fillText(t,0,0),this.painter.restore(),this},t.prototype.strokeText=function(t,i,r,n){return void 0===n&&(n=0),this.__region&&this.__region.strokeText(t,i,r,n),this.painter.save(),e(this.painter,this.__specialConfig,i,r,n).strokeText(t,0,0),this.painter.restore(),this},t.prototype.fullText=function(t,i,r,n){return void 0===n&&(n=0),this.__region&&this.__region.fullText(t,i,r,n),this.painter.save(),e(this.painter,this.__specialConfig,i,r,n),this.painter.fillText(t,0,0),this.painter.strokeText(t,0,0),this.painter.restore(),this},t.prototype.fillTexts=function(t,i,r,n,o,a){var h=this;void 0===o&&(o=1.2),void 0===a&&(a=0),this.__region&&this.__region.fillTexts(t,i,r,n,o),this.painter.save(),e(this.painter,this.__specialConfig,i,r,a);var _=s(this.painter,t,n,this.__specialConfig.fontSize*o,(function(t,i){h.painter.fillText(t,0,i)}));return this.painter.restore(),_},t.prototype.strokeTexts=function(t,i,r,n,o,a){var h=this;void 0===o&&(o=1.2),void 0===a&&(a=0),this.__region&&this.__region.fillTexts(t,i,r,n,o),this.painter.save(),e(this.painter,this.__specialConfig,i,r,a);var _=s(this.painter,t,n,this.__specialConfig.fontSize*o,(function(t,i){h.painter.strokeText(t,0,i)}));return this.painter.restore(),_},t.prototype.fullTexts=function(t,i,r,n,o,a){var h=this;void 0===o&&(o=1.2),void 0===a&&(a=0),this.__region&&this.__region.fillTexts(t,i,r,n,o),this.painter.save(),e(this.painter,this.__specialConfig,i,r,a);var _=s(this.painter,t,n,this.__specialConfig.fontSize*o,(function(t,i){h.painter.fillText(t,0,i),h.painter.strokeText(t,0,i)}));return this.painter.restore(),_},t.prototype.beginPath=function(){return this.__region&&this.__region.beginPath(),this.painter.beginPath(),this},t.prototype.closePath=function(){return this.__region&&this.__region.closePath(),this.painter.closePath(),this},t.prototype.moveTo=function(t,i){return this.__region&&this.__region.moveTo(t,i),this.painter.moveTo(Math.round(t)+.5,Math.round(i)+.5),this},t.prototype.lineTo=function(t,i){return this.__region&&this.__region.lineTo(t,i),this.painter.lineTo(Math.round(t)+.5,Math.round(i)+.5),this},t.prototype.arc=function(t,i,e,r,n){return this.__region&&this.__region.arc(t,i,e,r,n),this.painter.arc(t,i,e,r,r+n,n<0),this},t.prototype.fill=function(){return this.__region&&this.__region.fill(),this.painter.fill(),this},t.prototype.stroke=function(){return this.__region&&this.__region.stroke(),this.painter.stroke(),this},t.prototype.full=function(){return this.__region&&this.__region.full(),this.painter.fill(),this.painter.stroke(),this},t.prototype.save=function(){return this.__region&&this.__region.save(),this.painter.save(),this},t.prototype.restore=function(){return this.__region&&this.__region.restore(),this.painter.restore(),this},t.prototype.clip=function(){return this.__region&&this.__region.clip(),this.painter.clip(),this},t.prototype.quadraticCurveTo=function(t,i,e,r){return this.__region&&this.__region.quadraticCurveTo(t,i,e,r),this.painter.quadraticCurveTo(t,i,e,r),this},t.prototype.bezierCurveTo=function(t,i,e,r,n,o){return this.__region&&this.__region.bezierCurveTo(t,i,e,r,n,o),this.painter.bezierCurveTo(t,i,e,r,n,o),this},t.prototype.clearRect=function(t,i,e,r){return this.__region&&this.__region.clearRect(t,i,e,r),this.painter.clearRect(t,i,e,r),this},t.prototype.fillArc=function(t,i,e,n,o,s){return this.__region&&this.__region.fillArc(t,i,e,n,o,s),r(this.painter,this.__specialConfig,t,i,e,n,o,s).fill(),this},t.prototype.strokeArc=function(t,i,e,n,o,s){return this.__region&&this.__region.strokeArc(t,i,e,n,o,s),r(this.painter,this.__specialConfig,t,i,e,n,o,s).stroke(),this},t.prototype.fullArc=function(t,i,e,n,o,s){return this.__region&&this.__region.fullArc(t,i,e,n,o,s),r(this.painter,this.__specialConfig,t,i,e,n,o,s),this.painter.fill(),this.painter.stroke(),this},t.prototype.fillCircle=function(t,i,e){return this.__region&&this.__region.fillCircle(t,i,e),n(this.painter,t,i,e).fill(),this},t.prototype.strokeCircle=function(t,i,e){return this.__region&&this.__region.strokeCircle(t,i,e),n(this.painter,t,i,e).stroke(),this},t.prototype.fullCircle=function(t,i,e){return this.__region&&this.__region.fullCircle(t,i,e),n(this.painter,t,i,e),this.painter.fill(),this.painter.stroke(),this},t.prototype.fillRect=function(t,i,e,r){return this.__region&&this.__region.fillRect(t,i,e,r),o(this.painter,t,i,e,r).fill(),this},t.prototype.strokeRect=function(t,i,e,r){return this.__region&&this.__region.strokeRect(t,i,e,r),o(this.painter,t,i,e,r).stroke(),this},t.prototype.fullRect=function(t,i,e,r){return this.__region&&this.__region.fullRect(t,i,e,r),o(this.painter,t,i,e,r),this.painter.fill(),this.painter.stroke(),this},t}();var h={"font-size":"fontSize","font-family":"fontFamily","font-weight":"fontWeight","font-style":"fontStyle","arc-start-cap":"arcStartCap","arc-end-cap":"arcEndCap"},_=function(i){function r(t,e){var r=i.call(this,t,{},e?new a(e,{willReadFrequently:!0}):null)||this;return r.name="Canvas",r.__regionList={},r.__regionAssemble=function(t,i,e,r){for(var n=[],o=0;o<r;o++)n[o]=t;return function(){for(var o=0;o<r;o++){if(n[o]+e<i){n[o]=+(n[o]+e).toFixed(7);break}o<r-1&&(n[o]=t)}return n}}(0,255,10,3),r.setRegion(""),r}return function(i,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=i}t(i,e),i.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(r,i),r.prototype.config=function(t){for(var i in t){var e=h[i]||i;this.useConfig(e,t[i])}return this},r.prototype.setRegion=function(t){if(this.__region)if(t){if(null==this.__regionList[t]){var i=this.__regionAssemble();this.__regionList[t]="rgb("+i[0]+","+i[1]+","+i[2]+")"}this.__region.useConfig("fillStyle",this.__regionList[t])&&this.__region.useConfig("strokeStyle",this.__regionList[t])}else this.__region.useConfig("fillStyle","#000000")&&this.__region.useConfig("strokeStyle","#000000");return this},r.prototype.getRegion=function(t,i){var e=this;return new Promise((function(r,n){var o=e.__region?e.__region.painter.getImageData(t-.5,i-.5,1,1):{data:[0,0,0,0]},s=o.data,a=function(){if(e.__region)for(var t in e.__regionList)if("rgb("+s[0]+","+s[1]+","+s[2]+")"==e.__regionList[t]){r(t);break}r("")};s?a():o.then((function(t){s=t,a()}))}))},r.prototype.textWidth=function(t){this.painter.save(),e(this.painter,this.__specialConfig,0,0,0);var i=this.painter.measureText(t+"").width;return this.painter.restore(),i},r.prototype.getContext=function(t){return void 0===t&&(t=!1),t?this.__region?this.__region.painter:null:this.painter},r.prototype.createLinearGradient=function(t,i,e,r){return function(t,i,e,r,n){var o=t.createLinearGradient(i,e,r,n),s={value:function(){return o},setColor:function(t,i){return o.addColorStop(t,i),s}};return s}(this.painter,t,i,e,r)},r.prototype.createRadialGradient=function(t,i,e){return function(t,i,e,r){var n=t.createRadialGradient(i,e,0,i,e,r),o={value:function(){return n},setColor:function(t,i){return n.addColorStop(t,i),o}};return o}(this.painter,t,i,e)},r.prototype.getColor=function(t,i){var e=this.painter.getImageData(t-.5,i-.5,1,1).data;return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},r}(a);export{_ as default};
|
|
11
|
+
var t=function(i,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])},t(i,e)};"function"==typeof SuppressedError&&SuppressedError;var i=function(t,i,e,n,r){var o=Math.cos(e),s=Math.sin(e);return[+((n-t)*o-(r-i)*s+t).toFixed(7),+((n-t)*s+(r-i)*o+i).toFixed(7)]};var e=function(t,i,e,n,r){return t.beginPath(),t.translate(e,n),t.rotate(r),t.font=i.fontStyle+" "+i.fontWeight+" "+i.fontSize+"px "+i.fontFamily,t},n=function(t,e,n,r,o,s,_,a){if(o>s){var h=o;o=s,s=h}return _%=2*Math.PI,a>=1.999999*Math.PI||a<=1.999999*-Math.PI?a=2*Math.PI:a%=2*Math.PI,function(t,e,n,r,o,s,_){e<0&&(t+=e,e*=-1);var a,h=[];a=i(0,0,t,o,0),h[0]=a[0],h[1]=a[1],a=i(0,0,e,a[0],a[1]),h[2]=a[0],h[3]=a[1],a=i(0,0,t,s,0),h[4]=a[0],h[5]=a[1],a=i(0,0,e,a[0],a[1]),h[6]=a[0],h[7]=a[1],_(t,t+e,h[0]+n,h[1]+r,h[4]+n,h[5]+r,h[2]+n,h[3]+r,h[6]+n,h[7]+r,.5*(s-o))}(_,a,n,r,o,s,(function(i,_,a,h,l,p,f,u,g,c,y){y<0&&(y=-y),t.beginPath(),t.moveTo(a,h),t.arc(n,r,o,i,_,!1),"round"==e.arcEndCap?t.arc(.5*(f+g),.5*(u+c),y,_-Math.PI,_,!0):"-round"==e.arcEndCap?t.arc(.5*(f+g),.5*(u+c),y,_-Math.PI,_,!1):t.lineTo(g,c),t.arc(n,r,s,_,i,!0),"round"==e.arcStartCap?t.arc(.5*(a+l),.5*(h+p),y,i,i-Math.PI,!0):"-round"==e.arcStartCap?t.arc(.5*(a+l),.5*(h+p),y,i,i-Math.PI,!1):t.lineTo(a,h)})),"butt"==e.arcStartCap&&t.closePath(),t},r=function(t,i,e,n){return t.beginPath(),t.moveTo(i+n,e),t.arc(i,e,n,0,2*Math.PI),t},o=function(t,i,e,n,r){return t.beginPath(),t.rect(i,e,n,r),t};function s(t,i,e,n,r){for(var o=0,s="",_=0;_<i.length;_++)t.measureText(s+i[_]).width>e||/\n$/.test(s)?(r(s,((o+=1)-.5)*n),s=i[_]):_==i.length-1?(o+=1,r(s+i[_],(o-.5)*n)):s+=i[_];return o*n}var _=function(){function t(t,i,e,n){void 0===i&&(i={}),void 0===n&&(n=!1),this.__region=null,this.__onlyRegion=!1,this.__specialConfig={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",arcStartCap:"butt",arcEndCap:"butt"},this.__initConfig={fillStyle:"black",strokeStyle:"black",lineWidth:1,textAlign:"left",textBaseline:"middle",lineDash:[],shadowBlur:0,shadowColor:"black"},this.painter=t.getContext("2d",i),this.__region=e,this.__isPainter=n,this.painter.textBaseline="middle",this.painter.textAlign="left"}return t.prototype.useConfig=function(t,i){if(this.__region&&["fillStyle","strokeStyle","shadowBlur","shadowColor"].indexOf(t)<0&&this.__region.useConfig(t,i),this.__isPainter&&this.__onlyRegion)return this;if("lineDash"==t)this.painter.setLineDash&&this.painter.setLineDash(i);else if(t in this.__specialConfig)"fontSize"==t&&(i=Math.round(i)),this.__specialConfig[t]=i;else{if(!(t in this.__initConfig))throw new Error("Illegal configuration item of painter : "+t+" !");this.painter[t]=i}return this},t.prototype.fillText=function(t,i,n,r){return void 0===r&&(r=0),this.__region&&this.__region.fillText(t,i,n,r),this.__isPainter&&this.__onlyRegion||(this.painter.save(),e(this.painter,this.__specialConfig,i,n,r).fillText(t,0,0),this.painter.restore()),this},t.prototype.strokeText=function(t,i,n,r){return void 0===r&&(r=0),this.__region&&this.__region.strokeText(t,i,n,r),this.__isPainter&&this.__onlyRegion||(this.painter.save(),e(this.painter,this.__specialConfig,i,n,r).strokeText(t,0,0),this.painter.restore()),this},t.prototype.fullText=function(t,i,n,r){return void 0===r&&(r=0),this.__region&&this.__region.fullText(t,i,n,r),this.__isPainter&&this.__onlyRegion||(this.painter.save(),e(this.painter,this.__specialConfig,i,n,r),this.painter.fillText(t,0,0),this.painter.strokeText(t,0,0),this.painter.restore()),this},t.prototype.fillTexts=function(t,i,n,r,o,_){var a=this;void 0===o&&(o=1.2),void 0===_&&(_=0);var h=0;if(this.__region&&(h=this.__region.fillTexts(t,i,n,r,o)),this.__isPainter&&this.__onlyRegion)return h;this.painter.save(),e(this.painter,this.__specialConfig,i,n,_);var l=s(this.painter,t,r,this.__specialConfig.fontSize*o,(function(t,i){a.painter.fillText(t,0,i)}));return this.painter.restore(),l},t.prototype.strokeTexts=function(t,i,n,r,o,_){var a=this;void 0===o&&(o=1.2),void 0===_&&(_=0);var h=0;if(this.__region&&(h=this.__region.fillTexts(t,i,n,r,o)),this.__isPainter&&this.__onlyRegion)return h;this.painter.save(),e(this.painter,this.__specialConfig,i,n,_);var l=s(this.painter,t,r,this.__specialConfig.fontSize*o,(function(t,i){a.painter.strokeText(t,0,i)}));return this.painter.restore(),l},t.prototype.fullTexts=function(t,i,n,r,o,_){var a=this;void 0===o&&(o=1.2),void 0===_&&(_=0);var h=0;if(this.__region&&(h=this.__region.fillTexts(t,i,n,r,o)),this.__isPainter&&this.__onlyRegion)return h;this.painter.save(),e(this.painter,this.__specialConfig,i,n,_);var l=s(this.painter,t,r,this.__specialConfig.fontSize*o,(function(t,i){a.painter.fillText(t,0,i),a.painter.strokeText(t,0,i)}));return this.painter.restore(),l},t.prototype.beginPath=function(){return this.__region&&this.__region.beginPath(),this.__isPainter&&this.__onlyRegion||this.painter.beginPath(),this},t.prototype.closePath=function(){return this.__region&&this.__region.closePath(),this.__isPainter&&this.__onlyRegion||this.painter.closePath(),this},t.prototype.moveTo=function(t,i){return this.__region&&this.__region.moveTo(t,i),this.__isPainter&&this.__onlyRegion||this.painter.moveTo(Math.round(t)+.5,Math.round(i)+.5),this},t.prototype.lineTo=function(t,i){return this.__region&&this.__region.lineTo(t,i),this.__isPainter&&this.__onlyRegion||this.painter.lineTo(Math.round(t)+.5,Math.round(i)+.5),this},t.prototype.arc=function(t,i,e,n,r){return this.__region&&this.__region.arc(t,i,e,n,r),this.__isPainter&&this.__onlyRegion||this.painter.arc(t,i,e,n,n+r,r<0),this},t.prototype.fill=function(){return this.__region&&this.__region.fill(),this.__isPainter&&this.__onlyRegion||this.painter.fill(),this},t.prototype.stroke=function(){return this.__region&&this.__region.stroke(),this.__isPainter&&this.__onlyRegion||this.painter.stroke(),this},t.prototype.full=function(){return this.__region&&this.__region.full(),this.__isPainter&&this.__onlyRegion||(this.painter.fill(),this.painter.stroke()),this},t.prototype.save=function(){return this.__region&&this.__region.save(),this.__isPainter&&this.__onlyRegion||this.painter.save(),this},t.prototype.restore=function(){return this.__region&&this.__region.restore(),this.__isPainter&&this.__onlyRegion||this.painter.restore(),this},t.prototype.clip=function(){return this.__region&&this.__region.clip(),this.__isPainter&&this.__onlyRegion||this.painter.clip(),this},t.prototype.quadraticCurveTo=function(t,i,e,n){return this.__region&&this.__region.quadraticCurveTo(t,i,e,n),this.__isPainter&&this.__onlyRegion||this.painter.quadraticCurveTo(t,i,e,n),this},t.prototype.bezierCurveTo=function(t,i,e,n,r,o){return this.__region&&this.__region.bezierCurveTo(t,i,e,n,r,o),this.__isPainter&&this.__onlyRegion||this.painter.bezierCurveTo(t,i,e,n,r,o),this},t.prototype.clearRect=function(t,i,e,n){return this.__region&&this.__region.clearRect(t,i,e,n),this.__isPainter&&this.__onlyRegion||this.painter.clearRect(t,i,e,n),this},t.prototype.fillArc=function(t,i,e,r,o,s){return this.__region&&this.__region.fillArc(t,i,e,r,o,s),this.__isPainter&&this.__onlyRegion||n(this.painter,this.__specialConfig,t,i,e,r,o,s).fill(),this},t.prototype.strokeArc=function(t,i,e,r,o,s){return this.__region&&this.__region.strokeArc(t,i,e,r,o,s),this.__isPainter&&this.__onlyRegion||n(this.painter,this.__specialConfig,t,i,e,r,o,s).stroke(),this},t.prototype.fullArc=function(t,i,e,r,o,s){return this.__region&&this.__region.fullArc(t,i,e,r,o,s),this.__isPainter&&this.__onlyRegion||(n(this.painter,this.__specialConfig,t,i,e,r,o,s),this.painter.fill(),this.painter.stroke()),this},t.prototype.fillCircle=function(t,i,e){return this.__region&&this.__region.fillCircle(t,i,e),this.__isPainter&&this.__onlyRegion||r(this.painter,t,i,e).fill(),this},t.prototype.strokeCircle=function(t,i,e){return this.__region&&this.__region.strokeCircle(t,i,e),this.__isPainter&&this.__onlyRegion||r(this.painter,t,i,e).stroke(),this},t.prototype.fullCircle=function(t,i,e){return this.__region&&this.__region.fullCircle(t,i,e),this.__isPainter&&this.__onlyRegion||(r(this.painter,t,i,e),this.painter.fill(),this.painter.stroke()),this},t.prototype.fillRect=function(t,i,e,n){return this.__region&&this.__region.fillRect(t,i,e,n),this.__isPainter&&this.__onlyRegion||o(this.painter,t,i,e,n).fill(),this},t.prototype.strokeRect=function(t,i,e,n){return this.__region&&this.__region.strokeRect(t,i,e,n),this.__isPainter&&this.__onlyRegion||o(this.painter,t,i,e,n).stroke(),this},t.prototype.fullRect=function(t,i,e,n){return this.__region&&this.__region.fullRect(t,i,e,n),this.__isPainter&&this.__onlyRegion||(o(this.painter,t,i,e,n),this.painter.fill(),this.painter.stroke()),this},t.prototype.draw=function(){},t}();var a={"font-size":"fontSize","font-family":"fontFamily","font-weight":"fontWeight","font-style":"fontStyle","arc-start-cap":"arcStartCap","arc-end-cap":"arcEndCap"},h=function(i){function n(t,e){var n=i.call(this,t,{},e?new _(e,{willReadFrequently:!0}):null,!0)||this;return n.name="Canvas",n.__regionList={},n.__regionAssemble=function(t,i,e,n){for(var r=[],o=0;o<n;o++)r[o]=t;return function(){for(var o=0;o<n;o++){if(r[o]+e<i){r[o]=+(r[o]+e).toFixed(7);break}o<n-1&&(r[o]=t)}return r}}(0,255,10,3),n.setRegion(""),n}return function(i,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=i}t(i,e),i.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,i),n.prototype.config=function(t){for(var i in t){var e=a[i]||i;this.useConfig(e,t[i])}return this},n.prototype.onlyRegion=function(t){return this.__onlyRegion=t,this},n.prototype.setRegion=function(t){if(this.__region)if(t){if(null==this.__regionList[t]){var i=this.__regionAssemble();this.__regionList[t]="rgb("+i[0]+","+i[1]+","+i[2]+")"}this.__region.useConfig("fillStyle",this.__regionList[t])&&this.__region.useConfig("strokeStyle",this.__regionList[t])}else this.__region.useConfig("fillStyle","#000000")&&this.__region.useConfig("strokeStyle","#000000");return this},n.prototype.getRegion=function(t,i){var e=this;return new Promise((function(n,r){var o=e.__region?e.__region.painter.getImageData(t-.5,i-.5,1,1):{data:[0,0,0,0]},s=o.data,_=function(){if(e.__region)for(var t in e.__regionList)if("rgb("+s[0]+","+s[1]+","+s[2]+")"==e.__regionList[t]){n(t);break}n("")};s?_():o.then((function(t){s=t,_()}))}))},n.prototype.textWidth=function(t){this.painter.save(),e(this.painter,this.__specialConfig,0,0,0);var i=this.painter.measureText(t+"").width;return this.painter.restore(),i},n.prototype.getContext=function(t){return void 0===t&&(t=!1),t?this.__region?this.__region.painter:null:this.painter},n.prototype.createLinearGradient=function(t,i,e,n){return function(t,i,e,n,r){var o=t.createLinearGradient(i,e,n,r),s={value:function(){return o},setColor:function(t,i){return o.addColorStop(t,i),s}};return s}(this.painter,t,i,e,n)},n.prototype.createRadialGradient=function(t,i,e){return function(t,i,e,n){var r=t.createRadialGradient(i,e,0,i,e,n),o={value:function(){return r},setColor:function(t,i){return r.addColorStop(t,i),o}};return o}(this.painter,t,i,e)},n.prototype.getColor=function(t,i){var e=this.painter.getImageData(t-.5,i-.5,1,1).data;return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},n}(_);export{h as default};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
/******************************************************************************
|
|
12
12
|
Copyright (c) Microsoft Corporation.
|
|
@@ -241,9 +241,7 @@ var BufferObject = (function () {
|
|
|
241
241
|
|
|
242
242
|
var initTexture = function (painter, type, unit) {
|
|
243
243
|
var texture = painter.createTexture();
|
|
244
|
-
|
|
245
|
-
painter.activeTexture(painter['TEXTURE' + unit]);
|
|
246
|
-
}
|
|
244
|
+
painter.activeTexture(painter['TEXTURE' + unit]);
|
|
247
245
|
painter.bindTexture(type, texture);
|
|
248
246
|
return texture;
|
|
249
247
|
};
|
|
@@ -339,18 +337,44 @@ var ShaderObject = (function () {
|
|
|
339
337
|
return ShaderObject;
|
|
340
338
|
}());
|
|
341
339
|
|
|
340
|
+
var vsColor = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n\r\n // 把原生的WebGL使用的左手坐标系变成了右手坐标系\r\n temp.z = -1.0 * temp.z;\r\n\r\n // 表示眼睛距离vec4(0.0,0.0,1.0)的距离\r\n float dist = 4.0;\r\n\r\n // 使用投影直接计算\r\n // 为保证纹理和相对位置正确\r\n // x、y、z的改变满足线性变换\r\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));\r\n}";
|
|
341
|
+
|
|
342
|
+
var vsColors = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\nattribute vec4 a_color;\r\nvarying vec4 v_color;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n temp.z = -1.0 * temp.z;\r\n float dist = 4.0;\r\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));\r\n\r\n v_color = a_color;\r\n}";
|
|
343
|
+
|
|
344
|
+
var vsImage = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\nattribute vec2 a_textcoord;\r\nvarying vec2 v_textcoord;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n temp.z = -1.0 * temp.z;\r\n float dist = 4.0;\r\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));\r\n\r\n v_textcoord = a_textcoord;\r\n}";
|
|
345
|
+
|
|
346
|
+
var vsCube = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\nattribute vec4 a_normal;\r\nvarying vec3 v_normal;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n temp.z = -1.0 * temp.z;\r\n float dist = 4.0;\r\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));\r\n\r\n v_normal = normalize(vec3(a_normal));\r\n}";
|
|
347
|
+
|
|
348
|
+
var fsColor = "precision mediump float;\r\n\r\nuniform vec4 u_color;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = u_color;\r\n}";
|
|
349
|
+
|
|
350
|
+
var fsColors = "precision mediump float;\r\n\r\nvarying vec4 v_color;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = v_color;\r\n}";
|
|
351
|
+
|
|
352
|
+
var fsImage = "precision mediump float;\r\n\r\nuniform sampler2D u_sampler;\r\nvarying vec2 v_textcoord;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = texture2D(u_sampler, v_textcoord);\r\n}";
|
|
353
|
+
|
|
354
|
+
var fsCube = "precision mediump float;\r\n\r\nvarying vec3 v_normal;\r\nuniform samplerCube u_texture;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = textureCube(u_texture, normalize(v_normal));\r\n}";
|
|
355
|
+
|
|
342
356
|
var shaders = {};
|
|
343
357
|
function getShader (type, painter, mesh) {
|
|
358
|
+
var _a, _b;
|
|
344
359
|
var uniqueName = type +
|
|
345
|
-
(mesh.geometry.attributes.normal ? "1" : "0") +
|
|
346
|
-
(mesh.material.image ? "1" : "0") +
|
|
347
360
|
(mesh.material.color ? "1" : "0") +
|
|
348
361
|
(mesh.material.colors ? "1" : "0") +
|
|
362
|
+
(mesh.material.image ? "1" : "0") +
|
|
349
363
|
(mesh.material.cube ? "1" : "0");
|
|
350
364
|
if (shaders[uniqueName])
|
|
351
365
|
return shaders[uniqueName].use();
|
|
352
|
-
var vertexShader =
|
|
353
|
-
|
|
366
|
+
var vertexShader = (_a = {},
|
|
367
|
+
_a[type + "1000"] = vsColor,
|
|
368
|
+
_a[type + "0100"] = vsColors,
|
|
369
|
+
_a[type + "0010"] = vsImage,
|
|
370
|
+
_a[type + "0001"] = vsCube,
|
|
371
|
+
_a)[uniqueName].replace(/uniform +mat4 +u_matrix;/, "\n uniform mat4 u_matrix_world;\n uniform mat4 u_matrix_mesh;\n uniform mat4 u_matrix_proporion;").replace(/u_matrix +\* +a_position/, "u_matrix_proporion * u_matrix_world * u_matrix_mesh * a_position");
|
|
372
|
+
var fragmentShader = (_b = {},
|
|
373
|
+
_b[type + "1000"] = fsColor,
|
|
374
|
+
_b[type + "0100"] = fsColors,
|
|
375
|
+
_b[type + "0010"] = fsImage,
|
|
376
|
+
_b[type + "0001"] = fsCube,
|
|
377
|
+
_b)[uniqueName];
|
|
354
378
|
var shader = new ShaderObject(painter).compile(vertexShader, fragmentShader).use();
|
|
355
379
|
shaders[uniqueName] = shader;
|
|
356
380
|
return shader;
|
|
@@ -379,6 +403,7 @@ function doDraw (type, painter, mesh, meshWorld, globalWorld) {
|
|
|
379
403
|
}
|
|
380
404
|
else if ("cube" in mesh.material) {
|
|
381
405
|
var size = mesh.material.cube.right.image.value.width;
|
|
406
|
+
painter.uniform1i(painter.getUniformLocation(shader.program, "u_texture"), 0);
|
|
382
407
|
getTexture(type, painter, 'cube').useCube([
|
|
383
408
|
mesh.material.cube.right.image.value,
|
|
384
409
|
mesh.material.cube.left.image.value,
|
|
@@ -553,7 +578,7 @@ var WebGL = (function () {
|
|
|
553
578
|
WebGL.prototype.setRegion = function (regionName) {
|
|
554
579
|
this.__regionName = regionName + "";
|
|
555
580
|
if (regionName) {
|
|
556
|
-
if (this.__regionList[regionName] ==
|
|
581
|
+
if (this.__regionList[regionName] == void 0) {
|
|
557
582
|
this.__regionList[regionName] = __spreadArray(__spreadArray([], this.__regionAssemble(), true), [1], false);
|
|
558
583
|
}
|
|
559
584
|
this.__regionColor = this.__regionList[regionName];
|