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
package/example/pso.html DELETED
@@ -1,148 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
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
- <title>pso</title>
7
- <style>
8
- html,body {
9
- margin:0;
10
- padding:0;
11
- width:100%;
12
- height:100%;
13
- background-color: #000;
14
- overflow: hidden;
15
- }
16
- #pso {
17
- position: absolute;
18
- }
19
- </style>
20
- </head>
21
- <body>
22
- <div>
23
- <canvas id="pso">你的浏览器暂不支持此功能</canvas>
24
- </div>
25
- <script type="module">
26
- import jmGraph from "../index.js";
27
-
28
- const curPos = {x: 400, y: 400};
29
-
30
- const graph = new jmGraph('pso', {
31
- width: window.innerWidth,
32
- height: window.innerHeight,
33
- autoRefresh: true,
34
- mode: 'webgl'
35
- });
36
-
37
- function createItems(count) {
38
- var style = {
39
- lineWidth:1,
40
- close:true,
41
- //stroke:'#fff',
42
- fill:'#05a2e2'
43
- };
44
- let radius = 2;
45
-
46
- let items = [];
47
- for(let i=0; i<count; i++) {
48
-
49
- var styletmp = graph.util.clone(style);
50
- styletmp.fill = graph.createRadialGradient(radius, radius, 0, radius, radius, radius);
51
- var rr1 = Math.floor(Math.random() * 255);
52
- var gg1 = Math.floor(Math.random() * 255);
53
- var bb1 = Math.floor(Math.random() * 255);
54
- var rr2 = Math.floor(Math.random() * 255);
55
- var gg2 = Math.floor(Math.random() * 255);
56
- var bb2 = Math.floor(Math.random() * 255);
57
- styletmp.fill.addStop(0, graph.util.toColor(rr1,gg1,bb1));
58
- styletmp.fill.addStop(1, graph.util.toColor(rr2,gg2,bb2));
59
-
60
- let pos = {
61
- x: Math.random() * graph.width,
62
- y: Math.random() * graph.height
63
- };
64
- let shape = graph.createShape('circle',{style: styletmp, center: pos, radius: radius, anticlockwise:true});
65
- graph.children.add(shape);
66
- items.push({
67
- velocity:{
68
- x:0,
69
- y:0
70
- },
71
- present: pos,
72
- shape: shape
73
- });
74
- }
75
- return items;
76
- }
77
-
78
-
79
- const pso = {
80
- c1: 2,
81
- c2: 2,
82
- w: 0.6,
83
- velocity:function (pBest, gBest, present, velocity) {
84
- let v = velocity||{x:0,y:0};
85
- v.x = this.w*v.x + this.c1*Math.random()*(pBest.x - present.x) + this.c2*Math.random()*(gBest.x - present.x);
86
- v.y = this.w*v.y + this.c1*Math.random()*(pBest.y - present.y) + this.c2*Math.random()*(gBest.y - present.y);
87
- return v;
88
- },
89
- present:function ( velocity,present) {
90
- let p = present||{x:0,y:0};
91
- p.x = p.x + velocity.x;
92
- p.y = p.y + velocity.y;
93
- return p;
94
- },
95
- gBest:function (arr,goal) {
96
- let gBest = {
97
- x: Number.POSITIVE_INFINITY,
98
- y: Number.POSITIVE_INFINITY
99
- };
100
- arr.forEach(function (item) {
101
- if(Math.abs(goal.x-gBest.x) > Math.abs(goal.x-item.present.x)){
102
- gBest.x = item.present.x
103
- }
104
- if(Math.abs(goal.y-gBest.y) > Math.abs(goal.y-item.present.y)){
105
- gBest.y = item.present.y
106
- }
107
- });
108
- return gBest
109
- }
110
- };
111
-
112
- function startPso(items) {
113
- items = items || createItems(500);
114
- const gBest = pso.gBest(items, curPos);
115
- for(let i = 0;i < items.length;i++){
116
- items[i].velocity = pso.velocity(items[i].present, gBest, items[i].present, items[i].velocity);
117
- items[i].present = pso.present(items[i].velocity, items[i].present);
118
- }
119
- graph.needUpdate = true;
120
- }
121
-
122
- const items = createItems(1000);
123
-
124
- //实时更新画布
125
- function update() {
126
- startPso(items);
127
- setTimeout(()=>{
128
- graph.requestAnimationFrame(update);
129
- }, 50);
130
- }
131
- graph.requestAnimationFrame(update);
132
-
133
- graph.on('mousedown mousemove', (e) => {
134
- curPos.x = e.position.x;
135
- curPos.y = e.position.y;
136
- });
137
- graph.on('touchstart touchmove', (e) => {
138
- curPos.x = e.position.x;
139
- curPos.y = e.position.y;
140
- });
141
-
142
- setInterval(()=>{
143
- curPos.x = Math.random() * graph.width;
144
- curPos.y = Math.random() * graph.height;
145
- }, 1000);
146
- </script>
147
- </body>
148
- </html>