jmgraph 3.2.18 → 3.2.20

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 (57) hide show
  1. package/README.md +174 -2
  2. package/dist/jmgraph.core.min.js +1 -1
  3. package/dist/jmgraph.core.min.js.map +1 -1
  4. package/dist/jmgraph.js +1672 -147
  5. package/dist/jmgraph.min.js +1 -1
  6. package/index.js +13 -2
  7. package/package.json +1 -1
  8. package/src/core/jmGraph.js +460 -5
  9. package/src/core/jmLayer.js +142 -0
  10. package/src/core/jmPath.js +55 -0
  11. package/src/lib/webgl/base.js +6 -0
  12. package/src/lib/webgl/path.js +8 -11
  13. package/src/shapes/jmEllipse.js +91 -0
  14. package/src/shapes/jmLabel.js +127 -15
  15. package/src/shapes/jmPolygon.js +129 -0
  16. package/src/shapes/jmStar.js +160 -0
  17. package/example/ball.html +0 -217
  18. package/example/base.html +0 -112
  19. package/example/canvas.html +0 -54
  20. package/example/cell.html +0 -284
  21. package/example/controls/arc.html +0 -129
  22. package/example/controls/arrowline.html +0 -78
  23. package/example/controls/bezier.html +0 -299
  24. package/example/controls/img.html +0 -97
  25. package/example/controls/label.html +0 -87
  26. package/example/controls/line.html +0 -173
  27. package/example/controls/prismatic.html +0 -63
  28. package/example/controls/rect.html +0 -64
  29. package/example/controls/resize.html +0 -112
  30. package/example/controls/test.html +0 -360
  31. package/example/es.html +0 -70
  32. package/example/es5module.html +0 -63
  33. package/example/heartarc.html +0 -116
  34. package/example/index.html +0 -47
  35. package/example/js/require.js +0 -5
  36. package/example/love/img/bling/bling.tps +0 -265
  37. package/example/love/img/bling.json +0 -87
  38. package/example/love/img/bling.tps +0 -295
  39. package/example/love/img/doc/bling.gif +0 -0
  40. package/example/love/img/love.json +0 -95
  41. package/example/love/img/love.tps +0 -315
  42. package/example/love/img/qq/qq.tps +0 -399
  43. package/example/love/img/qq.json +0 -242
  44. package/example/love/index.html +0 -40
  45. package/example/love/js/game.js +0 -558
  46. package/example/music.html +0 -211
  47. package/example/node/test.js +0 -138
  48. package/example/pdf.html +0 -187
  49. package/example/progress.html +0 -173
  50. package/example/pso.html +0 -148
  51. package/example/sort.html +0 -805
  52. package/example/tweenjs.html +0 -84
  53. package/example/webgl.html +0 -278
  54. package/example/xfj/img/dr_die.gif +0 -0
  55. package/example/xfj/index.html +0 -332
  56. package/example/xfj/shake.js +0 -49
  57. package/example/xfj/testori.html +0 -76
@@ -1,63 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- html,body{
8
- margin:0;
9
- padding: 0;
10
- }
11
- #mycanvas_container{
12
- overflow: hidden;
13
- }
14
- </style>
15
-
16
- </head>
17
- <body>
18
- <div id="mycanvas_container"></div>
19
- </body>
20
- <script type="module">
21
- import { jmGraph } from "../../index.js";
22
-
23
- //开发模式下,引用jmGraph.js,请使用这种方式,内部会初始化组件
24
- var g = jmGraph.create('mycanvas_container', {
25
- width: 800,
26
- height: 600,
27
- mode: '2d',
28
- style: {
29
- fill: '#000'
30
- }
31
- });
32
-
33
- init(g);
34
-
35
- function init(g){
36
- //g.style.fill = '#000'; //画布背景
37
- var style = {
38
- stroke: '#A2D84B',
39
- fill: 'transparent',
40
- shadow: '0,0,10,#fff'
41
- };
42
- //style.opacity = 0.2;
43
-
44
- //创建
45
- var prismatic = g.createShape('prismatic',{
46
- style:style,
47
- center:{x:200,y:150},
48
- width:120,
49
- height:80
50
- });
51
- //prismatic.canMove(true);
52
- g.children.add(prismatic);
53
-
54
-
55
- function update() {
56
- if(g.needUpdate) g.redraw();
57
- requestAnimationFrame(update);
58
- }
59
-
60
- update();
61
- }
62
- </script>
63
- </html>
@@ -1,64 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- html,body{
8
- margin:0;
9
- padding: 0;
10
- }
11
- #mycanvas_container{
12
- overflow: hidden;
13
- }
14
- </style>
15
- </head>
16
- <body>
17
- <div id="mycanvas_container"></div>
18
- </body>
19
- <script type="module">
20
- import { jmGraph } from "../../index.js";
21
-
22
- var container = document.getElementById('mycanvas_container');
23
-
24
- //开发模式下,引用jmGraph.js,请使用这种方式,内部会初始化组件
25
- var g = jmGraph.create('mycanvas_container', {
26
- width: 800,
27
- height: 600,
28
- mode: '2d',
29
- style: {
30
- fill: '#000'
31
- }
32
- });
33
- init(g);
34
-
35
-
36
- function init(g){
37
- //g.style.fill = '#000'; //画布背景
38
- var style = {
39
- stroke: 'red',
40
- fill: 'yellow',
41
- lineWidth: 1.1 //边线宽
42
- };
43
- //style.opacity = 0.2;
44
-
45
- //创建
46
- var rect = g.createShape('rect', {
47
- style: style,
48
- position: {x:200, y:150},
49
- width: 120,
50
- height: 80
51
- });
52
-
53
- g.children.add(rect);
54
- rect.canMove(true);
55
-
56
- function update() {
57
- if(g.needUpdate) g.redraw();
58
- requestAnimationFrame(update);
59
- }
60
-
61
- update();
62
- }
63
- </script>
64
- </html>
@@ -1,112 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- html,body{
8
- margin:0;
9
- padding: 0;
10
- }
11
- #mycanvas_container{
12
- overflow: hidden;
13
- text-align: center;
14
- }
15
-
16
- </style>
17
- </head>
18
- <body>
19
- <div id="mycanvas_container"></div>
20
- <button onclick="zoomIn()">放大</button>
21
- <button onclick="zoomOut()">缩小</button>
22
- <button onclick="zoomActual()">复原</button>
23
- </body>
24
- <script type="module">
25
- import { jmGraph } from "../../index.js";
26
- import jmResize from '../../src/shapes/jmResize.js';
27
-
28
- var container = document.getElementById('mycanvas_container');
29
-
30
- //开发模式下,引用jmGraph.js,请使用这种方式,内部会初始化组件
31
- var g = window.graph = jmGraph.create('mycanvas_container', {
32
- width: 800,
33
- height: 600,
34
- mode: '2d',
35
- autoRefresh: true,
36
- style: {
37
- fill: '#000',
38
- }
39
- });
40
- init(g);
41
-
42
-
43
- function init(g){
44
- //g.style.fill = '#000'; //画布背景
45
- var style = {
46
- stroke: 'red',
47
- fill: 'yellow',
48
- lineWidth: 2, //边线宽
49
- rotation: {
50
- angle: 0
51
- },
52
- //小方块样式
53
- rectStyle: {
54
- stroke: 'green', //小方块边颜色
55
- fill: '#ccc',//小方块填充色
56
- lineWidth: 1.1, //小方块线宽
57
- close: true
58
- }
59
- };
60
- //style.opacity = 0.2;
61
-
62
- //创建一个resize
63
- var resize = g.createShape(jmResize, {
64
- style: style,
65
- position: {x:200, y:150},
66
- width: 120,
67
- height: 80
68
- });
69
- //大小改变事件
70
- resize.on('resize', function() {
71
- console.log( Date.now(), arguments);
72
- });
73
- resize.canMove(true);
74
- g.children.add(resize);
75
-
76
- g.on('update', (time) => {
77
- //style.rotation.angle += 0.01;
78
- //g.needUpdate = true;
79
- });
80
- }
81
-
82
-
83
- </script>
84
- <script>
85
- var curentScale = {x: 1, y: 1};
86
- function zoomIn() {
87
- window.graph && window.graph.scale(1.1, 1.1);
88
- //window.graph && window.graph.resize(window.graph.width * 1.1, window.graph.height * 1.1);
89
- //curentScale.x += 0.1;
90
- //curentScale.y += 0.1;
91
- //window.graph && (window.graph.canvas.style.transform = `scale(${curentScale.x}, ${curentScale.y})`);
92
- }
93
-
94
- function zoomOut() {
95
- window.graph && window.graph.scale(0.9, 0.9);
96
- //window.graph && window.graph.resize(window.graph.width * 0.9, window.graph.height * 0.9);
97
- //curentScale.x -= 0.1;
98
- //curentScale.y -= 0.1;
99
- //window.graph && (window.graph.canvas.style.transform = `scale(${curentScale.x}, ${curentScale.y})`);
100
-
101
- }
102
-
103
- function zoomActual() {
104
- window.graph && window.graph.zoomActual();
105
- //window.graph && window.graph.resize(800, 600);
106
- //curentScale.x = 1;
107
- //curentScale.y = 1;
108
- //window.graph && (window.graph.canvas.style.transform = `scale(${curentScale.x}, ${curentScale.y})`);
109
-
110
- }
111
- </script>
112
- </html>
@@ -1,360 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- html,body{
8
- margin:0;
9
- padding: 0;
10
- }
11
- #mycanvas_container{
12
- overflow: hidden;
13
- }
14
- </style>
15
-
16
- </head>
17
- <body>
18
- <div id="mycanvas_container"></div>
19
- </body>
20
- <script type="module">
21
- import {jmGraph} from "../../index.js";
22
- import {jmRect} from "../../src/shapes/jmRect.js";
23
- import {jmPath} from "../../src/core/jmPath.js";
24
- /**
25
- * 测试
26
- */
27
-
28
- class jmTest extends jmPath {
29
- constructor(params) {
30
- if(!params) params = {};
31
- super(params);
32
- this.center = params.center || {x:0, y:0};
33
- this.radius = params.radius || 0;
34
- }
35
-
36
- //定义属性
37
- /**
38
- * 中心点
39
- * point格式:{x:0,y:0,m:true}
40
- * @property center
41
- * @type {point}
42
- */
43
- get center() {
44
- return this.property('center');
45
- }
46
- set center(v) {
47
- return this.property('center', v);
48
- }
49
- /**
50
- * 中心点
51
- * point格式:{x:0,y:0,m:true}
52
- * @property center
53
- * @type {point}
54
- */
55
- get radius() {
56
- return this.property('radius');
57
- }
58
- set radius(v) {
59
- return this.property('radius', v);
60
- }
61
-
62
- /**
63
- * 初始化图形点
64
- * 控件都是由点形成
65
- *
66
- * @method initPoint
67
- * @private
68
- * @for jmArc
69
- */
70
- initPoints() {
71
- //可以获取当前控件的左上坐标,可以用来画相对位置
72
- var location = this.getLocation();//获取位置参数
73
-
74
- var cx = location.center.x ;
75
- var cy = location.center.y ;
76
-
77
- this.points = [];
78
-
79
- //简单的画一个X
80
-
81
- //根据半径计算x,y偏移量
82
- //由于是圆,偏移量相同
83
- var offw = Math.sqrt(location.radius * location.radius / 2);
84
- //左上角到右下角对角线
85
- this.points.push({x:cx - offw, y:cy-offw}, {x:cx + offw, y:cy+offw});
86
-
87
- //左下角到右上角对角线
88
- //画完上面的线后,需要重新移到这条线的起点,指定m:true即可
89
- this.points.push({x:cx - offw, y:cy+offw, m:true}, {x:cx + offw, y:cy-offw});
90
-
91
- return this.points;
92
- }
93
- }
94
-
95
- // 图片裁剪框
96
- class ImageEditCover extends jmPath {
97
- constructor(params = {}) {
98
- super(params);
99
- this.style.close = this.style.close || true;
100
- this.init(params);
101
- }
102
- // 初始化控件元素
103
- init(params) {
104
- this.width = this.width || '100%';
105
- this.height = this.height || '100%';
106
- // 生成层
107
- const rectStyle = {
108
- stroke: 'transparent',
109
- fill: 'rgba(100,100,100,0.4)',
110
- lineWidth: 0.1,
111
- zIndex: 1,
112
- };
113
- const graph = (this.graph || params.graph);
114
- const leftRect = graph.createShape(jmRect, {
115
- position:{x:0, y:0 },
116
- width: 0,
117
- height: '100%',
118
- style: rectStyle,
119
- interactive: false
120
- });
121
- const topRect = graph.createShape(jmRect, {
122
- position:{x:0, y:0 },
123
- width: '100%',
124
- height: 0,
125
- style: rectStyle,
126
- interactive: false
127
- });
128
- const rightRect = graph.createShape(jmRect, {
129
- position:{x:0, y:0 },
130
- width: 0,
131
- height: '100%',
132
- style: rectStyle,
133
- interactive: false
134
- });
135
- const bottomRect = graph.createShape(jmRect, {
136
- position:{x:0, y:0 },
137
- width: '100%',
138
- height: 0,
139
- style: rectStyle,
140
- interactive: false
141
- });
142
- this.rects.push(leftRect, topRect, rightRect, bottomRect);
143
- this.children.add(leftRect);
144
- this.children.add(topRect);
145
- this.children.add(rightRect);
146
- this.children.add(bottomRect);
147
-
148
- const controlStyle = {
149
- lineWidth: 3,
150
- stroke: '#fff',
151
- zIndex: 100,
152
- }
153
- const c1 = graph.createShape(jmPath, {
154
- style: controlStyle,
155
- interactive: true
156
- });
157
- const c2 = graph.createShape(jmPath, {
158
- style: controlStyle,
159
- interactive: true
160
- });
161
- const c3 = graph.createShape(jmPath, {
162
- style: controlStyle,
163
- interactive: true
164
- });
165
- const c4 = graph.createShape(jmPath, {
166
- style: controlStyle,
167
- interactive: true
168
- });
169
- this.controls.push(c1, c2, c3, c4);
170
-
171
- this.children.add(c1);
172
- this.children.add(c2);
173
- this.children.add(c3);
174
- this.children.add(c4);
175
-
176
- c1.canMove(true);
177
- c2.canMove(true);
178
- c3.canMove(true);
179
- c4.canMove(true);
180
-
181
- }
182
-
183
- // 裁剪的目录区域
184
- // 最终改变结果也是这个参数
185
- targetBounds = {
186
- x: 0,
187
- y: 0,
188
- width: 0,
189
- height: 0
190
- }
191
-
192
- rects = [];
193
- // 操作折角
194
- controls = [];
195
-
196
- /**
197
- * 初始化图形点
198
- * 控件都是由点形成
199
- *
200
- * @method initPoint
201
- * @private
202
- * @for jmArc
203
- */
204
- initPoints() {
205
- //可以获取当前控件的左上坐标,可以用来画相对位置
206
- const location = this.getLocation();//获取位置参数
207
-
208
- const targetLeft = location.width / 2 - this.targetBounds.width / 2;
209
- const targetRight = location.width / 2 + this.targetBounds.width / 2;
210
- const targetBottom = this.targetBounds.y + this.targetBounds.height;
211
-
212
- this.rects[0].width = targetLeft + 0.1;
213
-
214
- this.rects[1].height = this.targetBounds.y;
215
- this.rects[1].width = this.targetBounds.width + 0.1;
216
- this.rects[1].position.x = targetLeft;
217
-
218
- this.rects[2].width = location.width - targetRight;
219
- this.rects[2].position.x = targetRight;
220
-
221
- this.rects[3].height = location.height - targetBottom;
222
- this.rects[3].width = this.targetBounds.width + 0.1;
223
- this.rects[3].position.x = targetLeft;
224
- this.rects[3].position.y = targetBottom;
225
-
226
- return this.points;
227
- }
228
- resetControlsPosition() {
229
- //可以获取当前控件的左上坐标,可以用来画相对位置
230
- const location = this.getLocation();//获取位置参数
231
-
232
- const targetLeft = location.width / 2 - this.targetBounds.width / 2;
233
- const targetRight = location.width / 2 + this.targetBounds.width / 2;
234
- const targetBottom = this.targetBounds.y + this.targetBounds.height;
235
-
236
- // 操作折角位置
237
- const controlWidth = 10;
238
- const controlLineWidth = this.controls[0].style.lineWidth || 2;
239
- this.controls[0].points = [
240
- {
241
- x: targetLeft - controlLineWidth/2,
242
- y: this.targetBounds.y + controlWidth
243
- },
244
- {
245
- x: targetLeft - controlLineWidth/2,
246
- y: this.targetBounds.y - controlLineWidth/2
247
- },
248
- {
249
- x: targetLeft + controlWidth,
250
- y: this.targetBounds.y - controlLineWidth/2
251
- }
252
- ];
253
-
254
- this.controls[1].points = [
255
- {
256
- x: targetRight - controlWidth,
257
- y: this.targetBounds.y - controlLineWidth/2
258
- },
259
- {
260
- x: targetRight + controlLineWidth/2,
261
- y: this.targetBounds.y - controlLineWidth/2
262
- },
263
- {
264
- x: targetRight + controlLineWidth/2,
265
- y: this.targetBounds.y + controlWidth
266
- }
267
- ];
268
-
269
- this.controls[2].points = [
270
- {
271
- x: targetRight - controlWidth,
272
- y: targetBottom + controlLineWidth/2
273
- },
274
- {
275
- x: targetRight + controlLineWidth/2,
276
- y: targetBottom + controlLineWidth/2
277
- },
278
- {
279
- x: targetRight + controlLineWidth/2,
280
- y: targetBottom - controlWidth
281
- }
282
- ];
283
-
284
- this.controls[3].points = [
285
- {
286
- x: targetLeft - controlLineWidth/2,
287
- y: targetBottom - controlWidth
288
- },
289
- {
290
- x: targetLeft - controlLineWidth/2,
291
- y: targetBottom + controlLineWidth/2
292
- },
293
- {
294
- x: targetLeft + controlWidth,
295
- y: targetBottom + controlLineWidth/2
296
- }
297
- ];
298
- }
299
- }
300
- var container = document.getElementById('mycanvas_container');
301
-
302
- var g = jmGraph.create(container, {
303
- width: 800,
304
- height: 600,
305
- mode: '2d',
306
- style: {
307
- fill: '#000'
308
- }
309
- });
310
-
311
- init(g);
312
-
313
- function init(g){
314
-
315
- var style = {
316
- stroke: '#23f24e',
317
- lineWidth: 5,
318
- shadow: '0,0,20,#fff'
319
- };
320
-
321
- //style.opacity = 0.2;
322
-
323
- //创建一个自定义的控件
324
- var t = g.createShape(jmTest, {
325
- style: style,
326
- center: {x:100,y:100},
327
- radius: 20,
328
- });
329
-
330
- g.children.add(t);
331
- t.canMove(true);
332
-
333
- const editorCover = g.createShape(ImageEditCover, {
334
- style: {
335
- fill: 'transparent',
336
- stroke: 'transparent',
337
- },
338
- interactive: true
339
- });
340
-
341
- editorCover.targetBounds = {
342
- x: 100,
343
- y: 100,
344
- width: 200,
345
- height: 300,
346
- };
347
- //editorCover.visible = false;
348
- g.children.add(editorCover);
349
-
350
- editorCover.resetControlsPosition();
351
-
352
- function update() {
353
- if(g.needUpdate) g.redraw();
354
- requestAnimationFrame(update);
355
- }
356
-
357
- update();
358
- }
359
- </script>
360
- </html>
package/example/es.html DELETED
@@ -1,70 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- html,body{
8
- margin:0;
9
- padding: 0;
10
- }
11
- canvas {
12
- cursor: pointer;
13
- }
14
- #mycanvas_container{
15
- overflow: hidden;
16
- }
17
- </style>
18
- </head>
19
- <body>
20
- <div id="mycanvas_container"></div>
21
- </body>
22
- <script type="module">
23
- //import jmGraph from "../dist/jmgraph.es6.js";
24
- import jmGraph from "../index.js";
25
-
26
- var container = document.getElementById('mycanvas_container');
27
-
28
- var g = new jmGraph(container, {
29
- width: 800,
30
- height: 600,
31
- style: {
32
- fill: '#000'
33
- }
34
- });
35
- init(g);
36
-
37
- function init(g){
38
- //g.style.fill = '#000'; //画布背景
39
- var style = {
40
- stroke:'#46BF86',
41
- fill: '#556662',
42
- lineWidth: 2
43
- };
44
- style.shadow = '0,0,10,#fff';
45
- //style.opacity = 0.2;
46
- //style.lineCap = 'round';
47
-
48
- //创建一个方块
49
- var rect = g.createShape('rect', {
50
- style:style,
51
- position: {x:100,y:100},
52
- width:100,
53
- height:100
54
- });
55
- g.children.add(rect);
56
- rect.canMove(true);
57
-
58
- rect.on('click', function(e) {
59
- alert('click');
60
- });
61
-
62
- function update() {
63
- if(g.needUpdate) g.redraw();
64
- requestAnimationFrame(update);
65
- }
66
-
67
- update();
68
- }
69
- </script>
70
- </html>