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,110 +1,71 @@
1
-
2
- import {jmUtils} from "./jmUtils.js";
3
- import { jmObject } from "./jmObject.js";
4
-
5
- const PROPERTY_KEY = Symbol("properties");
6
-
7
- /**
8
- * 对象属性管理
9
- *
10
- * @class jmProperty
11
- * @extends jmObject
12
- * @require jmObject
13
- */
14
- export default class jmProperty extends jmObject {
15
-
16
- constructor(params) {
17
- super();
18
- this[PROPERTY_KEY] = {};
19
- if(params && params.mode) this.mode = params.mode;
20
- }
21
-
22
- /**
23
- * 基础属性读写接口
24
- * @method property
25
- * @param {string} name 属性名
26
- * @param {any} value 属性的值
27
- * @returns {any} 属性的值
28
- */
29
- property(...pars) {
30
- if(pars) {
31
- const pros = this[PROPERTY_KEY];
32
- const name = pars[0];
33
- if(pars.length > 1) {
34
- const value = pars[1];
35
- const args = {oldValue: pros[name], newValue: value};
36
- pros[name] = pars[1];
37
- if(this.emit) this.emit('propertyChange', name, args);
38
- return pars[1];
39
- }
40
- else if(name) {
41
- return pros[name];
42
- }
43
- }
44
- }
45
-
46
- /**
47
- * 是否需要刷新画板,属性的改变会导致它变为true
48
- * @property needUpdate
49
- * @type {boolean}
50
- */
51
- get needUpdate() {
52
- return this.property('needUpdate');
53
- }
54
- set needUpdate(v) {
55
- this.property('needUpdate', v);
56
- //子控件属性改变,需要更新整个画板
57
- if(v && !this.is('jmGraph') && this.graph) {
58
- this.graph.needUpdate = true;
59
- }
60
- }
61
-
62
- /**
63
- * 当前所在的画布对象 jmGraph
64
- * @property graph
65
- * @type {jmGraph}
66
- */
67
- get graph() {
68
- let g = this.property('graph');
69
- g = g || (this.property('graph', this.findParent('jmGraph')));
70
- return g;
71
- }
72
- set graph(v) {
73
- return this.property('graph', v);
74
- }
75
-
76
- /**
77
- * 绘制模式 2d/webgl
78
- * @property mode
79
- * @type {string}
80
- */
81
- get mode() {
82
- let m = this.property('mode');
83
- if(m) return m;
84
- else if(this.is('jmGraph')) return this.property('mode');
85
- return this.graph.mode;
86
- }
87
- set mode(v) {
88
- return this.property('mode', v);
89
- }
90
-
91
- /**
92
- * 在下次进行重绘时执行
93
- * @param {Function} handler
94
- */
95
- requestAnimationFrame(handler) {
96
- return jmUtils.requestAnimationFrame(handler, this.graph? this.graph.canvas: null);
97
- }
98
- /**
99
- * 清除执行回调
100
- * @param {Function} handler
101
- * @returns
102
- */
103
- cancelAnimationFrame(handler) {
104
- return jmUtils.cancelAnimationFrame(handler, this.graph? this.graph.canvas: null);
105
- }
106
- }
107
-
108
- export { jmProperty };
109
-
110
-
1
+
2
+ import {jmUtils} from "./jmUtils.js";
3
+ import { jmObject } from "./jmObject.js";
4
+
5
+ const PROPERTY_KEY = Symbol("properties");
6
+
7
+ export default class jmProperty extends jmObject {
8
+ constructor(params) {
9
+ super();
10
+ this[PROPERTY_KEY] = {};
11
+ if(params && params.mode) this.mode = params.mode;
12
+ }
13
+
14
+ property(...pars) {
15
+ if(pars) {
16
+ const pros = this[PROPERTY_KEY];
17
+ const name = pars[0];
18
+ if(pars.length > 1) {
19
+ const value = pars[1];
20
+ const args = {oldValue: pros[name], newValue: value};
21
+ pros[name] = pars[1];
22
+ if(this.emit) this.emit('propertyChange', name, args);
23
+ return pars[1];
24
+ }
25
+ else if(name) {
26
+ return pros[name];
27
+ }
28
+ }
29
+ }
30
+
31
+ get needUpdate() {
32
+ return this.property('needUpdate');
33
+ }
34
+ set needUpdate(v) {
35
+ this.property('needUpdate', v);
36
+ if(v && !this.is('jmGraph') && this.graph) {
37
+ this.graph.needUpdate = true;
38
+ }
39
+ }
40
+
41
+ get graph() {
42
+ let g = this.property('graph');
43
+ g = g || (this.property('graph', this.findParent('jmGraph')));
44
+ return g;
45
+ }
46
+ set graph(v) {
47
+ return this.property('graph', v);
48
+ }
49
+
50
+ get mode() {
51
+ let m = this.property('mode');
52
+ if(m) return m;
53
+ else if(this.is('jmGraph')) return this.property('mode');
54
+ return this.graph.mode;
55
+ }
56
+ set mode(v) {
57
+ return this.property('mode', v);
58
+ }
59
+
60
+ requestAnimationFrame(handler) {
61
+ return jmUtils.requestAnimationFrame(handler, this.graph? this.graph.canvas: null);
62
+ }
63
+
64
+ cancelAnimationFrame(handler) {
65
+ return jmUtils.cancelAnimationFrame(handler, this.graph? this.graph.canvas: null);
66
+ }
67
+ }
68
+
69
+ export { jmProperty };
70
+
71
+
@@ -1,66 +1,66 @@
1
- import {jmUtils} from "./jmUtils.js";
2
-
3
- /**
4
- * 画图阴影对象表示法
5
- *
6
- * @class jmShadow
7
- * @param {number} x 横坐标偏移量
8
- * @param {number} y 纵坐标编移量
9
- * @param {number} blur 模糊值
10
- * @param {string} color 阴影的颜色
11
- */
12
-
13
- export default class jmShadow {
14
- constructor(x, y, blur, color) {
15
- if(typeof x == 'string' && !y && !blur && !color) {
16
- this.fromString(x);
17
- }
18
- else {
19
- this.x = x;
20
- this.y = y;
21
- this.blur = blur;
22
- this.color = color;
23
- }
24
- }
25
- /**
26
- * 根据字符串格式转为阴影
27
- * @method fromString
28
- * @param {string} s 阴影字符串 x,y,blur,color
29
- */
30
- fromString(s) {
31
- if(!s) return;
32
- let ms = s.match(/\s*([^,]+)\s*,\s*([^,]+)\s*(,[^,]+)?\s*(,[\s\S]+)?\s*/i);
33
- if(ms) {
34
- this.x = ms[1]||0;
35
- this.y = ms[2]||0;
36
- if(ms[3]) {
37
- ms[3] = jmUtils.trim(ms[3],', ');
38
- //如果第三位是颜色格式,则表示为颜色
39
- if(ms[3].indexOf('#')===0 || /^rgb/i.test(ms[3])) {
40
- this.color = ms[3];
41
- }
42
- else {
43
- this.blur = jmUtils.trim(ms[3],', ');
44
- }
45
- }
46
- if(ms[4]) {
47
- this.color = jmUtils.trim(ms[4],', ');
48
- }
49
- }
50
- return this;
51
- }
52
-
53
- /**
54
- * 转为字符串格式 x,y,blur,color
55
- * @method toString
56
- * @returns {string} 阴影字符串
57
- */
58
- toString() {
59
- let s = this.x + ',' + this.y;
60
- if(this.blur) s += ',' + this.blur;
61
- if(this.color) s += ',' + this.color;
62
- return s;
63
- }
64
- }
65
-
1
+ import {jmUtils} from "./jmUtils.js";
2
+
3
+ /**
4
+ * 画图阴影对象表示法
5
+ *
6
+ * @class jmShadow
7
+ * @param {number} x 横坐标偏移量
8
+ * @param {number} y 纵坐标编移量
9
+ * @param {number} blur 模糊值
10
+ * @param {string} color 阴影的颜色
11
+ */
12
+
13
+ export default class jmShadow {
14
+ constructor(x, y, blur, color) {
15
+ if(typeof x == 'string' && !y && !blur && !color) {
16
+ this.fromString(x);
17
+ }
18
+ else {
19
+ this.x = x;
20
+ this.y = y;
21
+ this.blur = blur;
22
+ this.color = color;
23
+ }
24
+ }
25
+ /**
26
+ * 根据字符串格式转为阴影
27
+ * @method fromString
28
+ * @param {string} s 阴影字符串 x,y,blur,color
29
+ */
30
+ fromString(s) {
31
+ if(!s) return;
32
+ let ms = s.match(/\s*([^,]+)\s*,\s*([^,]+)\s*(,[^,]+)?\s*(,[\s\S]+)?\s*/i);
33
+ if(ms) {
34
+ this.x = ms[1]||0;
35
+ this.y = ms[2]||0;
36
+ if(ms[3]) {
37
+ ms[3] = jmUtils.trim(ms[3],', ');
38
+ //如果第三位是颜色格式,则表示为颜色
39
+ if(ms[3].indexOf('#')===0 || /^rgb/i.test(ms[3])) {
40
+ this.color = ms[3];
41
+ }
42
+ else {
43
+ this.blur = jmUtils.trim(ms[3],', ');
44
+ }
45
+ }
46
+ if(ms[4]) {
47
+ this.color = jmUtils.trim(ms[4],', ');
48
+ }
49
+ }
50
+ return this;
51
+ }
52
+
53
+ /**
54
+ * 转为字符串格式 x,y,blur,color
55
+ * @method toString
56
+ * @returns {string} 阴影字符串
57
+ */
58
+ toString() {
59
+ let s = this.x + ',' + this.y;
60
+ if(this.blur) s += ',' + this.blur;
61
+ if(this.color) s += ',' + this.color;
62
+ return s;
63
+ }
64
+ }
65
+
66
66
  export { jmShadow };