light-h5-core-lib 2.5.4 → 2.6.5

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/LightCore.js CHANGED
@@ -1,30 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.coreUniqueIDUtil = exports.coreStringUtil = exports.coreRandomNumUtil = exports.coreFloatDigitUtil = exports.coreDateUtil = exports.coreBitUtil = exports.coreBaseSingleton = exports.corePoolObj = void 0;
3
+ exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.BaseSingleton = exports.PoolObj = void 0;
4
4
  var PoolObj_1 = require("./pool/PoolObj");
5
- Object.defineProperty(exports, "corePoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
5
+ Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
6
6
  var BaseSingleton_1 = require("./common/base/BaseSingleton");
7
- Object.defineProperty(exports, "coreBaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
7
+ Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
8
8
  var BitUtil_1 = require("./common/util/BitUtil");
9
- Object.defineProperty(exports, "coreBitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
9
+ Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
10
10
  var DateUtil_1 = require("./common/util/DateUtil");
11
- Object.defineProperty(exports, "coreDateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
11
+ Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
12
12
  var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
13
- Object.defineProperty(exports, "coreFloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
13
+ Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
14
14
  var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
15
- Object.defineProperty(exports, "coreRandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
15
+ Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
16
16
  var StringUtil_1 = require("./common/util/StringUtil");
17
- Object.defineProperty(exports, "coreStringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
17
+ Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
18
18
  var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
19
- Object.defineProperty(exports, "coreUniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
20
- module.exports.PoolObj = PoolObj_1.PoolObj;
21
- module.exports.BaseSingleton = BaseSingleton_1.BaseSingleton;
22
- module.exports.BitUtil = BitUtil_1.BitUtil;
23
- module.exports.DateUtil = DateUtil_1.DateUtil;
24
- module.exports.FloatDigitUtil = FloatDigitUtil_1.FloatDigitUtil;
25
- module.exports.RandomNumUtil = RandomNumUtil_1.RandomNumUtil;
26
- module.exports.StringUtil = StringUtil_1.StringUtil;
27
- module.exports.UniqueIDUtil = UniqueIDUtil_1.UniqueIDUtil;
19
+ Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
20
+ var BeizerUtil_1 = require("./common/util/BeizerUtil");
21
+ Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
28
22
  module.exports = {
29
23
  PoolObj: PoolObj_1.PoolObj,
30
24
  BaseSingleton: BaseSingleton_1.BaseSingleton,
@@ -34,4 +28,5 @@ module.exports = {
34
28
  RandomNumUtil: RandomNumUtil_1.RandomNumUtil,
35
29
  StringUtil: StringUtil_1.StringUtil,
36
30
  UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
31
+ BeizerUtil: BeizerUtil_1.BeizerUtil,
37
32
  };
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeizerUtil = void 0;
4
+ /**
5
+ * 贝塞尔曲线运动
6
+ * @author Aonaufly
7
+ */
8
+ var BeizerUtil = /** @class */ (function () {
9
+ function BeizerUtil() {
10
+ }
11
+ //#region 获得当前坐标
12
+ /**
13
+ * 获得当前坐标
14
+ * @param timer 时间[0,1]
15
+ * @returns
16
+ */
17
+ BeizerUtil.getPosition = function (points, timer) {
18
+ var x = 0, y = 0;
19
+ var bezier;
20
+ for (var i = 0, n = points.length; i < n; i++) {
21
+ bezier =
22
+ Math.min(Math.pow(1 - timer, n - i - 1) * Math.pow(timer, i)) *
23
+ BeizerUtil.calculationC(i, n);
24
+ x += points[i].x * bezier;
25
+ y += points[i].y * bezier;
26
+ }
27
+ return { x: x, y: y };
28
+ };
29
+ //#endregion
30
+ //region 获得路线的长度
31
+ BeizerUtil.distance = function (p1, p2) {
32
+ var dx = p2.x - p1.x;
33
+ var dy = p2.y - p1.y;
34
+ return Math.sqrt(dx * dx + dy * dy);
35
+ };
36
+ /**
37
+ * 获得整个路线的长度
38
+ * @param precision 精确度(微积分方案)
39
+ */
40
+ BeizerUtil.getLength = function (points, precision) {
41
+ if (precision === void 0) { precision = 100; }
42
+ var length = 0;
43
+ var point1;
44
+ var point2;
45
+ for (var t = 0; t < 1; t += 1 / precision) {
46
+ point1 = BeizerUtil.getBezierPoint(points, t);
47
+ point2 = BeizerUtil.getBezierPoint(points, t + 1 / precision);
48
+ length += BeizerUtil.distance(point1, point2);
49
+ }
50
+ return length;
51
+ };
52
+ BeizerUtil.calculationC = function (i, n) {
53
+ return (BeizerUtil.factorial(n - 1) /
54
+ (BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
55
+ };
56
+ BeizerUtil.factorial = function (num) {
57
+ if (num < 0) {
58
+ return 1;
59
+ }
60
+ else if (num === 0 || num === 1) {
61
+ return 1;
62
+ }
63
+ else {
64
+ return num * BeizerUtil.factorial(num - 1);
65
+ }
66
+ };
67
+ BeizerUtil.getBezierPoint = function (points, t) {
68
+ if (points.length === 1) {
69
+ return points[0];
70
+ }
71
+ var nextPoints = [];
72
+ var x;
73
+ var y;
74
+ for (var i = 0; i < points.length - 1; i++) {
75
+ x = (1 - t) * points[i].x + t * points[i + 1].x;
76
+ y = (1 - t) * points[i].y + t * points[i + 1].y;
77
+ nextPoints.push({ x: x, y: y });
78
+ }
79
+ return BeizerUtil.getBezierPoint(nextPoints, t);
80
+ };
81
+ return BeizerUtil;
82
+ }());
83
+ exports.BeizerUtil = BeizerUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "light-h5-core-lib",
3
- "version": "2.5.4",
3
+ "version": "2.6.5",
4
4
  "description": "light core lib",
5
5
  "main": "./LightCore.js",
6
6
  "types": "./type/index.d.ts",
package/type/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface IClear extends IDestroy {
10
10
  * 对象池(泛型)
11
11
  * @author aonaufly
12
12
  */
13
- declare class PoolObj<T> implements IClear {
13
+ export declare class PoolObj<T> implements IClear {
14
14
  private _pool;
15
15
  private _cup;
16
16
  /**
@@ -33,7 +33,7 @@ declare class PoolObj<T> implements IClear {
33
33
  clear(): void;
34
34
  destroy(isCleared?: boolean): void;
35
35
  }
36
- declare class BaseSingleton<T> {
36
+ export declare class BaseSingleton<T> {
37
37
  private static _instance;
38
38
  static getInstance<T>(c: {
39
39
  new (): T;
@@ -43,7 +43,7 @@ declare class BaseSingleton<T> {
43
43
  * 位操作工具(从右向左←)
44
44
  * @author aonaufly
45
45
  */
46
- declare class BitUtil {
46
+ export declare class BitUtil {
47
47
  /**
48
48
  * 读取uint类型某位的值, bit从1开始
49
49
  */
@@ -60,7 +60,7 @@ declare class BitUtil {
60
60
  * 日期(时间)工具
61
61
  * @author aonaufly
62
62
  */
63
- declare class DateUtil {
63
+ export declare class DateUtil {
64
64
  /**
65
65
  * 获取指定时间的时间戳 (单位:ms)
66
66
  * @param date 如: "2020-3-14 11:30:30"
@@ -106,7 +106,7 @@ declare class DateUtil {
106
106
  * Float精度
107
107
  * @author aonaufly
108
108
  */
109
- declare class FloatDigitUtil {
109
+ export declare class FloatDigitUtil {
110
110
  /**
111
111
  * 确定小数的精度<b style="color:red">2个小数相加会有精度错误</b>
112
112
  * @param fNum 小数
@@ -118,7 +118,7 @@ declare class FloatDigitUtil {
118
118
  * 随机数生成工具
119
119
  * @author aonaufly
120
120
  */
121
- declare class RandomNumUtil {
121
+ export declare class RandomNumUtil {
122
122
  /**
123
123
  * 获取一定方位的随机整数
124
124
  *
@@ -134,7 +134,7 @@ declare class RandomNumUtil {
134
134
  * 字符串工具
135
135
  * @author aonaufly
136
136
  */
137
- declare class StringUtil {
137
+ export declare class StringUtil {
138
138
  /**
139
139
  * 字符串的格式化 , 使用 {index = 0}的模式
140
140
  * @param str 源字符串
@@ -153,22 +153,41 @@ declare class StringUtil {
153
153
  * 唯一ID生成器
154
154
  * @author Aonaufly
155
155
  */
156
- declare class UniqueIDUtil {
156
+ export declare class UniqueIDUtil {
157
157
  /**生成唯一ID值*/
158
158
  static getUniqueId(): string;
159
159
  /**生成复合的Key值*/
160
160
  static getCompositeKey(key: string | number, uniqueId: string): string;
161
161
  }
162
-
163
- export {
164
- BaseSingleton as coreBaseSingleton,
165
- BitUtil as coreBitUtil,
166
- DateUtil as coreDateUtil,
167
- FloatDigitUtil as coreFloatDigitUtil,
168
- PoolObj as corePoolObj,
169
- RandomNumUtil as coreRandomNumUtil,
170
- StringUtil as coreStringUtil,
171
- UniqueIDUtil as coreUniqueIDUtil,
172
- };
162
+ /**
163
+ * 贝塞尔曲线运动
164
+ * @author Aonaufly
165
+ */
166
+ export declare class BeizerUtil {
167
+ /**
168
+ * 获得当前坐标
169
+ * @param timer 时间[0,1]
170
+ * @returns
171
+ */
172
+ static getPosition(points: {
173
+ x: number;
174
+ y: number;
175
+ }[], timer: number): {
176
+ x: number;
177
+ y: number;
178
+ };
179
+ private static calculationC;
180
+ private static factorial;
181
+ private static distance;
182
+ /**
183
+ * 获得整个路线的长度
184
+ * @param precision 精确度(微积分方案)
185
+ */
186
+ static getLength(points: {
187
+ x: number;
188
+ y: number;
189
+ }[], precision?: number): number;
190
+ private static getBezierPoint;
191
+ }
173
192
 
174
193
  export {};