vislite 0.4.1-alpha.1 → 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 +32 -11
- 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 +131 -39
- 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 +110 -33
- package/lib/OralCanvas/index.es.min.js +3 -3
- package/lib/OralWebGL/index.es.js +55 -24
- 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 +80 -34
- 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 +632 -74
- 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/miniprogram/ui-canvas/index.js +23 -15
- package/miniprogram/ui-canvas/index.wxml +1 -1
- 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 +18 -7
- 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 +24 -11
- package/src/animation.ts +2 -3
- package/src/common/canvas/config.ts +2 -1
- package/src/common/canvas/index.ts +44 -30
- package/src/common/canvas/painter.ts +74 -5
- package/src/common/canvas/texts.ts +1 -1
- 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 +28 -21
- 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 +8 -0
- 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/WebGLOption.d.ts +8 -0
- package/types/formatColor.d.ts +3 -0
- package/types/index.d.ts +29 -3
- package/types/resizeObserver.d.ts +3 -0
- package/types/throttle.d.ts +5 -0
- package/types/throttleOption.d.ts +20 -0
- package/uni-app/ui-canvas.vue +24 -14
package/.editorconfig
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# http://editorconfig.org
|
|
2
|
+
|
|
3
|
+
root = true
|
|
4
|
+
|
|
5
|
+
[*]
|
|
6
|
+
charset = utf-8
|
|
7
|
+
indent_style = space
|
|
8
|
+
indent_size = 4
|
|
9
|
+
end_of_line = cr
|
|
10
|
+
insert_final_newline = false
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
|
|
13
|
+
[*.md]
|
|
14
|
+
insert_final_newline = false
|
|
15
|
+
trim_trailing_whitespace = false
|
|
16
|
+
|
|
17
|
+
[*.json]
|
|
18
|
+
indent_size = 2
|
|
19
|
+
insert_final_newline = true
|
package/CHANGELOG
CHANGED
|
@@ -3,8 +3,8 @@ v0.1.0:
|
|
|
3
3
|
changes:
|
|
4
4
|
- 初始化版本
|
|
5
5
|
1、Canvas
|
|
6
|
-
(支持平台:H5、uni-app
|
|
7
|
-
2、SVG
|
|
6
|
+
(支持平台:H5、uni-app(包括:H5、微信小程序、支付宝小程序)、微信小程序)
|
|
7
|
+
2、SVG画笔
|
|
8
8
|
(支持平台:H5)
|
|
9
9
|
3、Eoap 等角斜方位投影
|
|
10
10
|
4、rotate 旋转
|
|
@@ -31,7 +31,7 @@ v0.2.0:
|
|
|
31
31
|
1、针对Canvas和SVG的画笔配置config的属性名,统一使用小驼峰
|
|
32
32
|
(对旧语法进行了向下兼容)
|
|
33
33
|
- 新增功能
|
|
34
|
-
1、WebGL
|
|
34
|
+
1、WebGL画笔
|
|
35
35
|
(支持平台:H5)
|
|
36
36
|
2、Mercator 墨卡托投影
|
|
37
37
|
3、Canvas新增功能
|
|
@@ -54,15 +54,15 @@ v0.3.0:
|
|
|
54
54
|
* render方法中itemSize设置无效问题
|
|
55
55
|
4、修复Cardinal插值超过界限的值问题
|
|
56
56
|
- 新增功能
|
|
57
|
-
1
|
|
57
|
+
1、Canvas画笔
|
|
58
58
|
* createLinearGradient 线性渐变色
|
|
59
59
|
* createRadialGradient 环形渐变色
|
|
60
60
|
* clip 裁剪
|
|
61
61
|
* 绘制圆弧系列(fillArc、strokeArc、fullArc)的闭合方式添加```-round```选项
|
|
62
62
|
* getColor 获取指定位置颜色
|
|
63
|
-
2
|
|
63
|
+
2、SVG画笔
|
|
64
64
|
* 绘制圆弧系列(fillArc、strokeArc、fullArc)的闭合方式添加```-round```选项
|
|
65
|
-
3
|
|
65
|
+
3、WebGL画笔
|
|
66
66
|
* 材料material新增多颜色值colors
|
|
67
67
|
4、朴素的WebGL接口集合
|
|
68
68
|
* getWebGLContext 画笔
|
|
@@ -79,14 +79,35 @@ v0.4.0:
|
|
|
79
79
|
date:2023-07-22
|
|
80
80
|
changes:
|
|
81
81
|
- 新增功能
|
|
82
|
-
1
|
|
83
|
-
* textWidth 计算文字宽
|
|
82
|
+
1、Canvas画笔
|
|
83
|
+
* textWidth 计算文字宽
|
|
84
84
|
v0.4.1:
|
|
85
85
|
date:
|
|
86
86
|
changes:
|
|
87
|
+
- 修复bug
|
|
88
|
+
1、uni-app平台的ui-canvas在微信小程序环境下有时会绘制失败并渲染过慢问题
|
|
89
|
+
2、Canvas画笔
|
|
90
|
+
* 多行文字(fillTexts、strokeTexts、fullTexts)在处理有换行文字时的未正确处理
|
|
87
91
|
- 优化改造
|
|
88
92
|
1、优化WebGL区域计算设计
|
|
89
|
-
2、uni-app平台的ui-canvas的方法draw对外暴露是否更丰富的参数
|
|
90
93
|
- 新增功能
|
|
91
|
-
1、
|
|
92
|
-
|
|
94
|
+
1、Canvas画笔
|
|
95
|
+
* 添加region配置,可以控制是否支持区域管理
|
|
96
|
+
* onlyRegion 区域模式
|
|
97
|
+
2、WebGL画笔
|
|
98
|
+
* 添加region配置,可以控制是否支持区域管理
|
|
99
|
+
3、uni-app平台的ui-canvas
|
|
100
|
+
* 画笔的draw方法对外暴露更丰富的参数
|
|
101
|
+
* 添加region属性,可以控制是否支持区域管理
|
|
102
|
+
4、微信小程序平台的ui-canvas
|
|
103
|
+
* 添加region属性,可以控制是否支持区域管理
|
|
104
|
+
5、viewHandler新增对悬浮hover事件的捕获并统一添加event参数
|
|
105
|
+
6、刻度尺算法ruler新增可选上下界约束
|
|
106
|
+
7、颜色格式化 formatColor
|
|
107
|
+
(支持平台:H5)
|
|
108
|
+
8、节点缩放监听 resizeObserver
|
|
109
|
+
(支持平台:H5)
|
|
110
|
+
9、节流函数 throttle
|
|
111
|
+
10、布局
|
|
112
|
+
* 树布局 treeLayout
|
|
113
|
+
11、着色器compile方法丰富参数(添加color、colors、image、cube四种内置着色器程序)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
- 开源不易,去 <i>[Github给个Star](https://github.com/oi-contrib/VISLite) </i>吧!
|
|
2
2
|
|
|
3
|
-
<img src='
|
|
3
|
+
<img src='./docs/images/logo.png' height='300px'/>
|
|
4
4
|
|
|
5
5
|
<p>
|
|
6
6
|
<a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=vislite&interval=7">
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
- 简单与复杂共存:一方面我们提供了可视化需要的基础功能,你可以按照自己的需要组合使用;另一方面,为了加速开发,我们针对常见的可视化业务场景进行了封装,可以帮助你快速完成,你可以根据实际情况进行选择。
|
|
28
28
|
- 向下兼容:我们向你保证,始终向下兼容```(alpha和beta版本为测试版本,不包括)```,因此,无论何时,最新版本总是最好的选择。
|
|
29
29
|
|
|
30
|
+
> 版本说明:alpha为开发阶段、beta为发布前测试、无后缀的为正式版本。
|
|
31
|
+
|
|
30
32
|
## 需求墙
|
|
31
33
|
|
|
32
34
|
我们的目标是不断完善丰富可视化功能,非常希望获得你宝贵的建议和批评,无论任何想法,都可以给我们[留言](https://github.com/oi-contrib/VISLite/issues)告诉我们。
|
|
@@ -47,6 +49,19 @@
|
|
|
47
49
|
|
|
48
50
|
给我们[留言](https://github.com/oi-contrib/VISLite/issues)告诉我们你希望快速扩展的功能,我们会优先你的建议考虑哦~
|
|
49
51
|
|
|
52
|
+
## 参与贡献
|
|
53
|
+
|
|
54
|
+
你可以选择下列一项或多项进行参与:
|
|
55
|
+
|
|
56
|
+
- 代码维护:由于新功能或一些BUG的出现,对代码进行维护和升级。
|
|
57
|
+
- 文档编辑:主要是接口文档和教程需要编辑,这很重要。
|
|
58
|
+
- 用例开发和测试:在项目的test文件夹下有一些测试,而在docs文档中存在一些例子需要补充。
|
|
59
|
+
- 参与讨论:主要是讨论未来如何发展,改造的方向等。
|
|
60
|
+
|
|
61
|
+
如果有意向加入我们,你可以通过提 [issue](https://github.com/oi-contrib/VISLite/issues) 和我们取到联系,请简单说明一下情况,我们会尽快回复。
|
|
62
|
+
|
|
63
|
+
你可以查看[VISLite 贡献指南](./.github/CONTRIBUTING.md)文件了解更多细节,查看[AUTHORS.txt](./AUTHORS.txt)了解所有的贡献者。
|
|
64
|
+
|
|
50
65
|
## 版权
|
|
51
66
|
|
|
52
67
|
MIT License
|
package/lib/Buffer/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,e;t=this,e=function(){"use strict";return function(){function t(t,e){void 0===e&&(e=!1),this.__painter=t,this.__isElement=e,this.__buffer=function(t){return t.createBuffer()}(t),this.__type=e?t.ELEMENT_ARRAY_BUFFER:t.ARRAY_BUFFER}return t.prototype.use=function(){return this.__painter.bindBuffer(this.__type,this.__buffer),this},t.prototype.write=function(t){return function(t,e,i,n){var r=i?t.ELEMENT_ARRAY_BUFFER:t.ARRAY_BUFFER;t.bufferData(r,e,n)}(this.__painter,t,this.__isElement,this.__painter.STATIC_DRAW),this.__fsize=t.BYTES_PER_ELEMENT,this},t.prototype.divide=function(t,e,i,n){return void 0===n&&(n=0),function(t,e,i,n,r,_,f){t.vertexAttribPointer(e,i,n,f,r,_),t.enableVertexAttribArray(e)}(this.__painter,t,e,this.__painter.FLOAT,i*this.__fsize,n*this.__fsize,!1),this},t}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_Buffer=e();
|
package/lib/Canvas/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() :
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
function texts (painter, contents, width, height, doback) {
|
|
145
145
|
var lineNumber = 0, content = "";
|
|
146
146
|
for (var i = 0; i < contents.length; i++) {
|
|
147
|
-
if (painter.measureText(content + contents[i]).width > width) {
|
|
147
|
+
if (painter.measureText(content + contents[i]).width > width || /\n$/.test(content)) {
|
|
148
148
|
lineNumber += 1;
|
|
149
149
|
doback(content, (lineNumber - 0.5) * height);
|
|
150
150
|
content = contents[i];
|
|
@@ -161,9 +161,11 @@
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
var Painter = (function () {
|
|
164
|
-
function Painter(canvas, opts, region) {
|
|
164
|
+
function Painter(canvas, opts, region, isPainter) {
|
|
165
165
|
if (opts === void 0) { opts = {}; }
|
|
166
|
+
if (isPainter === void 0) { isPainter = false; }
|
|
166
167
|
this.__region = null;
|
|
168
|
+
this.__onlyRegion = false;
|
|
167
169
|
this.__specialConfig = {
|
|
168
170
|
"fontSize": 16,
|
|
169
171
|
"fontFamily": "sans-serif",
|
|
@@ -184,6 +186,7 @@
|
|
|
184
186
|
};
|
|
185
187
|
this.painter = canvas.getContext("2d", opts);
|
|
186
188
|
this.__region = region;
|
|
189
|
+
this.__isPainter = isPainter;
|
|
187
190
|
this.painter.textBaseline = 'middle';
|
|
188
191
|
this.painter.textAlign = 'left';
|
|
189
192
|
}
|
|
@@ -193,6 +196,8 @@
|
|
|
193
196
|
this.__region.useConfig(key, value);
|
|
194
197
|
}
|
|
195
198
|
}
|
|
199
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
200
|
+
return this;
|
|
196
201
|
if (key == 'lineDash') {
|
|
197
202
|
if (this.painter.setLineDash)
|
|
198
203
|
this.painter.setLineDash(value);
|
|
@@ -215,6 +220,8 @@
|
|
|
215
220
|
if (deg === void 0) { deg = 0; }
|
|
216
221
|
if (this.__region)
|
|
217
222
|
this.__region.fillText(text, x, y, deg);
|
|
223
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
224
|
+
return this;
|
|
218
225
|
this.painter.save();
|
|
219
226
|
initText(this.painter, this.__specialConfig, x, y, deg).fillText(text, 0, 0);
|
|
220
227
|
this.painter.restore();
|
|
@@ -224,6 +231,8 @@
|
|
|
224
231
|
if (deg === void 0) { deg = 0; }
|
|
225
232
|
if (this.__region)
|
|
226
233
|
this.__region.strokeText(text, x, y, deg);
|
|
234
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
235
|
+
return this;
|
|
227
236
|
this.painter.save();
|
|
228
237
|
initText(this.painter, this.__specialConfig, x, y, deg).strokeText(text, 0, 0);
|
|
229
238
|
this.painter.restore();
|
|
@@ -233,6 +242,8 @@
|
|
|
233
242
|
if (deg === void 0) { deg = 0; }
|
|
234
243
|
if (this.__region)
|
|
235
244
|
this.__region.fullText(text, x, y, deg);
|
|
245
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
246
|
+
return this;
|
|
236
247
|
this.painter.save();
|
|
237
248
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
238
249
|
this.painter.fillText(text, 0, 0);
|
|
@@ -244,8 +255,11 @@
|
|
|
244
255
|
var _this = this;
|
|
245
256
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
246
257
|
if (deg === void 0) { deg = 0; }
|
|
258
|
+
var h = 0;
|
|
247
259
|
if (this.__region)
|
|
248
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
260
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
261
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
262
|
+
return h;
|
|
249
263
|
this.painter.save();
|
|
250
264
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
251
265
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -258,8 +272,11 @@
|
|
|
258
272
|
var _this = this;
|
|
259
273
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
260
274
|
if (deg === void 0) { deg = 0; }
|
|
275
|
+
var h = 0;
|
|
261
276
|
if (this.__region)
|
|
262
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
277
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
278
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
279
|
+
return h;
|
|
263
280
|
this.painter.save();
|
|
264
281
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
265
282
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -272,8 +289,11 @@
|
|
|
272
289
|
var _this = this;
|
|
273
290
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
274
291
|
if (deg === void 0) { deg = 0; }
|
|
292
|
+
var h = 0;
|
|
275
293
|
if (this.__region)
|
|
276
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
294
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
295
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
296
|
+
return h;
|
|
277
297
|
this.painter.save();
|
|
278
298
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
279
299
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -286,48 +306,64 @@
|
|
|
286
306
|
Painter.prototype.beginPath = function () {
|
|
287
307
|
if (this.__region)
|
|
288
308
|
this.__region.beginPath();
|
|
309
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
310
|
+
return this;
|
|
289
311
|
this.painter.beginPath();
|
|
290
312
|
return this;
|
|
291
313
|
};
|
|
292
314
|
Painter.prototype.closePath = function () {
|
|
293
315
|
if (this.__region)
|
|
294
316
|
this.__region.closePath();
|
|
317
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
318
|
+
return this;
|
|
295
319
|
this.painter.closePath();
|
|
296
320
|
return this;
|
|
297
321
|
};
|
|
298
322
|
Painter.prototype.moveTo = function (x, y) {
|
|
299
323
|
if (this.__region)
|
|
300
324
|
this.__region.moveTo(x, y);
|
|
325
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
326
|
+
return this;
|
|
301
327
|
this.painter.moveTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
302
328
|
return this;
|
|
303
329
|
};
|
|
304
330
|
Painter.prototype.lineTo = function (x, y) {
|
|
305
331
|
if (this.__region)
|
|
306
332
|
this.__region.lineTo(x, y);
|
|
333
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
334
|
+
return this;
|
|
307
335
|
this.painter.lineTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
308
336
|
return this;
|
|
309
337
|
};
|
|
310
338
|
Painter.prototype.arc = function (x, y, r, beginDeg, deg) {
|
|
311
339
|
if (this.__region)
|
|
312
340
|
this.__region.arc(x, y, r, beginDeg, deg);
|
|
341
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
342
|
+
return this;
|
|
313
343
|
this.painter.arc(x, y, r, beginDeg, beginDeg + deg, deg < 0);
|
|
314
344
|
return this;
|
|
315
345
|
};
|
|
316
346
|
Painter.prototype.fill = function () {
|
|
317
347
|
if (this.__region)
|
|
318
348
|
this.__region.fill();
|
|
349
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
350
|
+
return this;
|
|
319
351
|
this.painter.fill();
|
|
320
352
|
return this;
|
|
321
353
|
};
|
|
322
354
|
Painter.prototype.stroke = function () {
|
|
323
355
|
if (this.__region)
|
|
324
356
|
this.__region.stroke();
|
|
357
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
358
|
+
return this;
|
|
325
359
|
this.painter.stroke();
|
|
326
360
|
return this;
|
|
327
361
|
};
|
|
328
362
|
Painter.prototype.full = function () {
|
|
329
363
|
if (this.__region)
|
|
330
364
|
this.__region.full();
|
|
365
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
366
|
+
return this;
|
|
331
367
|
this.painter.fill();
|
|
332
368
|
this.painter.stroke();
|
|
333
369
|
return this;
|
|
@@ -335,54 +371,72 @@
|
|
|
335
371
|
Painter.prototype.save = function () {
|
|
336
372
|
if (this.__region)
|
|
337
373
|
this.__region.save();
|
|
374
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
375
|
+
return this;
|
|
338
376
|
this.painter.save();
|
|
339
377
|
return this;
|
|
340
378
|
};
|
|
341
379
|
Painter.prototype.restore = function () {
|
|
342
380
|
if (this.__region)
|
|
343
381
|
this.__region.restore();
|
|
382
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
383
|
+
return this;
|
|
344
384
|
this.painter.restore();
|
|
345
385
|
return this;
|
|
346
386
|
};
|
|
347
387
|
Painter.prototype.clip = function () {
|
|
348
388
|
if (this.__region)
|
|
349
389
|
this.__region.clip();
|
|
390
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
391
|
+
return this;
|
|
350
392
|
this.painter.clip();
|
|
351
393
|
return this;
|
|
352
394
|
};
|
|
353
395
|
Painter.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
354
396
|
if (this.__region)
|
|
355
397
|
this.__region.quadraticCurveTo(cpx, cpy, x, y);
|
|
398
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
399
|
+
return this;
|
|
356
400
|
this.painter.quadraticCurveTo(cpx, cpy, x, y);
|
|
357
401
|
return this;
|
|
358
402
|
};
|
|
359
403
|
Painter.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
360
404
|
if (this.__region)
|
|
361
405
|
this.__region.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
406
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
407
|
+
return this;
|
|
362
408
|
this.painter.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
363
409
|
return this;
|
|
364
410
|
};
|
|
365
411
|
Painter.prototype.clearRect = function (x, y, w, h) {
|
|
366
412
|
if (this.__region)
|
|
367
413
|
this.__region.clearRect(x, y, w, h);
|
|
414
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
415
|
+
return this;
|
|
368
416
|
this.painter.clearRect(x, y, w, h);
|
|
369
417
|
return this;
|
|
370
418
|
};
|
|
371
419
|
Painter.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
372
420
|
if (this.__region)
|
|
373
421
|
this.__region.fillArc(cx, cy, r1, r2, beginDeg, deg);
|
|
422
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
423
|
+
return this;
|
|
374
424
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).fill();
|
|
375
425
|
return this;
|
|
376
426
|
};
|
|
377
427
|
Painter.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
378
428
|
if (this.__region)
|
|
379
429
|
this.__region.strokeArc(cx, cy, r1, r2, beginDeg, deg);
|
|
430
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
431
|
+
return this;
|
|
380
432
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).stroke();
|
|
381
433
|
return this;
|
|
382
434
|
};
|
|
383
435
|
Painter.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
384
436
|
if (this.__region)
|
|
385
437
|
this.__region.fullArc(cx, cy, r1, r2, beginDeg, deg);
|
|
438
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
439
|
+
return this;
|
|
386
440
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg);
|
|
387
441
|
this.painter.fill();
|
|
388
442
|
this.painter.stroke();
|
|
@@ -391,18 +445,24 @@
|
|
|
391
445
|
Painter.prototype.fillCircle = function (cx, cy, r) {
|
|
392
446
|
if (this.__region)
|
|
393
447
|
this.__region.fillCircle(cx, cy, r);
|
|
448
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
449
|
+
return this;
|
|
394
450
|
initCircle(this.painter, cx, cy, r).fill();
|
|
395
451
|
return this;
|
|
396
452
|
};
|
|
397
453
|
Painter.prototype.strokeCircle = function (cx, cy, r) {
|
|
398
454
|
if (this.__region)
|
|
399
455
|
this.__region.strokeCircle(cx, cy, r);
|
|
456
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
457
|
+
return this;
|
|
400
458
|
initCircle(this.painter, cx, cy, r).stroke();
|
|
401
459
|
return this;
|
|
402
460
|
};
|
|
403
461
|
Painter.prototype.fullCircle = function (cx, cy, r) {
|
|
404
462
|
if (this.__region)
|
|
405
463
|
this.__region.fullCircle(cx, cy, r);
|
|
464
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
465
|
+
return this;
|
|
406
466
|
initCircle(this.painter, cx, cy, r);
|
|
407
467
|
this.painter.fill();
|
|
408
468
|
this.painter.stroke();
|
|
@@ -411,23 +471,30 @@
|
|
|
411
471
|
Painter.prototype.fillRect = function (x, y, width, height) {
|
|
412
472
|
if (this.__region)
|
|
413
473
|
this.__region.fillRect(x, y, width, height);
|
|
474
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
475
|
+
return this;
|
|
414
476
|
initRect(this.painter, x, y, width, height).fill();
|
|
415
477
|
return this;
|
|
416
478
|
};
|
|
417
479
|
Painter.prototype.strokeRect = function (x, y, width, height) {
|
|
418
480
|
if (this.__region)
|
|
419
481
|
this.__region.strokeRect(x, y, width, height);
|
|
482
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
483
|
+
return this;
|
|
420
484
|
initRect(this.painter, x, y, width, height).stroke();
|
|
421
485
|
return this;
|
|
422
486
|
};
|
|
423
487
|
Painter.prototype.fullRect = function (x, y, width, height) {
|
|
424
488
|
if (this.__region)
|
|
425
489
|
this.__region.fullRect(x, y, width, height);
|
|
490
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
491
|
+
return this;
|
|
426
492
|
initRect(this.painter, x, y, width, height);
|
|
427
493
|
this.painter.fill();
|
|
428
494
|
this.painter.stroke();
|
|
429
495
|
return this;
|
|
430
496
|
};
|
|
497
|
+
Painter.prototype.draw = function () { };
|
|
431
498
|
return Painter;
|
|
432
499
|
}());
|
|
433
500
|
|
|
@@ -487,9 +554,9 @@
|
|
|
487
554
|
var Canvas$1 = (function (_super) {
|
|
488
555
|
__extends(Canvas, _super);
|
|
489
556
|
function Canvas(ViewCanvas, RegionCanvas) {
|
|
490
|
-
var _this = _super.call(this, ViewCanvas, {}, new Painter(RegionCanvas, {
|
|
557
|
+
var _this = _super.call(this, ViewCanvas, {}, RegionCanvas ? new Painter(RegionCanvas, {
|
|
491
558
|
willReadFrequently: true,
|
|
492
|
-
})) || this;
|
|
559
|
+
}) : null, true) || this;
|
|
493
560
|
_this.name = "Canvas";
|
|
494
561
|
_this.__regionList = {};
|
|
495
562
|
_this.__regionAssemble = assemble(0, 255, 10, 3);
|
|
@@ -503,39 +570,49 @@
|
|
|
503
570
|
}
|
|
504
571
|
return this;
|
|
505
572
|
};
|
|
573
|
+
Canvas.prototype.onlyRegion = function (flag) {
|
|
574
|
+
this.__onlyRegion = flag;
|
|
575
|
+
return this;
|
|
576
|
+
};
|
|
506
577
|
Canvas.prototype.setRegion = function (regionName) {
|
|
507
|
-
if (
|
|
508
|
-
if (
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
578
|
+
if (this.__region) {
|
|
579
|
+
if (regionName) {
|
|
580
|
+
if (this.__regionList[regionName] == void 0) {
|
|
581
|
+
var tempColor = this.__regionAssemble();
|
|
582
|
+
this.__regionList[regionName] =
|
|
583
|
+
"rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")";
|
|
584
|
+
}
|
|
585
|
+
this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
|
|
586
|
+
this.__region.useConfig("strokeStyle", this.__regionList[regionName]);
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
this.__region.useConfig("fillStyle", "#000000") &&
|
|
590
|
+
this.__region.useConfig("strokeStyle", "#000000");
|
|
512
591
|
}
|
|
513
|
-
this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
|
|
514
|
-
this.__region.useConfig("strokeStyle", this.__regionList[regionName]);
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
this.__region.useConfig("fillStyle", "#000000") &&
|
|
518
|
-
this.__region.useConfig("strokeStyle", "#000000");
|
|
519
592
|
}
|
|
520
593
|
return this;
|
|
521
594
|
};
|
|
522
595
|
Canvas.prototype.getRegion = function (x, y) {
|
|
523
596
|
var _this = this;
|
|
524
597
|
return new Promise(function (resolve, reject) {
|
|
525
|
-
var imgData = _this.__region.painter.getImageData(x - 0.5, y - 0.5, 1, 1)
|
|
598
|
+
var imgData = _this.__region ? _this.__region.painter.getImageData(x - 0.5, y - 0.5, 1, 1) : {
|
|
599
|
+
data: [0, 0, 0, 0]
|
|
600
|
+
};
|
|
526
601
|
var currentRGBA = imgData.data;
|
|
527
602
|
var doit = function () {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
603
|
+
if (_this.__region) {
|
|
604
|
+
for (var key in _this.__regionList) {
|
|
605
|
+
if ("rgb(" +
|
|
606
|
+
currentRGBA[0] +
|
|
607
|
+
"," +
|
|
608
|
+
currentRGBA[1] +
|
|
609
|
+
"," +
|
|
610
|
+
currentRGBA[2] +
|
|
611
|
+
")" ==
|
|
612
|
+
_this.__regionList[key]) {
|
|
613
|
+
resolve(key);
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
539
616
|
}
|
|
540
617
|
}
|
|
541
618
|
resolve("");
|
|
@@ -560,7 +637,7 @@
|
|
|
560
637
|
};
|
|
561
638
|
Canvas.prototype.getContext = function (isRegion) {
|
|
562
639
|
if (isRegion === void 0) { isRegion = false; }
|
|
563
|
-
return isRegion ? this.__region.painter : this.painter;
|
|
640
|
+
return isRegion ? (this.__region ? this.__region.painter : null) : this.painter;
|
|
564
641
|
};
|
|
565
642
|
Canvas.prototype.createLinearGradient = function (x0, y0, x1, y1) {
|
|
566
643
|
return linearGradient(this.painter, x0, y0, x1, y1);
|
|
@@ -583,13 +660,24 @@
|
|
|
583
660
|
return Canvas;
|
|
584
661
|
}(Painter));
|
|
585
662
|
|
|
663
|
+
function mergeOption (option, defaultOption) {
|
|
664
|
+
for (var key in option) {
|
|
665
|
+
defaultOption[key] = option[key];
|
|
666
|
+
}
|
|
667
|
+
return defaultOption;
|
|
668
|
+
}
|
|
669
|
+
|
|
586
670
|
var Canvas = (function (_super) {
|
|
587
671
|
__extends(Canvas, _super);
|
|
588
|
-
function Canvas(el) {
|
|
672
|
+
function Canvas(el, option) {
|
|
673
|
+
if (option === void 0) { option = {}; }
|
|
589
674
|
var _this = this;
|
|
590
675
|
if (!el) {
|
|
591
676
|
throw new Error("VISLite Canvas:The mount point requires an HTMLElement type but encountered null.");
|
|
592
677
|
}
|
|
678
|
+
option = mergeOption(option, {
|
|
679
|
+
region: true
|
|
680
|
+
});
|
|
593
681
|
var width = el.clientWidth, height = el.clientHeight;
|
|
594
682
|
var ViewCanvas, RegionCanvas;
|
|
595
683
|
var _el = el;
|
|
@@ -600,16 +688,20 @@
|
|
|
600
688
|
else {
|
|
601
689
|
ViewCanvas = document.createElement('canvas');
|
|
602
690
|
el.appendChild(ViewCanvas);
|
|
603
|
-
|
|
691
|
+
if (option.region) {
|
|
692
|
+
RegionCanvas = document.createElement('canvas');
|
|
693
|
+
}
|
|
604
694
|
_el._vislite_canvas_ = [ViewCanvas, RegionCanvas];
|
|
605
695
|
el.setAttribute('vislite', 'Canvas');
|
|
606
696
|
}
|
|
607
697
|
for (var _i = 0, _a = [ViewCanvas, RegionCanvas]; _i < _a.length; _i++) {
|
|
608
698
|
var canvas = _a[_i];
|
|
609
|
-
canvas
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
699
|
+
if (canvas) {
|
|
700
|
+
canvas.style.width = width + "px";
|
|
701
|
+
canvas.setAttribute('width', width + "");
|
|
702
|
+
canvas.style.height = height + "px";
|
|
703
|
+
canvas.setAttribute('height', height + "");
|
|
704
|
+
}
|
|
613
705
|
}
|
|
614
706
|
_this = _super.call(this, ViewCanvas, RegionCanvas) || this;
|
|
615
707
|
_this.__canvas = ViewCanvas;
|