vislite 0.1.1 → 0.2.0-alpha.7
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 +19 -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 +567 -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 +626 -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 -863
- 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 +62 -0
- package/src/common/webgl/getTexture.ts +12 -0
- package/src/common/webgl/getWebGLContext.ts +28 -0
- package/src/common/webgl/index.ts +212 -0
- package/src/common/webgl/shader.ts +76 -0
- package/src/common/webgl/texture.ts +99 -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 +106 -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 +29 -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 +79 -7
- package/types/Eoap.d.ts +0 -10
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
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
|
var t,e;t=this,e=function(){"use strict";var t=function(t,e,n,i){var o=Math.cos(t),a=Math.sin(t);return[e*o-n*a,e*a+n*o,i]};return function(){function e(t,e){void 0===t&&(t=7),void 0===e&&(e=[107,36]),this.name="Eoap",this.__scale=t,this.__center=e}return e.prototype.use=function(e,n){var i,o,a,s,r,h,u=(i=(360-n)/180*Math.PI,o=100*this.__scale,a=0,s=0,r=Math.cos(i),h=Math.sin(i),[s*h+o*r,a,s*r-o*h]);return u=t(e/180*Math.PI,u[0],u[1],u[2]),u=t((90-this.__center[0])/180*Math.PI,u[0],u[1],u[2]),u=function(t,e,n,i){var o=Math.cos(t),a=Math.sin(t);return[e,n*o-i*a,n*a+i*o]}((90-this.__center[1])/180*Math.PI,u[0],u[1],u[2]),[-u[0],u[1],u[2]]},e}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_Eoap=e();
|
package/lib/Hermite/index.umd.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
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() :
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
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
|
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,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
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() :
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
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
|
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();
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
3
|
+
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
|
+
*
|
|
5
|
+
* Copyright zxl20070701
|
|
6
|
+
* Released under the MIT license
|
|
7
|
+
* https://zxl20070701.github.io/notebook/home.html
|
|
8
|
+
*
|
|
9
|
+
* 本版本系测试版本,请认真阅读下述说明再使用:
|
|
10
|
+
*
|
|
11
|
+
*【测试版本细则】
|
|
12
|
+
* alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
|
|
13
|
+
* beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
|
|
14
|
+
*/
|
|
15
|
+
(function (global, factory) {
|
|
16
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
17
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
18
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_Mercator = factory());
|
|
19
|
+
})(this, (function () { 'use strict';
|
|
20
|
+
|
|
21
|
+
var Mercator = (function () {
|
|
22
|
+
function Mercator(scale, center) {
|
|
23
|
+
if (scale === void 0) { scale = 7; }
|
|
24
|
+
if (center === void 0) { center = [107, 36]; }
|
|
25
|
+
this.name = 'Mercator';
|
|
26
|
+
var perimeter = 100 * scale * Math.PI;
|
|
27
|
+
var help = perimeter / 180;
|
|
28
|
+
var cx = help * center[0];
|
|
29
|
+
var cy = -1 * help * center[1];
|
|
30
|
+
this.use = function (λ, φ) {
|
|
31
|
+
return [
|
|
32
|
+
(help * λ - cx) * 0.8,
|
|
33
|
+
-1 * help * φ - cy
|
|
34
|
+
];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return Mercator;
|
|
38
|
+
}());
|
|
39
|
+
|
|
40
|
+
return Mercator;
|
|
41
|
+
|
|
42
|
+
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
3
|
+
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
|
+
*
|
|
5
|
+
* Copyright zxl20070701
|
|
6
|
+
* Released under the MIT license
|
|
7
|
+
* https://zxl20070701.github.io/notebook/home.html
|
|
8
|
+
*
|
|
9
|
+
* 本版本系测试版本,请认真阅读下述说明再使用:
|
|
10
|
+
*
|
|
11
|
+
*【测试版本细则】
|
|
12
|
+
* alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
|
|
13
|
+
* beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
|
|
14
|
+
*/
|
|
15
|
+
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,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
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
|
/******************************************************************************
|
|
12
16
|
Copyright (c) Microsoft Corporation.
|
|
@@ -71,7 +75,7 @@ var initText = function (painter, config, x, y, deg) {
|
|
|
71
75
|
painter.beginPath();
|
|
72
76
|
painter.translate(x, y);
|
|
73
77
|
painter.rotate(deg);
|
|
74
|
-
painter.font = config
|
|
78
|
+
painter.font = config.fontStyle + " " + config.fontWeight + " " + config.fontSize + "px " + config.fontFamily;
|
|
75
79
|
return painter;
|
|
76
80
|
};
|
|
77
81
|
var initArc = function (painter, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
@@ -93,17 +97,17 @@ var initArc = function (painter, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
|
93
97
|
painter.beginPath();
|
|
94
98
|
painter.moveTo(begInnerX, begInnerY);
|
|
95
99
|
painter.arc(cx, cy, r1, beginA, endA, false);
|
|
96
|
-
if (config
|
|
100
|
+
if (config.arcEndCap != 'round')
|
|
97
101
|
painter.lineTo(endOuterX, endOuterY);
|
|
98
102
|
else
|
|
99
103
|
painter.arc((endInnerX + endOuterX) * 0.5, (endInnerY + endOuterY) * 0.5, r, endA - Math.PI, endA, true);
|
|
100
104
|
painter.arc(cx, cy, r2, endA, beginA, true);
|
|
101
|
-
if (config
|
|
105
|
+
if (config.arcStartCap != 'round')
|
|
102
106
|
painter.lineTo(begInnerX, begInnerY);
|
|
103
107
|
else
|
|
104
108
|
painter.arc((begInnerX + begOuterX) * 0.5, (begInnerY + begOuterY) * 0.5, r, beginA, beginA - Math.PI, true);
|
|
105
109
|
});
|
|
106
|
-
if (config
|
|
110
|
+
if (config.arcStartCap == 'butt')
|
|
107
111
|
painter.closePath();
|
|
108
112
|
return painter;
|
|
109
113
|
};
|
|
@@ -119,17 +123,36 @@ var initRect = function (painter, x, y, width, height) {
|
|
|
119
123
|
return painter;
|
|
120
124
|
};
|
|
121
125
|
|
|
126
|
+
function texts (painter, contents, width, height, doback) {
|
|
127
|
+
var lineNumber = 0, content = "";
|
|
128
|
+
for (var i = 0; i < contents.length; i++) {
|
|
129
|
+
if (painter.measureText(content + contents[i]).width > width) {
|
|
130
|
+
lineNumber += 1;
|
|
131
|
+
doback(content, (lineNumber - 0.5) * height);
|
|
132
|
+
content = contents[i];
|
|
133
|
+
}
|
|
134
|
+
else if (i == contents.length - 1) {
|
|
135
|
+
lineNumber += 1;
|
|
136
|
+
doback(content + contents[i], (lineNumber - 0.5) * height);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
content += contents[i];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return lineNumber * height;
|
|
143
|
+
}
|
|
144
|
+
|
|
122
145
|
var Painter = (function () {
|
|
123
146
|
function Painter(canvas, opts, region) {
|
|
124
147
|
if (opts === void 0) { opts = {}; }
|
|
125
148
|
this.__region = null;
|
|
126
149
|
this.__specialConfig = {
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
150
|
+
"fontSize": 16,
|
|
151
|
+
"fontFamily": "sans-serif",
|
|
152
|
+
"fontWeight": 400,
|
|
153
|
+
"fontStyle": "normal",
|
|
154
|
+
"arcStartCap": 'butt',
|
|
155
|
+
"arcEndCap": 'butt'
|
|
133
156
|
};
|
|
134
157
|
this.__initConfig = {
|
|
135
158
|
"fillStyle": 'black',
|
|
@@ -181,7 +204,7 @@ var Painter = (function () {
|
|
|
181
204
|
if (this.__region)
|
|
182
205
|
this.__region.strokeText(text, x, y, deg);
|
|
183
206
|
this.painter.save();
|
|
184
|
-
initText(this.painter, this.__specialConfig, x, y, deg
|
|
207
|
+
initText(this.painter, this.__specialConfig, x, y, deg).strokeText(text, 0, 0);
|
|
185
208
|
this.painter.restore();
|
|
186
209
|
return this;
|
|
187
210
|
};
|
|
@@ -190,12 +213,55 @@ var Painter = (function () {
|
|
|
190
213
|
if (this.__region)
|
|
191
214
|
this.__region.fullText(text, x, y, deg);
|
|
192
215
|
this.painter.save();
|
|
193
|
-
initText(this.painter, this.__specialConfig, x, y, deg
|
|
216
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
194
217
|
this.painter.fillText(text, 0, 0);
|
|
195
218
|
this.painter.strokeText(text, 0, 0);
|
|
196
219
|
this.painter.restore();
|
|
197
220
|
return this;
|
|
198
221
|
};
|
|
222
|
+
Painter.prototype.fillTexts = function (contents, x, y, width, lineHeight, deg) {
|
|
223
|
+
var _this = this;
|
|
224
|
+
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
225
|
+
if (deg === void 0) { deg = 0; }
|
|
226
|
+
if (this.__region)
|
|
227
|
+
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
228
|
+
this.painter.save();
|
|
229
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
230
|
+
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
231
|
+
_this.painter.fillText(content, 0, top);
|
|
232
|
+
});
|
|
233
|
+
this.painter.restore();
|
|
234
|
+
return height;
|
|
235
|
+
};
|
|
236
|
+
Painter.prototype.strokeTexts = function (contents, x, y, width, lineHeight, deg) {
|
|
237
|
+
var _this = this;
|
|
238
|
+
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
239
|
+
if (deg === void 0) { deg = 0; }
|
|
240
|
+
if (this.__region)
|
|
241
|
+
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
242
|
+
this.painter.save();
|
|
243
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
244
|
+
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
245
|
+
_this.painter.strokeText(content, 0, top);
|
|
246
|
+
});
|
|
247
|
+
this.painter.restore();
|
|
248
|
+
return height;
|
|
249
|
+
};
|
|
250
|
+
Painter.prototype.fullTexts = function (contents, x, y, width, lineHeight, deg) {
|
|
251
|
+
var _this = this;
|
|
252
|
+
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
253
|
+
if (deg === void 0) { deg = 0; }
|
|
254
|
+
if (this.__region)
|
|
255
|
+
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
256
|
+
this.painter.save();
|
|
257
|
+
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
258
|
+
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
259
|
+
_this.painter.fillText(content, 0, top);
|
|
260
|
+
_this.painter.strokeText(content, 0, top);
|
|
261
|
+
});
|
|
262
|
+
this.painter.restore();
|
|
263
|
+
return height;
|
|
264
|
+
};
|
|
199
265
|
Painter.prototype.beginPath = function () {
|
|
200
266
|
if (this.__region)
|
|
201
267
|
this.__region.beginPath();
|
|
@@ -338,46 +404,56 @@ var Painter = (function () {
|
|
|
338
404
|
return Painter;
|
|
339
405
|
}());
|
|
340
406
|
|
|
407
|
+
function assemble (begin, end, step, count) {
|
|
408
|
+
var val = [];
|
|
409
|
+
for (var index = 0; index < count; index++)
|
|
410
|
+
val[index] = begin;
|
|
411
|
+
return function () {
|
|
412
|
+
for (var i = 0; i < count; i++) {
|
|
413
|
+
if (val[i] < end) {
|
|
414
|
+
val[i] = +(val[i] + step).toFixed(7);
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
else if (i < count - 1) {
|
|
418
|
+
val[i] = begin;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return val;
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
var oldAttrName = {
|
|
426
|
+
"font-size": "fontSize",
|
|
427
|
+
"font-family": "fontFamily",
|
|
428
|
+
"font-weight": "fontWeight",
|
|
429
|
+
"font-style": "fontStyle",
|
|
430
|
+
"arc-start-cap": "arcStartCap",
|
|
431
|
+
"arc-end-cap": "arcEndCap"
|
|
432
|
+
};
|
|
341
433
|
var Canvas = (function (_super) {
|
|
342
434
|
__extends(Canvas, _super);
|
|
343
435
|
function Canvas(ViewCanvas, RegionCanvas) {
|
|
344
|
-
var
|
|
436
|
+
var _this = _super.call(this, ViewCanvas, {}, new Painter(RegionCanvas, {
|
|
345
437
|
willReadFrequently: true
|
|
346
438
|
})) || this;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return _this_1;
|
|
439
|
+
_this.name = "Canvas";
|
|
440
|
+
_this.__regionList = {};
|
|
441
|
+
_this.__regionAssemble = assemble(0, 255, 1, 3);
|
|
442
|
+
_this.setRegion("");
|
|
443
|
+
return _this;
|
|
353
444
|
}
|
|
354
445
|
Canvas.prototype.config = function (configs) {
|
|
355
446
|
for (var key in configs) {
|
|
356
|
-
|
|
447
|
+
var _key = oldAttrName[key] || key;
|
|
448
|
+
this.useConfig(_key, configs[key]);
|
|
357
449
|
}
|
|
358
450
|
return this;
|
|
359
451
|
};
|
|
360
452
|
Canvas.prototype.setRegion = function (regionName) {
|
|
361
|
-
var _this = this;
|
|
362
453
|
if (regionName) {
|
|
363
454
|
if (this.__regionList[regionName] == undefined) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
_this.__rgb[0] += 1;
|
|
367
|
-
_this.__p = 'g';
|
|
368
|
-
return 'rgb(' + _this.__rgb[0] + ',' + _this.__rgb[1] + ',' + _this.__rgb[2] + ')';
|
|
369
|
-
},
|
|
370
|
-
'g': function () {
|
|
371
|
-
_this.__rgb[1] += 1;
|
|
372
|
-
_this.__p = 'b';
|
|
373
|
-
return 'rgb(' + _this.__rgb[0] + ',' + _this.__rgb[1] + ',' + _this.__rgb[2] + ')';
|
|
374
|
-
},
|
|
375
|
-
'b': function () {
|
|
376
|
-
_this.__rgb[2] += 1;
|
|
377
|
-
_this.__p = 'r';
|
|
378
|
-
return 'rgb(' + _this.__rgb[0] + ',' + _this.__rgb[1] + ',' + _this.__rgb[2] + ')';
|
|
379
|
-
}
|
|
380
|
-
}[this.__p]();
|
|
455
|
+
var tempColor = this.__regionAssemble();
|
|
456
|
+
this.__regionList[regionName] = "rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")";
|
|
381
457
|
}
|
|
382
458
|
this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
|
|
383
459
|
this.__region.useConfig("strokeStyle", this.__regionList[regionName]);
|
|
@@ -389,13 +465,13 @@ var Canvas = (function (_super) {
|
|
|
389
465
|
return this;
|
|
390
466
|
};
|
|
391
467
|
Canvas.prototype.getRegion = function (x, y) {
|
|
392
|
-
var
|
|
468
|
+
var _this = this;
|
|
393
469
|
return new Promise(function (resolve, reject) {
|
|
394
|
-
var imgData =
|
|
470
|
+
var imgData = _this.__region.painter.getImageData(x - 0.5, y - 0.5, 1, 1);
|
|
395
471
|
var currentRGBA = imgData.data;
|
|
396
472
|
var doit = function () {
|
|
397
|
-
for (var key in
|
|
398
|
-
if ("rgb(" + currentRGBA[0] + "," + currentRGBA[1] + "," + currentRGBA[2] + ")" ==
|
|
473
|
+
for (var key in _this.__regionList) {
|
|
474
|
+
if ("rgb(" + currentRGBA[0] + "," + currentRGBA[1] + "," + currentRGBA[2] + ")" == _this.__regionList[key]) {
|
|
399
475
|
resolve(key);
|
|
400
476
|
break;
|
|
401
477
|
}
|
|
@@ -413,6 +489,10 @@ var Canvas = (function (_super) {
|
|
|
413
489
|
}
|
|
414
490
|
});
|
|
415
491
|
};
|
|
492
|
+
Canvas.prototype.getContext = function (isRegion) {
|
|
493
|
+
if (isRegion === void 0) { isRegion = false; }
|
|
494
|
+
return isRegion ? this.__region.painter : this.painter;
|
|
495
|
+
};
|
|
416
496
|
return Canvas;
|
|
417
497
|
}(Painter));
|
|
418
498
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.2.0-alpha.7
|
|
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
|
-
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)};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
|
|
15
|
+
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)};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,_,l,p,f,u,c,g,y){y<0&&(y=-y),t.beginPath(),t.moveTo(h,_),t.arc(r,n,o,i,a,!1),"round"!=e.arcEndCap?t.lineTo(c,g):t.arc(.5*(f+c),.5*(u+g),y,a-Math.PI,a,!0),t.arc(r,n,s,a,i,!0),"round"!=e.arcStartCap?t.lineTo(h,_):t.arc(.5*(h+l),.5*(_+p),y,i,i-Math.PI,!0)})),"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(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)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.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 e(t,e){var r=i.call(this,t,{},new a(e,{willReadFrequently:!0}))||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]<i){n[o]=+(n[o]+e).toFixed(7);break}o<r-1&&(n[o]=t)}return n}}(0,255,1,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)}(e,i),e.prototype.config=function(t){for(var i in t){var e=h[i]||i;this.useConfig(e,t[i])}return this},e.prototype.setRegion=function(t){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},e.prototype.getRegion=function(t,i){var e=this;return new Promise((function(r,n){var o=e.__region.painter.getImageData(t-.5,i-.5,1,1),s=o.data,a=function(){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()}))}))},e.prototype.getContext=function(t){return void 0===t&&(t=!1),t?this.__region.painter:this.painter},e}(a);export{_ as default};
|