jmgraph 3.2.16 → 3.2.18

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 (77) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +251 -428
  3. package/build/gulpfile.js +142 -142
  4. package/build/package-lock.json +10666 -0
  5. package/build/package.json +71 -71
  6. package/dev.js +9 -9
  7. package/dist/jmgraph.core.min.js +1 -1
  8. package/dist/jmgraph.core.min.js.map +1 -1
  9. package/dist/jmgraph.js +3500 -2668
  10. package/dist/jmgraph.min.js +1 -1
  11. package/example/ball.html +216 -216
  12. package/example/base.html +111 -111
  13. package/example/canvas.html +53 -53
  14. package/example/cell.html +283 -283
  15. package/example/controls/arc.html +128 -128
  16. package/example/controls/arrowline.html +77 -77
  17. package/example/controls/bezier.html +298 -298
  18. package/example/controls/img.html +96 -96
  19. package/example/controls/label.html +86 -86
  20. package/example/controls/line.html +172 -172
  21. package/example/controls/prismatic.html +62 -62
  22. package/example/controls/rect.html +63 -63
  23. package/example/controls/resize.html +111 -111
  24. package/example/controls/test.html +359 -359
  25. package/example/es.html +69 -69
  26. package/example/es5module.html +62 -63
  27. package/example/heartarc.html +115 -115
  28. package/example/index.html +46 -46
  29. package/example/js/require.js +4 -4
  30. package/example/love/img/bling/bling.tps +265 -265
  31. package/example/love/img/bling.json +87 -87
  32. package/example/love/img/bling.tps +295 -295
  33. package/example/love/img/love.json +95 -95
  34. package/example/love/img/love.tps +315 -315
  35. package/example/love/img/qq/qq.tps +399 -399
  36. package/example/love/img/qq.json +242 -242
  37. package/example/love/index.html +40 -40
  38. package/example/love/js/game.js +558 -558
  39. package/example/music.html +210 -210
  40. package/example/node/test.js +137 -137
  41. package/example/pdf.html +186 -186
  42. package/example/progress.html +172 -172
  43. package/example/pso.html +147 -147
  44. package/example/sort.html +804 -815
  45. package/example/tweenjs.html +83 -83
  46. package/example/webgl.html +278 -278
  47. package/example/xfj/index.html +331 -331
  48. package/example/xfj/shake.js +48 -48
  49. package/example/xfj/testori.html +75 -75
  50. package/index.js +99 -99
  51. package/package.json +58 -56
  52. package/src/core/jmControl.js +1376 -1531
  53. package/src/core/jmEvents.js +240 -281
  54. package/src/core/jmGradient.js +231 -231
  55. package/src/core/jmGraph.js +569 -569
  56. package/src/core/jmList.js +92 -157
  57. package/src/core/jmObject.js +83 -103
  58. package/src/core/jmPath.js +35 -35
  59. package/src/core/jmProperty.js +71 -110
  60. package/src/core/jmShadow.js +65 -65
  61. package/src/core/jmUtils.js +906 -919
  62. package/src/lib/earcut.js +680 -680
  63. package/src/lib/earcut.md +73 -73
  64. package/src/lib/webgl/base.js +522 -452
  65. package/src/lib/webgl/core/buffer.js +48 -48
  66. package/src/lib/webgl/core/mapSize.js +40 -40
  67. package/src/lib/webgl/core/mapType.js +43 -43
  68. package/src/lib/webgl/core/program.js +138 -138
  69. package/src/lib/webgl/core/shader.js +13 -13
  70. package/src/lib/webgl/core/texture.js +60 -60
  71. package/src/lib/webgl/gradient.js +168 -168
  72. package/src/lib/webgl/index.js +137 -11
  73. package/src/lib/webgl/path.js +568 -561
  74. package/src/shapes/jmArrowLine.js +36 -36
  75. package/src/shapes/jmImage.js +244 -244
  76. package/src/shapes/jmLabel.js +271 -271
  77. package/src/shapes/jmResize.js +332 -330
@@ -1,49 +1,49 @@
1
- function devicemotion() {
2
-
3
- this.hasDeviceMotion = 'ondeviceorientation' in window;
4
- }
5
-
6
- devicemotion.prototype.initEvent = function() {
7
- if(this.inited) return;
8
- if(this.hasDeviceMotion) {
9
- var self = this;
10
- window.addEventListener('deviceorientation',function(e) {
11
- self.devicemotionEvent(e);
12
- }, false);
13
- }
14
- this.inited = true;
15
- return this.hasDeviceMotion;
16
- }
17
-
18
- //绑定摇一摇功能
19
- //如果不支持摇一摇,则会返回false
20
- devicemotion.prototype.bindShake = function(options) {
21
- if(!options) return;
22
-
23
- if(this.hasDeviceMotion) {
24
- this.shakeOption = options;
25
- }
26
- else {
27
- options.handler && options.handler();
28
- }
29
- this.initEvent();
30
- return this.hasDeviceMotion;
31
- }
32
-
33
- devicemotion.prototype.devicemotionEvent = function(e) {
34
-
35
- //以设备坐标系z轴为轴,旋转alpha度
36
- //以设备坐标系x轴为轴,旋转beta度
37
- //已设备坐标系y轴为轴,旋转gamma度
38
- if(this.shakeOption) {
39
- var opt = {
40
- //x: e.accelerationIncludingGravity.x,
41
- // y: e.accelerationIncludingGravity.y,
42
- //z: e.accelerationIncludingGravity.z,
43
- alpha: e.alpha,
44
- beta: e.beta,
45
- gamma: e.gamma
46
- }
47
- this.shakeOption.handler.call(this, opt);
48
- }
1
+ function devicemotion() {
2
+
3
+ this.hasDeviceMotion = 'ondeviceorientation' in window;
4
+ }
5
+
6
+ devicemotion.prototype.initEvent = function() {
7
+ if(this.inited) return;
8
+ if(this.hasDeviceMotion) {
9
+ var self = this;
10
+ window.addEventListener('deviceorientation',function(e) {
11
+ self.devicemotionEvent(e);
12
+ }, false);
13
+ }
14
+ this.inited = true;
15
+ return this.hasDeviceMotion;
16
+ }
17
+
18
+ //绑定摇一摇功能
19
+ //如果不支持摇一摇,则会返回false
20
+ devicemotion.prototype.bindShake = function(options) {
21
+ if(!options) return;
22
+
23
+ if(this.hasDeviceMotion) {
24
+ this.shakeOption = options;
25
+ }
26
+ else {
27
+ options.handler && options.handler();
28
+ }
29
+ this.initEvent();
30
+ return this.hasDeviceMotion;
31
+ }
32
+
33
+ devicemotion.prototype.devicemotionEvent = function(e) {
34
+
35
+ //以设备坐标系z轴为轴,旋转alpha度
36
+ //以设备坐标系x轴为轴,旋转beta度
37
+ //已设备坐标系y轴为轴,旋转gamma度
38
+ if(this.shakeOption) {
39
+ var opt = {
40
+ //x: e.accelerationIncludingGravity.x,
41
+ // y: e.accelerationIncludingGravity.y,
42
+ //z: e.accelerationIncludingGravity.z,
43
+ alpha: e.alpha,
44
+ beta: e.beta,
45
+ gamma: e.gamma
46
+ }
47
+ this.shakeOption.handler.call(this, opt);
48
+ }
49
49
  }
@@ -1,76 +1,76 @@
1
-
2
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3
- <html>
4
- <head>
5
- <title>Device Orientation By PuterJam</title>
6
-
7
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
- </head>
9
- <body>
10
- <h1><ruby>设备方向感应测试<rt style="text-align:right;color:#ccc;font-size:10px">By PuterJam</rt></ruby></h1>
11
- <div style="background:#000;width:400px;height:200px;color:#fff;border-radius:5px;">
12
- <div id="pointer" style="height:5px;width:5px;background:#fff;position:relative;border-radius:10px;-webkit-transition:all 0.1s ease-in;-moz-transition:all 0.1s ease-in">
13
-
14
- </div>
15
- </div>
16
- <div id="test" style="font-size:12px;-webkit-text-size-adjust:none;margin:6px;"></div>
17
-
18
-
19
- <script defer>
20
- function Orientation(selector) {
21
-
22
- }
23
-
24
- Orientation.prototype.init = function(){
25
- window.addEventListener('deviceorientation', this.orientationListener, false);
26
- window.addEventListener('MozOrientation', this.orientationListener, false);
27
- window.addEventListener('devicemotion', this.orientationListener, false);
28
- }
29
-
30
- Orientation.prototype.orientationListener = function(evt) {
31
- // For FF3.6+
32
- if (!evt.gamma && !evt.beta) {
33
- // angle=radian*180.0/PI 在firefox中x和y是弧度值,
34
- evt.gamma = (evt.x * (180 / Math.PI)); //转换成角度值,
35
- evt.beta = (evt.y * (180 / Math.PI)); //转换成角度值
36
- evt.alpha = (evt.z * (180 / Math.PI)); //转换成角度值
37
- }
38
- /* beta: -180..180 (rotation around x axis) */
39
- /* gamma: -90..90 (rotation around y axis) */
40
- /* alpha: 0..360 (rotation around z axis) (-180..180) */
41
-
42
- var gamma = evt.gamma
43
- var beta = evt.beta
44
- var alpha = evt.alpha
45
-
46
- if(evt.accelerationIncludingGravity){
47
- // window.removeEventListener('deviceorientation', this.orientationListener, false);
48
- gamma = event.accelerationIncludingGravity.x*10
49
- beta = -event.accelerationIncludingGravity.y*10
50
- alpha = event.accelerationIncludingGravity.z*10
51
- }
52
-
53
- //var gamma = evt.rotationRate.gamma;
54
- //var beta = evt.rotationRate.beta;
55
- //var alpha = evt.rotationRate.beta;
56
-
57
-
58
-
59
-
60
- if (this._lastGamma != gamma || this._lastBeta != beta) {
61
- document.querySelector("#test").innerHTML = "x: "+ beta.toFixed(2) + " y: " + gamma.toFixed(2) + " z: " + (alpha != null?alpha.toFixed(2):0)
62
-
63
-
64
- var style = document.querySelector("#pointer").style;
65
- style.left = (gamma+20)/40*400 +"px";
66
- style.top = beta/90 * 100 + 100 +"px";
67
-
68
-
69
- this._lastGamma = gamma;
70
- this._lastBeta = beta;
71
- }
72
- };
73
- (new Orientation()).init();
74
- </script>
75
- </body>
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Device Orientation By PuterJam</title>
6
+
7
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
+ </head>
9
+ <body>
10
+ <h1><ruby>设备方向感应测试<rt style="text-align:right;color:#ccc;font-size:10px">By PuterJam</rt></ruby></h1>
11
+ <div style="background:#000;width:400px;height:200px;color:#fff;border-radius:5px;">
12
+ <div id="pointer" style="height:5px;width:5px;background:#fff;position:relative;border-radius:10px;-webkit-transition:all 0.1s ease-in;-moz-transition:all 0.1s ease-in">
13
+
14
+ </div>
15
+ </div>
16
+ <div id="test" style="font-size:12px;-webkit-text-size-adjust:none;margin:6px;"></div>
17
+
18
+
19
+ <script defer>
20
+ function Orientation(selector) {
21
+
22
+ }
23
+
24
+ Orientation.prototype.init = function(){
25
+ window.addEventListener('deviceorientation', this.orientationListener, false);
26
+ window.addEventListener('MozOrientation', this.orientationListener, false);
27
+ window.addEventListener('devicemotion', this.orientationListener, false);
28
+ }
29
+
30
+ Orientation.prototype.orientationListener = function(evt) {
31
+ // For FF3.6+
32
+ if (!evt.gamma && !evt.beta) {
33
+ // angle=radian*180.0/PI 在firefox中x和y是弧度值,
34
+ evt.gamma = (evt.x * (180 / Math.PI)); //转换成角度值,
35
+ evt.beta = (evt.y * (180 / Math.PI)); //转换成角度值
36
+ evt.alpha = (evt.z * (180 / Math.PI)); //转换成角度值
37
+ }
38
+ /* beta: -180..180 (rotation around x axis) */
39
+ /* gamma: -90..90 (rotation around y axis) */
40
+ /* alpha: 0..360 (rotation around z axis) (-180..180) */
41
+
42
+ var gamma = evt.gamma
43
+ var beta = evt.beta
44
+ var alpha = evt.alpha
45
+
46
+ if(evt.accelerationIncludingGravity){
47
+ // window.removeEventListener('deviceorientation', this.orientationListener, false);
48
+ gamma = event.accelerationIncludingGravity.x*10
49
+ beta = -event.accelerationIncludingGravity.y*10
50
+ alpha = event.accelerationIncludingGravity.z*10
51
+ }
52
+
53
+ //var gamma = evt.rotationRate.gamma;
54
+ //var beta = evt.rotationRate.beta;
55
+ //var alpha = evt.rotationRate.beta;
56
+
57
+
58
+
59
+
60
+ if (this._lastGamma != gamma || this._lastBeta != beta) {
61
+ document.querySelector("#test").innerHTML = "x: "+ beta.toFixed(2) + " y: " + gamma.toFixed(2) + " z: " + (alpha != null?alpha.toFixed(2):0)
62
+
63
+
64
+ var style = document.querySelector("#pointer").style;
65
+ style.left = (gamma+20)/40*400 +"px";
66
+ style.top = beta/90 * 100 + 100 +"px";
67
+
68
+
69
+ this._lastGamma = gamma;
70
+ this._lastBeta = beta;
71
+ }
72
+ };
73
+ (new Orientation()).init();
74
+ </script>
75
+ </body>
76
76
  </html>
package/index.js CHANGED
@@ -1,99 +1,99 @@
1
-
2
-
3
- import {jmArc} from "./src/shapes/jmArc.js";
4
- import {jmArrow} from "./src/shapes/jmArrow.js";
5
- import {jmBezier} from "./src/shapes/jmBezier.js";
6
- import {jmCircle} from "./src/shapes/jmCircle.js";
7
- import {jmHArc} from "./src/shapes/jmHArc.js";
8
- import {jmLine} from "./src/shapes/jmLine.js";
9
- import {jmPrismatic} from "./src/shapes/jmPrismatic.js";
10
- import {jmRect} from "./src/shapes/jmRect.js";
11
- import {jmArrowLine} from "./src/shapes/jmArrowLine.js";
12
- import {jmImage} from "./src/shapes/jmImage.js";
13
- import {jmLabel} from "./src/shapes/jmLabel.js";
14
- import {jmResize} from "./src/shapes/jmResize.js";
15
-
16
- import { jmGraph as jmGraphCore,
17
- jmUtils,
18
- jmList,
19
- jmProperty,
20
- jmShadow,
21
- jmGradient,
22
- jmEvents,
23
- jmControl,
24
- jmPath, } from "./src/core/jmGraph.js";
25
-
26
- const shapes = {
27
- "arc": jmArc,
28
- "arrow": jmArrow,
29
- "bezier": jmBezier,
30
- "circle": jmCircle,
31
- "harc": jmHArc,
32
- "line": jmLine,
33
- "prismatic": jmPrismatic,
34
- "rect": jmRect,
35
- "arrowline": jmArrowLine,
36
- "image": jmImage,
37
- "img": jmImage,
38
- "label": jmLabel,
39
- "resize": jmResize
40
- }
41
-
42
- export default class jmGraph extends jmGraphCore {
43
- constructor(canvas, option, callback) {
44
-
45
- const targetType = new.target;
46
-
47
- // 合并shapes
48
- option = Object.assign({}, option);
49
- option.shapes = Object.assign(shapes, option.shapes||{});
50
-
51
- //不是用new实例化的话,返回一个promise
52
- if(!targetType || !(targetType.prototype instanceof jmGraphCore)) {
53
- return new Promise(function(resolve, reject){
54
- var g = new jmGraph(canvas, option, callback);
55
- if(resolve) resolve(g);
56
- });
57
- }
58
-
59
- if(typeof option == 'function') {
60
- callback = option;
61
- option = {};
62
- }
63
-
64
- super(canvas, option, callback);
65
- }
66
-
67
- static create(...args) {
68
- return createJmGraph(...args);
69
- }
70
- }
71
-
72
- //创建实例
73
- const createJmGraph = (...args) => {
74
- return new jmGraph(...args);
75
- }
76
-
77
- export {
78
- jmUtils,
79
- jmList,
80
- jmControl,
81
- jmPath,
82
- jmShadow,
83
- jmGradient,
84
- jmArc,
85
- jmArrow,
86
- jmBezier,
87
- jmCircle,
88
- jmHArc,
89
- jmLine,
90
- jmPrismatic,
91
- jmRect,
92
- jmArrowLine,
93
- jmImage,
94
- jmLabel,
95
- jmResize,
96
- jmGraph,
97
- createJmGraph as create
98
- };
99
-
1
+
2
+
3
+ import {jmArc} from "./src/shapes/jmArc.js";
4
+ import {jmArrow} from "./src/shapes/jmArrow.js";
5
+ import {jmBezier} from "./src/shapes/jmBezier.js";
6
+ import {jmCircle} from "./src/shapes/jmCircle.js";
7
+ import {jmHArc} from "./src/shapes/jmHArc.js";
8
+ import {jmLine} from "./src/shapes/jmLine.js";
9
+ import {jmPrismatic} from "./src/shapes/jmPrismatic.js";
10
+ import {jmRect} from "./src/shapes/jmRect.js";
11
+ import {jmArrowLine} from "./src/shapes/jmArrowLine.js";
12
+ import {jmImage} from "./src/shapes/jmImage.js";
13
+ import {jmLabel} from "./src/shapes/jmLabel.js";
14
+ import {jmResize} from "./src/shapes/jmResize.js";
15
+
16
+ import { jmGraph as jmGraphCore,
17
+ jmUtils,
18
+ jmList,
19
+ jmProperty,
20
+ jmShadow,
21
+ jmGradient,
22
+ jmEvents,
23
+ jmControl,
24
+ jmPath, } from "./src/core/jmGraph.js";
25
+
26
+ const shapes = {
27
+ "arc": jmArc,
28
+ "arrow": jmArrow,
29
+ "bezier": jmBezier,
30
+ "circle": jmCircle,
31
+ "harc": jmHArc,
32
+ "line": jmLine,
33
+ "prismatic": jmPrismatic,
34
+ "rect": jmRect,
35
+ "arrowline": jmArrowLine,
36
+ "image": jmImage,
37
+ "img": jmImage,
38
+ "label": jmLabel,
39
+ "resize": jmResize
40
+ }
41
+
42
+ export default class jmGraph extends jmGraphCore {
43
+ constructor(canvas, option, callback) {
44
+
45
+ const targetType = new.target;
46
+
47
+ // 合并shapes
48
+ option = Object.assign({}, option);
49
+ option.shapes = Object.assign(shapes, option.shapes||{});
50
+
51
+ //不是用new实例化的话,返回一个promise
52
+ if(!targetType || !(targetType.prototype instanceof jmGraphCore)) {
53
+ return new Promise(function(resolve, reject){
54
+ var g = new jmGraph(canvas, option, callback);
55
+ if(resolve) resolve(g);
56
+ });
57
+ }
58
+
59
+ if(typeof option == 'function') {
60
+ callback = option;
61
+ option = {};
62
+ }
63
+
64
+ super(canvas, option, callback);
65
+ }
66
+
67
+ static create(...args) {
68
+ return createJmGraph(...args);
69
+ }
70
+ }
71
+
72
+ //创建实例
73
+ const createJmGraph = (...args) => {
74
+ return new jmGraph(...args);
75
+ }
76
+
77
+ export {
78
+ jmUtils,
79
+ jmList,
80
+ jmControl,
81
+ jmPath,
82
+ jmShadow,
83
+ jmGradient,
84
+ jmArc,
85
+ jmArrow,
86
+ jmBezier,
87
+ jmCircle,
88
+ jmHArc,
89
+ jmLine,
90
+ jmPrismatic,
91
+ jmRect,
92
+ jmArrowLine,
93
+ jmImage,
94
+ jmLabel,
95
+ jmResize,
96
+ jmGraph,
97
+ createJmGraph as create
98
+ };
99
+
package/package.json CHANGED
@@ -1,56 +1,58 @@
1
- {
2
- "family": "jmgraph",
3
- "name": "jmgraph",
4
- "version": "3.2.16",
5
- "description": "一个简单的canvas画图库",
6
- "homepage": "http://graph.jm47.com/",
7
- "keywords": [
8
- "canvas",
9
- "html5",
10
- "webgl"
11
- ],
12
- "author": "jiamao<haofefe@163.com>",
13
- "engines": {},
14
- "dependencies": {},
15
- "devDependencies": {
16
- "@commitlint/cli": "^7.6.1",
17
- "@commitlint/config-conventional": "^7.6.0",
18
- "canvas": "^2.11.2",
19
- "cz-conventional-changelog": "^2.1.0",
20
- "express": "^4.17.1"
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "git+https://github.com/jiamao/jmgraph.git"
25
- },
26
- "main": "./index.js",
27
- "spm": {
28
- "alias": {},
29
- "output": [
30
- "main.js"
31
- ]
32
- },
33
- "licenses": [
34
- {
35
- "type": "MIT",
36
- "url": "https://github.com/jiamao/jmgraph/blob/master/LICENSE"
37
- }
38
- ],
39
- "bugs": {
40
- "url": "https://github.com/jiamao/jmgraph/issues"
41
- },
42
- "directories": {
43
- "example": "example"
44
- },
45
- "scripts": {
46
- "build": "cd build & npm i & gulp & cd ..",
47
- "push": "npm publish --registry=https://registry.npmjs.org",
48
- "dev": "node dev"
49
- },
50
- "license": "MIT",
51
- "config": {
52
- "commitizen": {
53
- "path": "./node_modules/cz-conventional-changelog"
54
- }
55
- }
56
- }
1
+ {
2
+ "family": "jmgraph",
3
+ "name": "jmgraph",
4
+ "version": "3.2.18",
5
+ "description": "一个简单的canvas画图库",
6
+ "homepage": "https://surl.fit/tools/tools/jmgraph",
7
+ "keywords": [
8
+ "canvas",
9
+ "html5",
10
+ "webgl"
11
+ ],
12
+ "author": "jiamao<haofefe@163.com>",
13
+ "engines": {},
14
+ "devDependencies": {
15
+ "@commitlint/cli": "^7.6.1",
16
+ "@commitlint/config-conventional": "^7.6.0",
17
+ "canvas": "^2.11.2",
18
+ "cz-conventional-changelog": "^2.1.0",
19
+ "express": "^4.22.1"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/fefeding/jmgraph.git"
24
+ },
25
+ "main": "./index.js",
26
+ "spm": {
27
+ "alias": {},
28
+ "output": [
29
+ "main.js"
30
+ ]
31
+ },
32
+ "licenses": [
33
+ {
34
+ "type": "MIT",
35
+ "url": "https://github.com/fefeding/jmgraph/blob/master/LICENSE"
36
+ }
37
+ ],
38
+ "bugs": {
39
+ "url": "https://github.com/fefeding/jmgraph/issues"
40
+ },
41
+ "directories": {
42
+ "example": "example"
43
+ },
44
+ "scripts": {
45
+ "build": "cd build && npm i --legacy-peer-deps && npx gulp && cd ..",
46
+ "push": "npm publish --registry=https://registry.npmjs.org",
47
+ "dev": "node dev"
48
+ },
49
+ "license": "MIT",
50
+ "publishConfig": {
51
+ "registry": "https://registry.npmjs.org/"
52
+ },
53
+ "config": {
54
+ "commitizen": {
55
+ "path": "./node_modules/cz-conventional-changelog"
56
+ }
57
+ }
58
+ }