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.
Files changed (77) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +251 -428
  3. package/build/gulpfile.js +142 -142
  4. package/build/package-lock.json +10666 -0
  5. package/build/package.json +71 -71
  6. package/dev.js +9 -9
  7. package/dist/jmgraph.core.min.js +1 -1
  8. package/dist/jmgraph.core.min.js.map +1 -1
  9. package/dist/jmgraph.js +3500 -2668
  10. package/dist/jmgraph.min.js +1 -1
  11. package/example/ball.html +216 -216
  12. package/example/base.html +111 -111
  13. package/example/canvas.html +53 -53
  14. package/example/cell.html +283 -283
  15. package/example/controls/arc.html +128 -128
  16. package/example/controls/arrowline.html +77 -77
  17. package/example/controls/bezier.html +298 -298
  18. package/example/controls/img.html +96 -96
  19. package/example/controls/label.html +86 -86
  20. package/example/controls/line.html +172 -172
  21. package/example/controls/prismatic.html +62 -62
  22. package/example/controls/rect.html +63 -63
  23. package/example/controls/resize.html +111 -111
  24. package/example/controls/test.html +359 -359
  25. package/example/es.html +69 -69
  26. package/example/es5module.html +62 -63
  27. package/example/heartarc.html +115 -115
  28. package/example/index.html +46 -46
  29. package/example/js/require.js +4 -4
  30. package/example/love/img/bling/bling.tps +265 -265
  31. package/example/love/img/bling.json +87 -87
  32. package/example/love/img/bling.tps +295 -295
  33. package/example/love/img/love.json +95 -95
  34. package/example/love/img/love.tps +315 -315
  35. package/example/love/img/qq/qq.tps +399 -399
  36. package/example/love/img/qq.json +242 -242
  37. package/example/love/index.html +40 -40
  38. package/example/love/js/game.js +558 -558
  39. package/example/music.html +210 -210
  40. package/example/node/test.js +137 -137
  41. package/example/pdf.html +186 -186
  42. package/example/progress.html +172 -172
  43. package/example/pso.html +147 -147
  44. package/example/sort.html +804 -815
  45. package/example/tweenjs.html +83 -83
  46. package/example/webgl.html +278 -278
  47. package/example/xfj/index.html +331 -331
  48. package/example/xfj/shake.js +48 -48
  49. package/example/xfj/testori.html +75 -75
  50. package/index.js +99 -99
  51. package/package.json +58 -56
  52. package/src/core/jmControl.js +1376 -1531
  53. package/src/core/jmEvents.js +240 -281
  54. package/src/core/jmGradient.js +231 -231
  55. package/src/core/jmGraph.js +569 -569
  56. package/src/core/jmList.js +92 -157
  57. package/src/core/jmObject.js +83 -103
  58. package/src/core/jmPath.js +35 -35
  59. package/src/core/jmProperty.js +71 -110
  60. package/src/core/jmShadow.js +65 -65
  61. package/src/core/jmUtils.js +906 -919
  62. package/src/lib/earcut.js +680 -680
  63. package/src/lib/earcut.md +73 -73
  64. package/src/lib/webgl/base.js +522 -452
  65. package/src/lib/webgl/core/buffer.js +48 -48
  66. package/src/lib/webgl/core/mapSize.js +40 -40
  67. package/src/lib/webgl/core/mapType.js +43 -43
  68. package/src/lib/webgl/core/program.js +138 -138
  69. package/src/lib/webgl/core/shader.js +13 -13
  70. package/src/lib/webgl/core/texture.js +60 -60
  71. package/src/lib/webgl/gradient.js +168 -168
  72. package/src/lib/webgl/index.js +137 -11
  73. package/src/lib/webgl/path.js +568 -561
  74. package/src/shapes/jmArrowLine.js +36 -36
  75. package/src/shapes/jmImage.js +244 -244
  76. package/src/shapes/jmLabel.js +271 -271
  77. package/src/shapes/jmResize.js +332 -330
@@ -1,158 +1,93 @@
1
- /**
2
- * 自定义集合
3
- *
4
- * @class jmList
5
- * @for jmUtils
6
- * @param {array} [arr] 数组,可转为当前list元素
7
- */
8
- export default class jmList extends Array {
9
- constructor(...arg) {
10
- let ps = [];
11
- if(arg && arg.length && Array.isArray(arg[0])) {
12
- for(let i=0; i< arg[0].length; i++) ps.push(arg[0][i]);
13
- super(...ps);
14
- }
15
- else {
16
- super();
17
- }
18
- this.option = {}; //选项
19
- this.type = 'jmList';
20
- }
21
- /**
22
- * 往集合中添加对象
23
- *
24
- * @method add
25
- * @for list
26
- * @param {any} obj 往集合中添加的对象
27
- */
28
- add(obj) {
29
- if(obj && Array.isArray(obj)) {
30
- for(let i=0; i < obj.length; i++) {
31
- if(!this.includes(obj[i])) this.push(obj[i]);
32
- }
33
- return obj;
34
- }
35
- if(typeof obj == 'object' && this.includes(obj)) return obj;
36
- this.push(obj);
37
- return obj;
38
- }
39
-
40
- /**
41
- * 从集合中移除指定对象
42
- *
43
- * @method remove
44
- * @for list
45
- * @param {any} obj 将移除的对象
46
- */
47
- remove(obj) {
48
- for(let i = this.length -1; i>=0; i--) {
49
- if(this[i] == obj) {
50
- this.removeAt(i);
51
- }
52
- }
53
- }
54
-
55
- /**
56
- * 按索引移除对象
57
- *
58
- * @method removeAt
59
- * @for list
60
- * @param {integer} index 移除对象的索引
61
- */
62
- removeAt(index) {
63
- if(this.length > index) {
64
- let obj = this[index];
65
- this.splice(index,1);
66
- if(this.option.removeHandler) this.option.removeHandler.call(this, obj, index);
67
- }
68
- }
69
-
70
- /**
71
- * 判断是否包含某个对象
72
- *
73
- * @method contain
74
- * @for list
75
- * @param {any} obj 判断当前集合中是否包含此对象
76
- */
77
- contain(obj) {
78
- return this.includes(obj);
79
- }
80
-
81
- /**
82
- * 从集合中获取某个对象
83
- *
84
- * @method get
85
- * @for list
86
- * @param {integer/function} index 如果为整型则表示为获取此索引的对象,如果为function为则通过此委托获取对象
87
- * @return {any} 集合中的对象
88
- */
89
- get(index) {
90
- if(typeof index == 'function') {
91
- return this.find(index);
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 };
@@ -1,104 +1,84 @@
1
-
2
- import {jmList} from "./jmList.js";
3
-
4
- var control_id_counter = 0;
5
- /**
6
- * 所有jm对象的基础对象
7
- *
8
- * @class jmObject
9
- * @for jmGraph
10
- */
11
- export default class jmObject {
12
- //id;
13
- constructor(g) {
14
- if(g && g.type == 'jmGraph') {
15
- this.graph = g;
16
- }
17
- this.id = ++control_id_counter; //生成一个唯一id
18
- }
19
-
20
- /**
21
- * 检 查对象是否为指定类型
22
- *
23
- * @method is
24
- * @param {class} type 判断的类型
25
- * @for jmObject
26
- * @return {boolean} true=表示当前对象为指定的类型type,false=表示不是
27
- */
28
- is(type) {
29
- if(typeof type == 'string') {
30
- return this.type == type;
31
- }
32
- return this instanceof type;
33
- }
34
-
35
- /**
36
- * 给控件添加动画处理,如果成功执行会导致画布刷新。
37
- *
38
- * @method animate
39
- * @for jmObject
40
- * @param {function} handle 动画委托
41
- * @param {integer} millisec 此委托执行间隔 (毫秒)
42
- */
43
- animate(...args) {
44
- if(this.is('jmGraph')) {
45
- if(args.length > 1) {
46
- if(!this.animateHandles) this.animateHandles = new jmList();
47
-
48
- var params = [];
49
- if(args.length > 2) {
50
- for(var i=2;i<args.length;i++) {
51
- params.push(args[i]);
52
- }
53
- }
54
- this.animateHandles.add({
55
- millisec: args[1] || 20,
56
- handle: args[0],
57
- params:params
58
- });
59
- }
60
- if(this.animateHandles) {
61
- if(this.animateHandles.count() > 0) {
62
- var self = this;
63
- //延时处理动画事件
64
- this.dispatcher = setTimeout(function(_this) {
65
- _this = _this || self;
66
- //var needredraw = false;
67
- var overduehandles = [];
68
- var curTimes = new Date().getTime();
69
- _this.animateHandles.each(function(i,ani) {
70
- try {
71
- if(ani && ani.handle && (!ani.times || curTimes - ani.times >= ani.millisec)) {
72
- var r = ani.handle.apply(_this, ani.params);
73
- if(r === false) {
74
- overduehandles.push(ani);//表示已完成的动画效果
75
- }
76
- ani.times = curTimes;
77
- //needredraw = true;
78
- }
79
- }
80
- catch(e) {
81
- if(window.console && window.console.info) {
82
- window.console.info(e.toString());
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 };
@@ -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 };