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,272 +1,272 @@
1
- import {jmControl} from "../core/jmControl.js";
2
- /**
3
- * 显示文字控件
4
- *
5
- * @class jmLabel
6
- * @extends jmControl
7
- * @param {object} params params参数:style=样式,value=显示的文字
8
- */
9
- export default class jmLabel extends jmControl {
10
-
11
- constructor(params, t) {
12
- params = params || {};
13
- params.isRegular = true;// 规则的
14
- super(params, t||'jmLabel');
15
-
16
- this.style.font = this.style.font || "15px Arial";
17
- this.style.fontFamily = this.style.fontFamily || 'Arial';
18
- this.style.fontSize = this.style.fontSize || 15;
19
-
20
- // 显示不同的 textAlign 值
21
- //文字水平对齐
22
- this.style.textAlign = this.style.textAlign || 'left';
23
- //文字垂直对齐
24
- this.style.textBaseline = this.style.textBaseline || 'middle';
25
- this.text = params.text || '';
26
-
27
- this.center = params.center || null;
28
- }
29
-
30
- /**
31
- * 显示的内容
32
- * @property text
33
- * @type {string}
34
- */
35
- get text() {
36
- return this.property('text');
37
- }
38
- set text(v) {
39
- this.needUpdate = true;
40
- return this.property('text', v);
41
- }
42
-
43
- /**
44
- * 中心点
45
- * point格式:{x:0,y:0,m:true}
46
- * @property center
47
- * @type {point}
48
- */
49
- get center() {
50
- return this.property('center');
51
- }
52
- set center(v) {
53
- this.needUpdate = true;
54
- return this.property('center', v);
55
- }
56
-
57
- /**
58
- * 当前位置左上角
59
- * @property position
60
- * @type {point}
61
- */
62
- get position() {
63
- return this.property('position');
64
- }
65
- set position(v) {
66
- this.needUpdate = true;
67
- return this.property('position', v);
68
- }
69
-
70
- /**
71
- * 在基础的getLocation上,再加上一个特殊的center处理
72
- *
73
- * @method getLocation
74
- * @returns {Object}
75
- */
76
- getLocation() {
77
- let location = super.getLocation();
78
- let size = this.testSize();
79
-
80
- location.width = location.width || size.width;
81
- location.height = location.height || size.height;
82
-
83
- //如果没有指定位置,但指定了中心,则用中心来计算坐标
84
- if(!location.left && !location.top && location.center) {
85
- location.left = location.center.x - location.width / 2;
86
- location.top = location.center.y - location.height / 2;
87
- }
88
- return location;
89
- }
90
-
91
- /**
92
- * 初始化图形点,主要用于限定控件边界。
93
- *
94
- * @method initPoints
95
- * @return {array} 所有边界点数组
96
- * @private
97
- */
98
- initPoints() {
99
- this.__size = null;
100
- let location = this.getLocation();
101
-
102
- this.points = [{x: location.left, y: location.top}];
103
- this.points.push({x: location.left + location.width, y: location.top});
104
- this.points.push({x: location.left + location.width, y: location.top + location.height});
105
- this.points.push({x: location.left, y: location.top + location.height});
106
- return this.points;
107
- }
108
-
109
- /**
110
- * 测试获取文本所占大小
111
- *
112
- * @method testSize
113
- * @return {object} 含文本大小的对象
114
- */
115
- testSize() {
116
- if(this.__size) return this.__size;
117
-
118
- if(this.webglControl) this.__size = this.webglControl.testSize(this.text, this.style);
119
- else {
120
- this.context.save && this.context.save();
121
- // 修改字体,用来计算
122
- this.setStyle({
123
- font: this.style.font || (this.style.fontSize + 'px ' + this.style.fontFamily)
124
- });
125
- //计算宽度
126
- this.__size = this.context.measureText?
127
- this.context.measureText(this.text):
128
- {width:15};
129
- this.context.restore && this.context.restore();
130
- this.__size.height = this.style.fontSize?this.style.fontSize:15;
131
- }
132
-
133
- if(!this.width) this.width = this.__size.width;
134
- if(!this.height) this.height = this.__size.height;
135
-
136
- return this.__size;
137
- }
138
-
139
- /**
140
- * 根据位置偏移画字符串
141
- *
142
- * @method draw
143
- */
144
- draw() {
145
-
146
- //获取当前控件的绝对位置
147
- let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
148
- const size = this.testSize();
149
- let location = this.location;
150
- let x = location.left + bounds.left;
151
- let y = location.top + bounds.top;
152
- //通过文字对齐方式计算起始X位置
153
- switch(this.style.textAlign) {
154
- case 'right': {
155
- x += location.width;
156
- break;
157
- }
158
- case 'center': {
159
- x += location.width / 2;
160
- break;
161
- }
162
- }
163
- //通过垂直对齐方式计算起始Y值
164
- switch(this.style.textBaseline) {
165
- case 'bottom': {
166
- y += location.height;
167
- break;
168
- }
169
- case 'hanging':
170
- case 'alphabetic':
171
- case 'middle' : {
172
- y += location.height/2;
173
- break;
174
- }
175
-
176
- }
177
-
178
- let txt = this.text;
179
- if(typeof txt !== 'undefined') {
180
- // webgl方式
181
- if(this.webglControl) {
182
- this.webglControl.draw(this.points, bounds);
183
- this.webglControl.drawText(txt, x, y, location);
184
- }
185
- else if(this.style.fill && this.context.fillText) {
186
- if(this.style.maxWidth) {
187
- this.context.fillText(txt,x,y, this.style.maxWidth);
188
- }
189
- else {
190
- this.context.fillText(txt,x,y);
191
- }
192
- }
193
- else if(this.context.strokeText) {
194
- if(this.style.maxWidth) {
195
- this.context.strokeText(txt,x,y, this.style.maxWidth);
196
- }
197
- else {
198
- this.context.strokeText(txt,x,y);
199
- }
200
- }
201
- }
202
- //如果有指定边框,则画出边框
203
- if(this.style.border) {
204
- //如果指定了边框样式
205
- if(this.style.border.style) {
206
- this.context.save && this.context.save();
207
- this.setStyle(this.style.border.style);
208
- }
209
- if(this.mode === '2d') {
210
- this.context.moveTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
211
- if(this.style.border.top) {
212
- this.context.lineTo(this.points[1].x + bounds.left,this.points[1].y + bounds.top);
213
- }
214
-
215
- if(this.style.border.right) {
216
- this.context.moveTo(this.points[1].x + bounds.left,this.points[1].y + bounds.top);
217
- this.context.lineTo(this.points[2].x + bounds.left,this.points[2].y + bounds.top);
218
- }
219
-
220
- if(this.style.border.bottom) {
221
- this.context.moveTo(this.points[2].x + bounds.left,this.points[2].y + bounds.top);
222
- this.context.lineTo(this.points[3].x + bounds.left,this.points[3].y + bounds.top);
223
- }
224
-
225
- if(this.style.border.left) {
226
- this.context.moveTo(this.points[3].x + bounds.left,this.points[3].y + bounds.top);
227
- this.context.lineTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
228
- }
229
- }
230
- else {
231
- const points = [];
232
- if(this.style.border.top) {
233
- points.push(this.points[0]);
234
- points.push(this.points[1]);
235
- }
236
-
237
- if(this.style.border.right) {
238
- points.push({
239
- ...this.points[1],
240
- m: true
241
- });
242
- points.push(this.points[2]);
243
- }
244
-
245
- if(this.style.border.bottom) {
246
- points.push({
247
- ...this.points[2],
248
- m: true
249
- });
250
- points.push(this.points[3]);
251
- }
252
-
253
- if(this.style.border.left) {
254
- points.push({
255
- ...this.points[3],
256
- m: true
257
- });
258
- points.push(this.points[0]);
259
- }
260
- points.length && this.webglControl && this.webglControl.stroke(points);
261
- }
262
- }
263
- }
264
-
265
- endDraw() {
266
- if(this.mode === '2d') {
267
- super.endDraw();
268
- }
269
- }
270
- }
271
-
1
+ import {jmControl} from "../core/jmControl.js";
2
+ /**
3
+ * 显示文字控件
4
+ *
5
+ * @class jmLabel
6
+ * @extends jmControl
7
+ * @param {object} params params参数:style=样式,value=显示的文字
8
+ */
9
+ export default class jmLabel extends jmControl {
10
+
11
+ constructor(params, t) {
12
+ params = params || {};
13
+ params.isRegular = true;// 规则的
14
+ super(params, t||'jmLabel');
15
+
16
+ this.style.font = this.style.font || "15px Arial";
17
+ this.style.fontFamily = this.style.fontFamily || 'Arial';
18
+ this.style.fontSize = this.style.fontSize || 15;
19
+
20
+ // 显示不同的 textAlign 值
21
+ //文字水平对齐
22
+ this.style.textAlign = this.style.textAlign || 'left';
23
+ //文字垂直对齐
24
+ this.style.textBaseline = this.style.textBaseline || 'middle';
25
+ this.text = params.text || '';
26
+
27
+ this.center = params.center || null;
28
+ }
29
+
30
+ /**
31
+ * 显示的内容
32
+ * @property text
33
+ * @type {string}
34
+ */
35
+ get text() {
36
+ return this.property('text');
37
+ }
38
+ set text(v) {
39
+ this.needUpdate = true;
40
+ return this.property('text', v);
41
+ }
42
+
43
+ /**
44
+ * 中心点
45
+ * point格式:{x:0,y:0,m:true}
46
+ * @property center
47
+ * @type {point}
48
+ */
49
+ get center() {
50
+ return this.property('center');
51
+ }
52
+ set center(v) {
53
+ this.needUpdate = true;
54
+ return this.property('center', v);
55
+ }
56
+
57
+ /**
58
+ * 当前位置左上角
59
+ * @property position
60
+ * @type {point}
61
+ */
62
+ get position() {
63
+ return this.property('position');
64
+ }
65
+ set position(v) {
66
+ this.needUpdate = true;
67
+ return this.property('position', v);
68
+ }
69
+
70
+ /**
71
+ * 在基础的getLocation上,再加上一个特殊的center处理
72
+ *
73
+ * @method getLocation
74
+ * @returns {Object}
75
+ */
76
+ getLocation() {
77
+ let location = super.getLocation();
78
+ let size = this.testSize();
79
+
80
+ location.width = location.width || size.width;
81
+ location.height = location.height || size.height;
82
+
83
+ //如果没有指定位置,但指定了中心,则用中心来计算坐标
84
+ if(!location.left && !location.top && location.center) {
85
+ location.left = location.center.x - location.width / 2;
86
+ location.top = location.center.y - location.height / 2;
87
+ }
88
+ return location;
89
+ }
90
+
91
+ /**
92
+ * 初始化图形点,主要用于限定控件边界。
93
+ *
94
+ * @method initPoints
95
+ * @return {array} 所有边界点数组
96
+ * @private
97
+ */
98
+ initPoints() {
99
+ this.__size = null;
100
+ let location = this.getLocation();
101
+
102
+ this.points = [{x: location.left, y: location.top}];
103
+ this.points.push({x: location.left + location.width, y: location.top});
104
+ this.points.push({x: location.left + location.width, y: location.top + location.height});
105
+ this.points.push({x: location.left, y: location.top + location.height});
106
+ return this.points;
107
+ }
108
+
109
+ /**
110
+ * 测试获取文本所占大小
111
+ *
112
+ * @method testSize
113
+ * @return {object} 含文本大小的对象
114
+ */
115
+ testSize() {
116
+ if(this.__size) return this.__size;
117
+
118
+ if(this.webglControl) this.__size = this.webglControl.testSize(this.text, this.style);
119
+ else {
120
+ this.context.save && this.context.save();
121
+ // 修改字体,用来计算
122
+ this.setStyle({
123
+ font: this.style.font || (this.style.fontSize + 'px ' + this.style.fontFamily)
124
+ });
125
+ //计算宽度
126
+ this.__size = this.context.measureText?
127
+ this.context.measureText(this.text):
128
+ {width:15};
129
+ this.context.restore && this.context.restore();
130
+ this.__size.height = this.style.fontSize?this.style.fontSize:15;
131
+ }
132
+
133
+ if(!this.width) this.width = this.__size.width;
134
+ if(!this.height) this.height = this.__size.height;
135
+
136
+ return this.__size;
137
+ }
138
+
139
+ /**
140
+ * 根据位置偏移画字符串
141
+ *
142
+ * @method draw
143
+ */
144
+ draw() {
145
+
146
+ //获取当前控件的绝对位置
147
+ let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
148
+ const size = this.testSize();
149
+ let location = this.location;
150
+ let x = location.left + bounds.left;
151
+ let y = location.top + bounds.top;
152
+ //通过文字对齐方式计算起始X位置
153
+ switch(this.style.textAlign) {
154
+ case 'right': {
155
+ x += location.width;
156
+ break;
157
+ }
158
+ case 'center': {
159
+ x += location.width / 2;
160
+ break;
161
+ }
162
+ }
163
+ //通过垂直对齐方式计算起始Y值
164
+ switch(this.style.textBaseline) {
165
+ case 'bottom': {
166
+ y += location.height;
167
+ break;
168
+ }
169
+ case 'hanging':
170
+ case 'alphabetic':
171
+ case 'middle' : {
172
+ y += location.height/2;
173
+ break;
174
+ }
175
+
176
+ }
177
+
178
+ let txt = this.text;
179
+ if(typeof txt !== 'undefined') {
180
+ // webgl方式
181
+ if(this.webglControl) {
182
+ this.webglControl.draw(this.points, bounds);
183
+ this.webglControl.drawText(txt, x, y, location);
184
+ }
185
+ else if(this.style.fill && this.context.fillText) {
186
+ if(this.style.maxWidth) {
187
+ this.context.fillText(txt,x,y, this.style.maxWidth);
188
+ }
189
+ else {
190
+ this.context.fillText(txt,x,y);
191
+ }
192
+ }
193
+ else if(this.context.strokeText) {
194
+ if(this.style.maxWidth) {
195
+ this.context.strokeText(txt,x,y, this.style.maxWidth);
196
+ }
197
+ else {
198
+ this.context.strokeText(txt,x,y);
199
+ }
200
+ }
201
+ }
202
+ //如果有指定边框,则画出边框
203
+ if(this.style.border) {
204
+ //如果指定了边框样式
205
+ if(this.style.border.style) {
206
+ this.context.save && this.context.save();
207
+ this.setStyle(this.style.border.style);
208
+ }
209
+ if(this.mode === '2d') {
210
+ this.context.moveTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
211
+ if(this.style.border.top) {
212
+ this.context.lineTo(this.points[1].x + bounds.left,this.points[1].y + bounds.top);
213
+ }
214
+
215
+ if(this.style.border.right) {
216
+ this.context.moveTo(this.points[1].x + bounds.left,this.points[1].y + bounds.top);
217
+ this.context.lineTo(this.points[2].x + bounds.left,this.points[2].y + bounds.top);
218
+ }
219
+
220
+ if(this.style.border.bottom) {
221
+ this.context.moveTo(this.points[2].x + bounds.left,this.points[2].y + bounds.top);
222
+ this.context.lineTo(this.points[3].x + bounds.left,this.points[3].y + bounds.top);
223
+ }
224
+
225
+ if(this.style.border.left) {
226
+ this.context.moveTo(this.points[3].x + bounds.left,this.points[3].y + bounds.top);
227
+ this.context.lineTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
228
+ }
229
+ }
230
+ else {
231
+ const points = [];
232
+ if(this.style.border.top) {
233
+ points.push(this.points[0]);
234
+ points.push(this.points[1]);
235
+ }
236
+
237
+ if(this.style.border.right) {
238
+ points.push({
239
+ ...this.points[1],
240
+ m: true
241
+ });
242
+ points.push(this.points[2]);
243
+ }
244
+
245
+ if(this.style.border.bottom) {
246
+ points.push({
247
+ ...this.points[2],
248
+ m: true
249
+ });
250
+ points.push(this.points[3]);
251
+ }
252
+
253
+ if(this.style.border.left) {
254
+ points.push({
255
+ ...this.points[3],
256
+ m: true
257
+ });
258
+ points.push(this.points[0]);
259
+ }
260
+ points.length && this.webglControl && this.webglControl.stroke(points);
261
+ }
262
+ }
263
+ }
264
+
265
+ endDraw() {
266
+ if(this.mode === '2d') {
267
+ super.endDraw();
268
+ }
269
+ }
270
+ }
271
+
272
272
  export { jmLabel };