jmgraph 3.2.19 → 3.2.21

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 (63) hide show
  1. package/README.md +311 -6
  2. package/dist/jmgraph.core.min.js +1 -1
  3. package/dist/jmgraph.core.min.js.map +1 -1
  4. package/dist/jmgraph.js +2022 -368
  5. package/dist/jmgraph.min.js +1 -1
  6. package/index.js +23 -25
  7. package/package.json +1 -1
  8. package/src/core/jmControl.js +199 -30
  9. package/src/core/jmFilter.js +150 -0
  10. package/src/core/jmGraph.js +207 -7
  11. package/src/core/jmLayer.js +142 -0
  12. package/src/core/jmPath.js +55 -0
  13. package/src/core/jmUtils.js +46 -37
  14. package/src/lib/webgl/base.js +10 -36
  15. package/src/lib/webgl/gradient.js +16 -3
  16. package/src/lib/webgl/index.js +5 -4
  17. package/src/lib/webgl/path.js +156 -33
  18. package/src/shapes/jmEllipse.js +91 -0
  19. package/src/shapes/jmLabel.js +126 -75
  20. package/src/shapes/jmPolygon.js +129 -0
  21. package/src/shapes/jmRect.js +107 -29
  22. package/src/shapes/jmStar.js +160 -0
  23. package/example/ball.html +0 -217
  24. package/example/base.html +0 -112
  25. package/example/canvas.html +0 -54
  26. package/example/cell.html +0 -284
  27. package/example/controls/arc.html +0 -129
  28. package/example/controls/arrowline.html +0 -78
  29. package/example/controls/bezier.html +0 -299
  30. package/example/controls/img.html +0 -97
  31. package/example/controls/label.html +0 -87
  32. package/example/controls/line.html +0 -173
  33. package/example/controls/prismatic.html +0 -63
  34. package/example/controls/rect.html +0 -64
  35. package/example/controls/resize.html +0 -112
  36. package/example/controls/test.html +0 -360
  37. package/example/es.html +0 -70
  38. package/example/es5module.html +0 -63
  39. package/example/heartarc.html +0 -116
  40. package/example/index.html +0 -47
  41. package/example/js/require.js +0 -5
  42. package/example/love/img/bling/bling.tps +0 -265
  43. package/example/love/img/bling.json +0 -87
  44. package/example/love/img/bling.tps +0 -295
  45. package/example/love/img/doc/bling.gif +0 -0
  46. package/example/love/img/love.json +0 -95
  47. package/example/love/img/love.tps +0 -315
  48. package/example/love/img/qq/qq.tps +0 -399
  49. package/example/love/img/qq.json +0 -242
  50. package/example/love/index.html +0 -40
  51. package/example/love/js/game.js +0 -558
  52. package/example/music.html +0 -211
  53. package/example/node/test.js +0 -138
  54. package/example/pdf.html +0 -187
  55. package/example/progress.html +0 -173
  56. package/example/pso.html +0 -148
  57. package/example/sort.html +0 -805
  58. package/example/tweenjs.html +0 -84
  59. package/example/webgl.html +0 -278
  60. package/example/xfj/img/dr_die.gif +0 -0
  61. package/example/xfj/index.html +0 -332
  62. package/example/xfj/shake.js +0 -49
  63. 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>