@antv/util 3.3.4 → 3.3.6
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.
- package/dist/color/torgb.d.ts +12 -4
- package/dist/dom/create-dom.d.ts +6 -0
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/modify-css.d.ts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/lodash/memoize.d.ts +8 -2
- package/dist/matrix/angle-to.d.ts +7 -0
- package/dist/matrix/direction.d.ts +7 -0
- package/dist/matrix/index.d.ts +6 -26
- package/dist/matrix/transform.d.ts +6 -0
- package/dist/matrix/vertical.d.ts +7 -0
- package/dist/util.min.js +1 -1
- package/esm/color/index.js +0 -1
- package/esm/color/index.js.map +1 -1
- package/esm/color/torgb.d.ts +12 -4
- package/esm/color/torgb.js +8 -1
- package/esm/color/torgb.js.map +1 -1
- package/esm/dom/create-dom.d.ts +6 -0
- package/esm/dom/create-dom.js +15 -0
- package/esm/dom/create-dom.js.map +1 -0
- package/esm/dom/index.d.ts +2 -0
- package/esm/dom/index.js +3 -0
- package/esm/dom/index.js.map +1 -0
- package/esm/dom/modify-css.d.ts +9 -0
- package/esm/dom/modify-css.js +15 -0
- package/esm/dom/modify-css.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/lodash/memoize.d.ts +8 -2
- package/esm/lodash/memoize.js +45 -2
- package/esm/lodash/memoize.js.map +1 -1
- package/esm/matrix/angle-to.d.ts +7 -0
- package/esm/matrix/angle-to.js +23 -0
- package/esm/matrix/angle-to.js.map +1 -0
- package/esm/matrix/direction.d.ts +7 -0
- package/esm/matrix/direction.js +10 -0
- package/esm/matrix/direction.js.map +1 -0
- package/esm/matrix/index.d.ts +6 -26
- package/esm/matrix/index.js +5 -94
- package/esm/matrix/index.js.map +1 -1
- package/esm/matrix/transform.d.ts +6 -0
- package/esm/matrix/transform.js +48 -0
- package/esm/matrix/transform.js.map +1 -0
- package/esm/matrix/vertical.d.ts +7 -0
- package/esm/matrix/vertical.js +18 -0
- package/esm/matrix/vertical.js.map +1 -0
- package/esm/path/util/path-length-factory.js.map +1 -1
- package/esm/path/util/segment-arc-factory.js.map +1 -1
- package/esm/path/util/segment-cubic-factory.js.map +1 -1
- package/esm/path/util/segment-quad-factory.js.map +1 -1
- package/lib/color/index.js +0 -1
- package/lib/color/index.js.map +1 -1
- package/lib/color/torgb.d.ts +12 -4
- package/lib/color/torgb.js +8 -2
- package/lib/color/torgb.js.map +1 -1
- package/lib/dom/create-dom.d.ts +6 -0
- package/lib/dom/create-dom.js +19 -0
- package/lib/dom/create-dom.js.map +1 -0
- package/lib/dom/index.d.ts +2 -0
- package/lib/dom/index.js +8 -0
- package/lib/dom/index.js.map +1 -0
- package/lib/dom/modify-css.d.ts +9 -0
- package/lib/dom/modify-css.js +19 -0
- package/lib/dom/modify-css.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/lodash/memoize.d.ts +8 -2
- package/lib/lodash/memoize.js +45 -2
- package/lib/lodash/memoize.js.map +1 -1
- package/lib/matrix/angle-to.d.ts +7 -0
- package/lib/matrix/angle-to.js +27 -0
- package/lib/matrix/angle-to.js.map +1 -0
- package/lib/matrix/direction.d.ts +7 -0
- package/lib/matrix/direction.js +14 -0
- package/lib/matrix/direction.js.map +1 -0
- package/lib/matrix/index.d.ts +6 -26
- package/lib/matrix/index.js +10 -99
- package/lib/matrix/index.js.map +1 -1
- package/lib/matrix/transform.d.ts +6 -0
- package/lib/matrix/transform.js +52 -0
- package/lib/matrix/transform.js.map +1 -0
- package/lib/matrix/vertical.d.ts +7 -0
- package/lib/matrix/vertical.js +22 -0
- package/lib/matrix/vertical.js.map +1 -0
- package/lib/path/util/path-length-factory.js.map +1 -1
- package/lib/path/util/segment-arc-factory.js.map +1 -1
- package/lib/path/util/segment-cubic-factory.js.map +1 -1
- package/lib/path/util/segment-quad-factory.js.map +1 -1
- package/package.json +1 -1
- package/src/color/index.ts +0 -1
- package/src/color/torgb.ts +9 -1
- package/src/dom/create-dom.ts +15 -0
- package/src/dom/index.ts +2 -0
- package/src/dom/modify-css.ts +14 -0
- package/src/index.ts +1 -0
- package/src/lodash/memoize.ts +47 -2
- package/src/matrix/angle-to.ts +24 -0
- package/src/matrix/direction.ts +9 -0
- package/src/matrix/index.ts +5 -106
- package/src/matrix/transform.ts +55 -0
- package/src/matrix/vertical.ts +17 -0
- package/src/path/util/path-length-factory.ts +2 -2
- package/src/path/util/segment-arc-factory.ts +1 -1
- package/src/path/util/segment-cubic-factory.ts +1 -1
- package/src/path/util/segment-quad-factory.ts +1 -1
- package/dist/helper/index.d.ts +0 -2
- package/dist/helper/mod.d.ts +0 -1
- package/dist/helper/to-radian.d.ts +0 -1
- package/esm/helper/index.d.ts +0 -2
- package/esm/helper/index.js +0 -3
- package/esm/helper/index.js.map +0 -1
- package/esm/helper/mod.d.ts +0 -1
- package/esm/helper/mod.js +0 -4
- package/esm/helper/mod.js.map +0 -1
- package/esm/helper/to-radian.d.ts +0 -1
- package/esm/helper/to-radian.js +0 -5
- package/esm/helper/to-radian.js.map +0 -1
- package/lib/helper/index.d.ts +0 -2
- package/lib/helper/index.js +0 -8
- package/lib/helper/index.js.map +0 -1
- package/lib/helper/mod.d.ts +0 -1
- package/lib/helper/mod.js +0 -8
- package/lib/helper/mod.js.map +0 -1
- package/lib/helper/to-radian.d.ts +0 -1
- package/lib/helper/to-radian.js +0 -9
- package/lib/helper/to-radian.js.map +0 -1
- package/src/helper/index.ts +0 -2
- package/src/helper/mod.ts +0 -3
- package/src/helper/to-radian.ts +0 -5
package/src/matrix/index.ts
CHANGED
|
@@ -1,108 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description 扩展方法,提供 gl-matrix 为提供的方法
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function leftTranslate(out, a, v) {
|
|
9
|
-
const transMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
10
|
-
mat3.fromTranslation(transMat, v);
|
|
11
|
-
return mat3.multiply(out, transMat, a);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function leftRotate(out, a, rad) {
|
|
15
|
-
const rotateMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
16
|
-
mat3.fromRotation(rotateMat, rad);
|
|
17
|
-
return mat3.multiply(out, rotateMat, a);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function leftScale(out, a, v) {
|
|
21
|
-
const scaleMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
22
|
-
mat3.fromScaling(scaleMat, v);
|
|
23
|
-
return mat3.multiply(out, scaleMat, a);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function leftMultiply(out, a, a1) {
|
|
27
|
-
return mat3.multiply(out, a1, a);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 根据 actions 来做 transform
|
|
31
|
-
* @param m
|
|
32
|
-
* @param actions
|
|
33
|
-
*/
|
|
34
|
-
export function transform(m: number[], actions: any[][]) {
|
|
35
|
-
const matrix = m ? [].concat(m) : [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
36
|
-
|
|
37
|
-
for (let i = 0, len = actions.length; i < len; i++) {
|
|
38
|
-
const action = actions[i];
|
|
39
|
-
switch (action[0]) {
|
|
40
|
-
case 't':
|
|
41
|
-
leftTranslate(matrix, matrix, [action[1], action[2]]);
|
|
42
|
-
break;
|
|
43
|
-
case 's':
|
|
44
|
-
leftScale(matrix, matrix, [action[1], action[2]]);
|
|
45
|
-
break;
|
|
46
|
-
case 'r':
|
|
47
|
-
leftRotate(matrix, matrix, action[1]);
|
|
48
|
-
break;
|
|
49
|
-
case 'm':
|
|
50
|
-
leftMultiply(matrix, matrix, action[1]);
|
|
51
|
-
break;
|
|
52
|
-
default:
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return matrix;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 向量 v1 到 向量 v2 夹角的方向
|
|
62
|
-
* @param {Array} v1 向量
|
|
63
|
-
* @param {Array} v2 向量
|
|
64
|
-
* @return {Boolean} >= 0 顺时针 < 0 逆时针
|
|
65
|
-
*/
|
|
66
|
-
export function direction(v1: number[], v2: number[]): number {
|
|
67
|
-
return v1[0] * v2[1] - v2[0] * v1[1];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 二维向量 v1 到 v2 的夹角
|
|
72
|
-
* @param v1
|
|
73
|
-
* @param v2
|
|
74
|
-
* @param direct
|
|
75
|
-
*/
|
|
76
|
-
export function angleTo(v1: [number, number], v2: [number, number], direct?: boolean): number {
|
|
77
|
-
const ang = vec2.angle(v1, v2);
|
|
78
|
-
const angleLargeThanPI = direction(v1, v2) >= 0;
|
|
79
|
-
if (direct) {
|
|
80
|
-
if (angleLargeThanPI) {
|
|
81
|
-
return Math.PI * 2 - ang;
|
|
82
|
-
}
|
|
83
|
-
return ang;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (angleLargeThanPI) {
|
|
87
|
-
return ang;
|
|
88
|
-
}
|
|
89
|
-
return Math.PI * 2 - ang;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 计算二维向量的垂直向量
|
|
94
|
-
* @param out
|
|
95
|
-
* @param v
|
|
96
|
-
* @param flag
|
|
97
|
-
*/
|
|
98
|
-
export function vertical(out: number[], v: number[], flag: boolean): number[] {
|
|
99
|
-
if (flag) {
|
|
100
|
-
out[0] = v[1];
|
|
101
|
-
out[1] = -1 * v[0];
|
|
102
|
-
} else {
|
|
103
|
-
out[0] = -1 * v[1];
|
|
104
|
-
out[1] = v[0];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
3
|
+
**/
|
|
4
|
+
export { transform } from './transform';
|
|
5
|
+
export { angleTo } from './angle-to';
|
|
6
|
+
export { direction } from './direction';
|
|
7
|
+
export { vertical } from './vertical';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mat3 } from 'gl-matrix';
|
|
2
|
+
|
|
3
|
+
type mat3Type = [number, number, number, number, number, number, number, number, number];
|
|
4
|
+
|
|
5
|
+
function leftTranslate(out, a, v) {
|
|
6
|
+
const transMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
7
|
+
mat3.fromTranslation(transMat, v);
|
|
8
|
+
return mat3.multiply(out, transMat, a);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function leftRotate(out, a, rad) {
|
|
12
|
+
const rotateMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
13
|
+
mat3.fromRotation(rotateMat, rad);
|
|
14
|
+
return mat3.multiply(out, rotateMat, a);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function leftScale(out, a, v) {
|
|
18
|
+
const scaleMat: mat3Type = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
19
|
+
mat3.fromScaling(scaleMat, v);
|
|
20
|
+
return mat3.multiply(out, scaleMat, a);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function leftMultiply(out, a, a1) {
|
|
24
|
+
return mat3.multiply(out, a1, a);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 根据 actions 来做 transform
|
|
28
|
+
* @param m
|
|
29
|
+
* @param actions
|
|
30
|
+
*/
|
|
31
|
+
export function transform(m: number[], actions: any[][]) {
|
|
32
|
+
const matrix = m ? [].concat(m) : [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
33
|
+
|
|
34
|
+
for (let i = 0, len = actions.length; i < len; i++) {
|
|
35
|
+
const action = actions[i];
|
|
36
|
+
switch (action[0]) {
|
|
37
|
+
case 't':
|
|
38
|
+
leftTranslate(matrix, matrix, [action[1], action[2]]);
|
|
39
|
+
break;
|
|
40
|
+
case 's':
|
|
41
|
+
leftScale(matrix, matrix, [action[1], action[2]]);
|
|
42
|
+
break;
|
|
43
|
+
case 'r':
|
|
44
|
+
leftRotate(matrix, matrix, action[1]);
|
|
45
|
+
break;
|
|
46
|
+
case 'm':
|
|
47
|
+
leftMultiply(matrix, matrix, action[1]);
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return matrix;
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 计算二维向量的垂直向量
|
|
3
|
+
* @param out
|
|
4
|
+
* @param v
|
|
5
|
+
* @param flag
|
|
6
|
+
*/
|
|
7
|
+
export function vertical(out: number[], v: number[], flag: boolean): number[] {
|
|
8
|
+
if (flag) {
|
|
9
|
+
out[0] = v[1];
|
|
10
|
+
out[1] = -1 * v[0];
|
|
11
|
+
} else {
|
|
12
|
+
out[0] = -1 * v[1];
|
|
13
|
+
out[1] = v[0];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
@@ -145,7 +145,7 @@ export function segmentArcFactory(
|
|
|
145
145
|
let cur: [number, number] = [x, y];
|
|
146
146
|
let t = 0;
|
|
147
147
|
let POINT = { x: 0, y: 0 };
|
|
148
|
-
|
|
148
|
+
const POINTS = [{ x, y }];
|
|
149
149
|
|
|
150
150
|
if (distanceIsNumber && distance <= 0) {
|
|
151
151
|
POINT = { x, y };
|
package/dist/helper/index.d.ts
DELETED
package/dist/helper/mod.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function mod(n: number, m: number): number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function toRadian(degree: number): number;
|
package/esm/helper/index.d.ts
DELETED
package/esm/helper/index.js
DELETED
package/esm/helper/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/esm/helper/mod.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function mod(n: number, m: number): number;
|
package/esm/helper/mod.js
DELETED
package/esm/helper/mod.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"src/","sources":["helper/mod.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function toRadian(degree: number): number;
|
package/esm/helper/to-radian.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to-radian.js","sourceRoot":"src/","sources":["helper/to-radian.ts"],"names":[],"mappings":"AAAA,IAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAE7B,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC"}
|
package/lib/helper/index.d.ts
DELETED
package/lib/helper/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toRadian = exports.mod = void 0;
|
|
4
|
-
var mod_1 = require("./mod");
|
|
5
|
-
Object.defineProperty(exports, "mod", { enumerable: true, get: function () { return mod_1.mod; } });
|
|
6
|
-
var to_radian_1 = require("./to-radian");
|
|
7
|
-
Object.defineProperty(exports, "toRadian", { enumerable: true, get: function () { return to_radian_1.toRadian; } });
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/lib/helper/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["helper/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA"}
|
package/lib/helper/mod.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function mod(n: number, m: number): number;
|
package/lib/helper/mod.js
DELETED
package/lib/helper/mod.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"src/","sources":["helper/mod.ts"],"names":[],"mappings":";;;AAAA,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAFD,kBAEC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function toRadian(degree: number): number;
|
package/lib/helper/to-radian.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toRadian = void 0;
|
|
4
|
-
var RADIAN = Math.PI / 180;
|
|
5
|
-
function toRadian(degree) {
|
|
6
|
-
return RADIAN * degree;
|
|
7
|
-
}
|
|
8
|
-
exports.toRadian = toRadian;
|
|
9
|
-
//# sourceMappingURL=to-radian.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to-radian.js","sourceRoot":"src/","sources":["helper/to-radian.ts"],"names":[],"mappings":";;;AAAA,IAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAE7B,SAAgB,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC;AAFD,4BAEC"}
|
package/src/helper/index.ts
DELETED
package/src/helper/mod.ts
DELETED