jmgraph 3.2.19 → 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 (55) 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 +1640 -135
  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 +453 -4
  9. package/src/core/jmLayer.js +142 -0
  10. package/src/core/jmPath.js +55 -0
  11. package/src/shapes/jmEllipse.js +91 -0
  12. package/src/shapes/jmLabel.js +127 -15
  13. package/src/shapes/jmPolygon.js +129 -0
  14. package/src/shapes/jmStar.js +160 -0
  15. package/example/ball.html +0 -217
  16. package/example/base.html +0 -112
  17. package/example/canvas.html +0 -54
  18. package/example/cell.html +0 -284
  19. package/example/controls/arc.html +0 -129
  20. package/example/controls/arrowline.html +0 -78
  21. package/example/controls/bezier.html +0 -299
  22. package/example/controls/img.html +0 -97
  23. package/example/controls/label.html +0 -87
  24. package/example/controls/line.html +0 -173
  25. package/example/controls/prismatic.html +0 -63
  26. package/example/controls/rect.html +0 -64
  27. package/example/controls/resize.html +0 -112
  28. package/example/controls/test.html +0 -360
  29. package/example/es.html +0 -70
  30. package/example/es5module.html +0 -63
  31. package/example/heartarc.html +0 -116
  32. package/example/index.html +0 -47
  33. package/example/js/require.js +0 -5
  34. package/example/love/img/bling/bling.tps +0 -265
  35. package/example/love/img/bling.json +0 -87
  36. package/example/love/img/bling.tps +0 -295
  37. package/example/love/img/doc/bling.gif +0 -0
  38. package/example/love/img/love.json +0 -95
  39. package/example/love/img/love.tps +0 -315
  40. package/example/love/img/qq/qq.tps +0 -399
  41. package/example/love/img/qq.json +0 -242
  42. package/example/love/index.html +0 -40
  43. package/example/love/js/game.js +0 -558
  44. package/example/music.html +0 -211
  45. package/example/node/test.js +0 -138
  46. package/example/pdf.html +0 -187
  47. package/example/progress.html +0 -173
  48. package/example/pso.html +0 -148
  49. package/example/sort.html +0 -805
  50. package/example/tweenjs.html +0 -84
  51. package/example/webgl.html +0 -278
  52. package/example/xfj/img/dr_die.gif +0 -0
  53. package/example/xfj/index.html +0 -332
  54. package/example/xfj/shake.js +0 -49
  55. package/example/xfj/testori.html +0 -76
@@ -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>
@@ -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
- </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
- var g = new jmGraph(container, {
25
- width: 800,
26
- height: 600,
27
- style: {
28
- fill: '#000'
29
- }
30
- });
31
- init(g);
32
-
33
-
34
- function init(g){
35
- //g.style.fill = '#000'; //画布背景
36
- var style = {
37
- stroke:'#46BF86',
38
- fill: '#556662',
39
- lineWidth: 2
40
- };
41
- style.shadow = '0,0,10,#fff';
42
- //style.opacity = 0.2;
43
- //style.lineCap = 'round';
44
-
45
- //创建一个方块
46
- var rect = g.createShape('rect', {
47
- style:style,
48
- position: {x:100,y:100},
49
- width:100,
50
- height:100
51
- });
52
- g.children.add(rect);
53
- rect.canMove(true);
54
-
55
- function update() {
56
- if(g.needUpdate) g.redraw();
57
- requestAnimationFrame(update);
58
- }
59
-
60
- update();
61
- }
62
- </script>
63
- </html>
@@ -1,116 +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
- <!--<script type="text/javascript" src="../src/jmGraph.js"></script>
7
- <script type="text/javascript" src="../dist/jmGraph.min.js"></script> -->
8
- <style>
9
- html,body {
10
- margin:0;
11
- padding:0;
12
- width:100%;
13
- height:100%;
14
- overflow: hidden;
15
- }
16
- #mycanvas {
17
- background-color:#000;
18
- position: absolute;
19
- width: 100%;
20
- height: 100%;
21
- }
22
- </style>
23
-
24
- </head>
25
- <body >
26
- <div id="mycanvas">
27
- </div>
28
-
29
- </body>
30
- </html>
31
-
32
- <script type="module">
33
- import jmGraph from "../index.js";
34
-
35
- //初始化jmgraph
36
- var graph = new jmGraph('mycanvas', {
37
- mode: '2d'
38
- });
39
-
40
- var arcStyle = {
41
- lineWidth:1.1,
42
- stroke: 'green',
43
- close:true
44
- };
45
- var radius = 50;
46
- var center1 = {
47
- x: 400,
48
- y: 400
49
- };
50
- var arc1 = graph.createShape('circle',{
51
- style: arcStyle,
52
- center: center1,
53
- radius: radius,
54
- anticlockwise: false
55
- });
56
- graph.children.add(arc1);
57
-
58
- var center2 = {
59
- x: center1.x,
60
- y: center1.y + radius * 2
61
- };
62
- var arc2 = graph.createShape('circle',{
63
- style: arcStyle,
64
- center: center2,
65
- radius: radius,
66
- anticlockwise: false
67
- });
68
- graph.children.add(arc2);
69
-
70
- var heartStyle = {
71
- stroke: 'red',
72
- lineWidth: 2
73
- };
74
- const heartStart = {
75
- x: center1.x,
76
- y: center1.y + radius
77
- };
78
- var heart = graph.createShape('path',{
79
- style: heartStyle,
80
- points: [heartStart]
81
- });
82
- graph.children.add(heart);
83
-
84
- var r = 0;
85
- const startX = center1.x;
86
- const startY = center1.y;
87
- function goTrack() {
88
-
89
- const l = 2 * radius * Math.sin(r) * 2;
90
- const ox = Math.cos(r) * l;
91
- const oy = Math.sin(r) * l;
92
- center1.x = startX - ox;
93
- center1.y = startY + oy;
94
-
95
- const heartPoint = {
96
- x: center1.x + radius * Math.cos(4 * r - Math.PI/2),
97
- y: center1.y - radius * Math.sin(4 * r - Math.PI/2)
98
- }
99
- heart.points.push(heartPoint);
100
-
101
- graph.redraw();
102
-
103
- if(r >= Math.PI) {
104
- r = 0;
105
- heart.points = [heartStart];
106
- }
107
-
108
- r += 0.02;
109
-
110
-
111
-
112
- setTimeout(goTrack, 10);
113
- }
114
-
115
- goTrack();
116
- </script>
@@ -1,47 +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
- .left{
8
- float:left;
9
- width:10%;
10
- }
11
- .left ul {
12
- list-style: none;
13
- padding-left:4px;
14
- }
15
- .right{
16
- float:right;
17
- width:90%;
18
- }
19
- </style>
20
- </head>
21
- <body>
22
- <div class="right"><iframe width="100%" height="1024" frameborder="0" scrolling="no" name="webbrowers" src="sort.html"></iframe></div>
23
-
24
- <div class="left">
25
- <ul>
26
- <li><a href="sort.html" target="webbrowers">排序算法演示</a></li>
27
- <li><a href="cell.html" target="webbrowers">孢子游戏</a></li>
28
- <li><a href="ball.html" target="webbrowers">球碰撞试验</a></li>
29
- <li><a href="progress.html" target="webbrowers">动画</a></li>
30
- <li><a href="controls/arc.html" target="webbrowers">画圆</a></li>
31
- <li><a href="controls/line.html" target="webbrowers">线条</a></li>
32
- <li>
33
- <a href="controls/bezier.html" target="webbrowers">贝塞尔曲线</a></li>
34
-
35
- <li><a href="controls/arrowline.html" target="webbrowers">箭头</a></li>
36
- <li><a href="controls/img.html" target="webbrowers">图片</a></li>
37
- <li><a href="controls/label.html" target="webbrowers">文字</a></li>
38
- <li><a href="controls/prismatic.html" target="webbrowers">棱形</a></li>
39
- <li><a href="controls/resize.html" target="webbrowers">可缩放方块</a></li>
40
- <li><a href="music.html" target="webbrowers">音乐图谱</a></li>
41
- <li><a href="pso.html" target="webbrowers">PSO</a></li>
42
- <li><a href="heartarc.html" target="webbrowers">心图</a></li>
43
- </ul>
44
- </div>
45
-
46
- </body>
47
- </html>