jmgraph 3.2.16 → 3.2.18
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/LICENSE +21 -21
- package/README.md +251 -428
- package/build/gulpfile.js +142 -142
- package/build/package-lock.json +10666 -0
- package/build/package.json +71 -71
- package/dev.js +9 -9
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +3500 -2668
- package/dist/jmgraph.min.js +1 -1
- package/example/ball.html +216 -216
- package/example/base.html +111 -111
- package/example/canvas.html +53 -53
- package/example/cell.html +283 -283
- package/example/controls/arc.html +128 -128
- package/example/controls/arrowline.html +77 -77
- package/example/controls/bezier.html +298 -298
- package/example/controls/img.html +96 -96
- package/example/controls/label.html +86 -86
- package/example/controls/line.html +172 -172
- package/example/controls/prismatic.html +62 -62
- package/example/controls/rect.html +63 -63
- package/example/controls/resize.html +111 -111
- package/example/controls/test.html +359 -359
- package/example/es.html +69 -69
- package/example/es5module.html +62 -63
- package/example/heartarc.html +115 -115
- package/example/index.html +46 -46
- package/example/js/require.js +4 -4
- package/example/love/img/bling/bling.tps +265 -265
- package/example/love/img/bling.json +87 -87
- package/example/love/img/bling.tps +295 -295
- package/example/love/img/love.json +95 -95
- package/example/love/img/love.tps +315 -315
- package/example/love/img/qq/qq.tps +399 -399
- package/example/love/img/qq.json +242 -242
- package/example/love/index.html +40 -40
- package/example/love/js/game.js +558 -558
- package/example/music.html +210 -210
- package/example/node/test.js +137 -137
- package/example/pdf.html +186 -186
- package/example/progress.html +172 -172
- package/example/pso.html +147 -147
- package/example/sort.html +804 -815
- package/example/tweenjs.html +83 -83
- package/example/webgl.html +278 -278
- package/example/xfj/index.html +331 -331
- package/example/xfj/shake.js +48 -48
- package/example/xfj/testori.html +75 -75
- package/index.js +99 -99
- package/package.json +58 -56
- package/src/core/jmControl.js +1376 -1531
- package/src/core/jmEvents.js +240 -281
- package/src/core/jmGradient.js +231 -231
- package/src/core/jmGraph.js +569 -569
- package/src/core/jmList.js +92 -157
- package/src/core/jmObject.js +83 -103
- package/src/core/jmPath.js +35 -35
- package/src/core/jmProperty.js +71 -110
- package/src/core/jmShadow.js +65 -65
- package/src/core/jmUtils.js +906 -919
- package/src/lib/earcut.js +680 -680
- package/src/lib/earcut.md +73 -73
- package/src/lib/webgl/base.js +522 -452
- package/src/lib/webgl/core/buffer.js +48 -48
- package/src/lib/webgl/core/mapSize.js +40 -40
- package/src/lib/webgl/core/mapType.js +43 -43
- package/src/lib/webgl/core/program.js +138 -138
- package/src/lib/webgl/core/shader.js +13 -13
- package/src/lib/webgl/core/texture.js +60 -60
- package/src/lib/webgl/gradient.js +168 -168
- package/src/lib/webgl/index.js +137 -11
- package/src/lib/webgl/path.js +568 -561
- package/src/shapes/jmArrowLine.js +36 -36
- package/src/shapes/jmImage.js +244 -244
- package/src/shapes/jmLabel.js +271 -271
- package/src/shapes/jmResize.js +332 -330
package/src/core/jmList.js
CHANGED
|
@@ -1,158 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
else {
|
|
94
|
-
return this[index];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 遍历当前集合
|
|
100
|
-
*
|
|
101
|
-
* @method each
|
|
102
|
-
* @for list
|
|
103
|
-
* @param {function} cb 遍历当前集合的委托
|
|
104
|
-
* @param {boolean} inverse 是否按逆序遍历
|
|
105
|
-
*/
|
|
106
|
-
each(cb, inverse) {
|
|
107
|
-
if(cb && typeof cb == 'function') {
|
|
108
|
-
//如果按倒序循环
|
|
109
|
-
if(inverse) {
|
|
110
|
-
for(let i = this.length - 1;i>=0; i--) {
|
|
111
|
-
let r = cb.call(this, i, this[i]);
|
|
112
|
-
if(r === false) break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
let len = this.length;
|
|
117
|
-
for(let i = 0; i < len;i++) {
|
|
118
|
-
let r = cb.call(this, i, this[i]);
|
|
119
|
-
if(r === false) break;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* 获取当前集合对象个数
|
|
127
|
-
*
|
|
128
|
-
* @method count
|
|
129
|
-
* @param {function} [handler] 检查对象是否符合计算的条件
|
|
130
|
-
* @for list
|
|
131
|
-
* @return {integer} 当前集合的个数
|
|
132
|
-
*/
|
|
133
|
-
count(handler) {
|
|
134
|
-
if(handler && typeof handler == 'function') {
|
|
135
|
-
let count = 0;
|
|
136
|
-
let len = this.length;
|
|
137
|
-
for(let i = 0; i<len;i++) {
|
|
138
|
-
if(handler(this[i])) {
|
|
139
|
-
count ++;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return count;
|
|
143
|
-
}
|
|
144
|
-
return this.length;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* 清空当前集合
|
|
149
|
-
*
|
|
150
|
-
* @method clear
|
|
151
|
-
* @for list
|
|
152
|
-
*/
|
|
153
|
-
clear() {
|
|
154
|
-
this.splice(0, this.length);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
1
|
+
export default class jmList extends Array {
|
|
2
|
+
constructor(...arg) {
|
|
3
|
+
const ps = [];
|
|
4
|
+
if(arg && arg.length && Array.isArray(arg[0])) {
|
|
5
|
+
for(let i=0; i< arg[0].length; i++) ps.push(arg[0][i]);
|
|
6
|
+
super(...ps);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
this.option = {};
|
|
12
|
+
this.type = 'jmList';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
add(obj) {
|
|
16
|
+
if(obj && Array.isArray(obj)) {
|
|
17
|
+
for(let i=0; i < obj.length; i++) {
|
|
18
|
+
if(!this.includes(obj[i])) this.push(obj[i]);
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
if(typeof obj == 'object' && this.includes(obj)) return obj;
|
|
23
|
+
this.push(obj);
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
remove(obj) {
|
|
28
|
+
for(let i = this.length -1; i>=0; i--) {
|
|
29
|
+
if(this[i] == obj) {
|
|
30
|
+
this.removeAt(i);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
removeAt(index) {
|
|
36
|
+
if(this.length > index) {
|
|
37
|
+
const obj = this[index];
|
|
38
|
+
this.splice(index,1);
|
|
39
|
+
if(this.option.removeHandler) this.option.removeHandler.call(this, obj, index);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
contain(obj) {
|
|
44
|
+
return this.includes(obj);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get(index) {
|
|
48
|
+
if(typeof index == 'function') {
|
|
49
|
+
return this.find(index);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return this[index];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
each(cb, inverse) {
|
|
57
|
+
if(cb && typeof cb == 'function') {
|
|
58
|
+
if(inverse) {
|
|
59
|
+
for(let i = this.length - 1;i>=0; i--) {
|
|
60
|
+
const r = cb.call(this, i, this[i]);
|
|
61
|
+
if(r === false) break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const len = this.length;
|
|
66
|
+
for(let i = 0; i < len;i++) {
|
|
67
|
+
const r = cb.call(this, i, this[i]);
|
|
68
|
+
if(r === false) break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
count(handler) {
|
|
75
|
+
if(handler && typeof handler == 'function') {
|
|
76
|
+
let count = 0;
|
|
77
|
+
const len = this.length;
|
|
78
|
+
for(let i = 0; i<len;i++) {
|
|
79
|
+
if(handler(this[i])) {
|
|
80
|
+
count++;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return count;
|
|
84
|
+
}
|
|
85
|
+
return this.length;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
clear() {
|
|
89
|
+
this.splice(0, this.length);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
158
93
|
export { jmList };
|
package/src/core/jmObject.js
CHANGED
|
@@ -1,104 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
import {jmList} from "./jmList.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if(ani) overduehandles.push(ani);//异常的事件,不再执行
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
for(var i in overduehandles) {
|
|
88
|
-
_this.animateHandles.remove(overduehandles[i]);//移除完成的效果
|
|
89
|
-
}
|
|
90
|
-
_this.animate();
|
|
91
|
-
},10,this);//刷新
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
var graph = this.graph;
|
|
97
|
-
if(graph) {
|
|
98
|
-
graph.animate(...args);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
1
|
+
|
|
2
|
+
import {jmList} from "./jmList.js";
|
|
3
|
+
|
|
4
|
+
let control_id_counter = 0;
|
|
5
|
+
|
|
6
|
+
export default class jmObject {
|
|
7
|
+
constructor(g) {
|
|
8
|
+
if(g && g.type == 'jmGraph') {
|
|
9
|
+
this.graph = g;
|
|
10
|
+
}
|
|
11
|
+
this.id = ++control_id_counter;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 检 查对象是否为指定类型
|
|
16
|
+
*
|
|
17
|
+
* @method is
|
|
18
|
+
* @param {class} type 判断的类型
|
|
19
|
+
* @for jmObject
|
|
20
|
+
* @return {boolean} true=表示当前对象为指定的类型type,false=表示不是
|
|
21
|
+
*/
|
|
22
|
+
is(type) {
|
|
23
|
+
if(typeof type == 'string') {
|
|
24
|
+
return this.type == type;
|
|
25
|
+
}
|
|
26
|
+
return this instanceof type;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
animate(...args) {
|
|
30
|
+
if(this.is('jmGraph')) {
|
|
31
|
+
if(args.length > 1) {
|
|
32
|
+
if(!this.animateHandles) this.animateHandles = new jmList();
|
|
33
|
+
|
|
34
|
+
const params = [];
|
|
35
|
+
if(args.length > 2) {
|
|
36
|
+
for(let i=2;i<args.length;i++) {
|
|
37
|
+
params.push(args[i]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.animateHandles.add({
|
|
41
|
+
millisec: args[1] || 20,
|
|
42
|
+
handle: args[0],
|
|
43
|
+
params: params
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if(this.animateHandles) {
|
|
47
|
+
if(this.animateHandles.count() > 0) {
|
|
48
|
+
const self = this;
|
|
49
|
+
this.dispatcher = setTimeout(function(_this) {
|
|
50
|
+
_this = _this || self;
|
|
51
|
+
const overduehandles = [];
|
|
52
|
+
const curTimes = Date.now();
|
|
53
|
+
_this.animateHandles.each(function(i,ani) {
|
|
54
|
+
try {
|
|
55
|
+
if(ani && ani.handle && (!ani.times || curTimes - ani.times >= ani.millisec)) {
|
|
56
|
+
const r = ani.handle.apply(_this, ani.params);
|
|
57
|
+
if(r === false) {
|
|
58
|
+
overduehandles.push(ani);
|
|
59
|
+
}
|
|
60
|
+
ani.times = curTimes;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch(e) {
|
|
64
|
+
if(ani) overduehandles.push(ani);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
for(const i in overduehandles) {
|
|
68
|
+
_this.animateHandles.remove(overduehandles[i]);
|
|
69
|
+
}
|
|
70
|
+
_this.animate();
|
|
71
|
+
},10,this);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const graph = this.graph;
|
|
77
|
+
if(graph) {
|
|
78
|
+
graph.animate(...args);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
104
84
|
export { jmObject };
|
package/src/core/jmPath.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import {jmControl} from "./jmControl.js";
|
|
2
|
-
/**
|
|
3
|
-
* 基础路径,大部分图型的基类
|
|
4
|
-
* 指定一系列点,画出图形
|
|
5
|
-
*
|
|
6
|
-
* @class jmPath
|
|
7
|
-
* @extends jmControl
|
|
8
|
-
* @param {object} params 路径参数 points=所有描点
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export default class jmPath extends jmControl {
|
|
12
|
-
|
|
13
|
-
constructor(params, t='jmPath') {
|
|
14
|
-
super(params, t);
|
|
15
|
-
this.points = params && params.points ? params.points : [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 描点集合
|
|
20
|
-
* point格式:{x:0,y:0,m:true}
|
|
21
|
-
* @property points
|
|
22
|
-
* @type {array}
|
|
23
|
-
*/
|
|
24
|
-
get points() {
|
|
25
|
-
let s = this.property('points');
|
|
26
|
-
return s;
|
|
27
|
-
}
|
|
28
|
-
set points(v) {
|
|
29
|
-
this.needUpdate = true;
|
|
30
|
-
return this.property('points', v);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { jmPath };
|
|
1
|
+
import {jmControl} from "./jmControl.js";
|
|
2
|
+
/**
|
|
3
|
+
* 基础路径,大部分图型的基类
|
|
4
|
+
* 指定一系列点,画出图形
|
|
5
|
+
*
|
|
6
|
+
* @class jmPath
|
|
7
|
+
* @extends jmControl
|
|
8
|
+
* @param {object} params 路径参数 points=所有描点
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export default class jmPath extends jmControl {
|
|
12
|
+
|
|
13
|
+
constructor(params, t='jmPath') {
|
|
14
|
+
super(params, t);
|
|
15
|
+
this.points = params && params.points ? params.points : [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 描点集合
|
|
20
|
+
* point格式:{x:0,y:0,m:true}
|
|
21
|
+
* @property points
|
|
22
|
+
* @type {array}
|
|
23
|
+
*/
|
|
24
|
+
get points() {
|
|
25
|
+
let s = this.property('points');
|
|
26
|
+
return s;
|
|
27
|
+
}
|
|
28
|
+
set points(v) {
|
|
29
|
+
this.needUpdate = true;
|
|
30
|
+
return this.property('points', v);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { jmPath };
|