jmgraph 3.2.6 → 3.2.7

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 (71) hide show
  1. package/build/gulpfile.js +143 -0
  2. package/build/package-lock.json +19282 -0
  3. package/build/package.json +71 -0
  4. package/dist/jmgraph.core.min.js +1 -1
  5. package/dist/jmgraph.core.min.js.map +1 -1
  6. package/dist/jmgraph.js +29 -4
  7. package/dist/jmgraph.min.js +1 -1
  8. package/docs/_config.yml +1 -0
  9. package/docs/about.html +41 -0
  10. package/docs/api/jmGraph.md +2302 -0
  11. package/docs/css/index.css +131 -0
  12. package/docs/images/ball.gif +0 -0
  13. package/docs/images/bezier.gif +0 -0
  14. package/docs/images/cell.gif +0 -0
  15. package/docs/images/chart.gif +0 -0
  16. package/docs/images/editor.gif +0 -0
  17. package/docs/images/sort.gif +0 -0
  18. package/docs/index.html +80 -0
  19. package/docs/js/helper.js +89 -0
  20. package/docs/js/jquery.min.js +6 -0
  21. package/example/ball.html +223 -0
  22. package/example/base.html +112 -0
  23. package/example/canvas.html +54 -0
  24. package/example/cell.html +284 -0
  25. package/example/controls/arc.html +126 -0
  26. package/example/controls/arrowline.html +77 -0
  27. package/example/controls/bezier.html +223 -0
  28. package/example/controls/img.html +90 -0
  29. package/example/controls/label.html +85 -0
  30. package/example/controls/line.html +170 -0
  31. package/example/controls/prismatic.html +63 -0
  32. package/example/controls/rect.html +64 -0
  33. package/example/controls/resize.html +75 -0
  34. package/example/controls/test.html +136 -0
  35. package/example/es.html +70 -0
  36. package/example/es5module.html +64 -0
  37. package/example/heartarc.html +116 -0
  38. package/example/index.html +46 -0
  39. package/example/js/require.js +5 -0
  40. package/example/love/img/bling/bling.tps +265 -0
  41. package/example/love/img/bling.json +87 -0
  42. package/example/love/img/bling.tps +295 -0
  43. package/example/love/img/doc/bling.gif +0 -0
  44. package/example/love/img/love.json +95 -0
  45. package/example/love/img/love.tps +315 -0
  46. package/example/love/img/music/bg.mp3 +0 -0
  47. package/example/love/img/music/bg_2019130144035.mp3 +0 -0
  48. package/example/love/img/music/f.mp3 +0 -0
  49. package/example/love/img/music/fail.mp3 +0 -0
  50. package/example/love/img/music/s.mp3 +0 -0
  51. package/example/love/img/music/s_201913014415.mp3 +0 -0
  52. package/example/love/img/qq/qq.tps +399 -0
  53. package/example/love/img/qq.json +242 -0
  54. package/example/love/index.html +40 -0
  55. package/example/love/js/game.js +558 -0
  56. package/example/music.html +192 -0
  57. package/example/node/test.js +138 -0
  58. package/example/pdf.html +187 -0
  59. package/example/progress.html +173 -0
  60. package/example/pso.html +148 -0
  61. package/example/sort.html +816 -0
  62. package/example/tweenjs.html +84 -0
  63. package/example/webgl.html +255 -0
  64. package/example/xfj/img/dr_die.gif +0 -0
  65. package/example/xfj/index.html +332 -0
  66. package/example/xfj/shake.js +49 -0
  67. package/example/xfj/testori.html +76 -0
  68. package/package.json +1 -1
  69. package/src/core/jmControl.js +3 -2
  70. package/src/core/jmGradient.js +4 -0
  71. package/src/core/jmGraph.js +6 -4
@@ -0,0 +1,148 @@
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: '2d'
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>