@thi.ng/math 5.8.4 → 5.9.1
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/CHANGELOG.md +8 -1
- package/README.md +11 -1
- package/easing.d.ts +36 -0
- package/easing.js +75 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-02-10T08:59:56Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [5.9.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.9.0) (2024-02-06)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add easing functions ([e4966fd](https://github.com/thi-ng/umbrella/commit/e4966fd))
|
|
17
|
+
- add easing functions, ported from [@thi.ng/shader-ast-std](https://github.com/thi-ng/umbrella/tree/main/packages/shader-ast-std) pkg
|
|
18
|
+
|
|
12
19
|
## [5.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.8.0) (2024-01-26)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> ‼️ Announcing the thi.ng user survey 2024 📋
|
|
5
|
+
>
|
|
6
|
+
> [Please participate in the survey here!](https://forms.gle/XacbSDEmQMPZg8197)\
|
|
7
|
+
> (open until end of February)
|
|
8
|
+
>
|
|
9
|
+
> **To achieve a better sample size, I'd highly appreciate if you could
|
|
10
|
+
> circulate the link to this survey in your own networks.**
|
|
11
|
+
>
|
|
12
|
+
> [Discussion](https://github.com/thi-ng/umbrella/discussions/447)
|
|
3
13
|
|
|
4
14
|
# 
|
|
5
15
|
|
|
@@ -72,7 +82,7 @@ For Node.js REPL:
|
|
|
72
82
|
const math = await import("@thi.ng/math");
|
|
73
83
|
```
|
|
74
84
|
|
|
75
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 4.
|
|
85
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 4.63 KB
|
|
76
86
|
|
|
77
87
|
## Dependencies
|
|
78
88
|
|
package/easing.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FnN } from "@thi.ng/api";
|
|
2
|
+
export declare const defEaseInExp: (k: number) => FnN;
|
|
3
|
+
export declare const defEaseOutExp: (k: number) => FnN;
|
|
4
|
+
export declare const defEaseInOutExp: (k: number) => FnN;
|
|
5
|
+
export declare const easeLinear: FnN;
|
|
6
|
+
export declare const easeIn2: FnN;
|
|
7
|
+
export declare const easeOut2: FnN;
|
|
8
|
+
export declare const easeInOut2: FnN;
|
|
9
|
+
export declare const easeIn3: FnN;
|
|
10
|
+
export declare const easeOut3: FnN;
|
|
11
|
+
export declare const easeInOut3: FnN;
|
|
12
|
+
export declare const easeIn4: FnN;
|
|
13
|
+
export declare const easeOut4: FnN;
|
|
14
|
+
export declare const easeInOut4: FnN;
|
|
15
|
+
export declare const easeIn5: FnN;
|
|
16
|
+
export declare const easeOut5: FnN;
|
|
17
|
+
export declare const easeInOut5: FnN;
|
|
18
|
+
export declare const easeInBack: FnN;
|
|
19
|
+
export declare const easeOutBack: FnN;
|
|
20
|
+
export declare const easeInOutBack: FnN;
|
|
21
|
+
export declare const easeInBounce: FnN;
|
|
22
|
+
export declare const easeOutBounce: FnN;
|
|
23
|
+
export declare const easeInOutBounce: FnN;
|
|
24
|
+
export declare const easeInCirc: FnN;
|
|
25
|
+
export declare const easeOutCirc: FnN;
|
|
26
|
+
export declare const easeInOutCirc: FnN;
|
|
27
|
+
export declare const easeInElastic: FnN;
|
|
28
|
+
export declare const easeOutElastic: FnN;
|
|
29
|
+
export declare const easeInOutElastic: FnN;
|
|
30
|
+
export declare const easeInExp2: FnN;
|
|
31
|
+
export declare const easeOutExp2: FnN;
|
|
32
|
+
export declare const easeInOutExp2: FnN;
|
|
33
|
+
export declare const easeInSine: FnN;
|
|
34
|
+
export declare const easeOutSine: FnN;
|
|
35
|
+
export declare const easeInOutSine: FnN;
|
|
36
|
+
//# sourceMappingURL=easing.d.ts.map
|
package/easing.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { HALF_PI, PI, TAU } from "./api.js";
|
|
2
|
+
const { cos, sin, sqrt } = Math;
|
|
3
|
+
const defEaseInExp = (k) => (t) => t ** k;
|
|
4
|
+
const defEaseOutExp = (k) => (t) => 1 - (1 - t) ** k;
|
|
5
|
+
const defEaseInOutExp = (k) => {
|
|
6
|
+
const k2 = 2 ** (k - 1);
|
|
7
|
+
return (t) => t < 0.5 ? k2 * t ** k : 1 - (-2 * t + 2) ** k / 2;
|
|
8
|
+
};
|
|
9
|
+
const easeLinear = (t) => t;
|
|
10
|
+
const easeIn2 = defEaseInExp(2);
|
|
11
|
+
const easeOut2 = defEaseOutExp(2);
|
|
12
|
+
const easeInOut2 = defEaseInOutExp(2);
|
|
13
|
+
const easeIn3 = defEaseInExp(3);
|
|
14
|
+
const easeOut3 = defEaseOutExp(3);
|
|
15
|
+
const easeInOut3 = defEaseInOutExp(3);
|
|
16
|
+
const easeIn4 = defEaseInExp(4);
|
|
17
|
+
const easeOut4 = defEaseOutExp(4);
|
|
18
|
+
const easeInOut4 = defEaseInOutExp(4);
|
|
19
|
+
const easeIn5 = defEaseInExp(5);
|
|
20
|
+
const easeOut5 = defEaseOutExp(5);
|
|
21
|
+
const easeInOut5 = defEaseInOutExp(5);
|
|
22
|
+
const easeInBack = (t) => 2.70158 * t ** 3 - 1.70158 * t ** 2;
|
|
23
|
+
const easeOutBack = (t) => 2.70158 * (t - 1) ** 3 + 1 + 1.70158 * (t - 1) ** 2;
|
|
24
|
+
const easeInOutBack = (t) => t < 0.5 ? (2 * t) ** 2 * ((2.5949095 + 1) * 2 * t - 2.5949095) / 2 : ((2 * t - 2) ** 2 * ((2.5949095 + 1) * (t * 2 - 2) + 2.5949095) + 2) / 2;
|
|
25
|
+
const easeInBounce = (t) => 1 - easeOutBounce(1 - t);
|
|
26
|
+
const easeOutBounce = (t) => t < 1 / 2.75 ? 7.5625 * (t * t) : t < 2 / 2.75 ? 7.5625 * (t - 1.5 / 2.75) * (t - 1.5 / 2.75) + 0.75 : t < 2.5 / 2.75 ? 7.5625 * (t - 2.25 / 2.75) * (t - 2.25 / 2.75) + 0.9375 : 7.5625 * (t - 2.625 / 2.75) * (t - 2.625 / 2.75) + 0.984375;
|
|
27
|
+
const easeInOutBounce = (t) => t < 0.5 ? (1 - easeOutBounce(1 - 2 * t)) / 2 : (1 + easeOutBounce(2 * t - 1)) / 2;
|
|
28
|
+
const easeInCirc = (t) => 1 - sqrt(1 - t ** 2);
|
|
29
|
+
const easeOutCirc = (t) => sqrt(1 - (t - 1) ** 2);
|
|
30
|
+
const easeInOutCirc = (t) => t < 0.5 ? (1 - sqrt(1 - (2 * t) ** 2)) / 2 : (sqrt(1 - (-2 * t + 2) ** 2) + 1) / 2;
|
|
31
|
+
const easeInElastic = (t) => t <= 0 ? 0 : t >= 1 ? 1 : -(2 ** (10 * t - 10)) * sin((t * 10 - 10.75) * (TAU / 3));
|
|
32
|
+
const easeOutElastic = (t) => t <= 0 ? 0 : t >= 1 ? 1 : 2 ** (-10 * t) * sin((t * 10 - 0.75) * (TAU / 3)) + 1;
|
|
33
|
+
const easeInOutElastic = (t) => t <= 0 ? 0 : t >= 1 ? 1 : t < 0.5 ? -(2 ** (20 * t - 10) * sin((20 * t - 11.125) * (TAU / 4.5))) / 2 : 2 ** (-20 * t + 10) * sin((20 * t - 11.125) * (TAU / 4.5)) / 2 + 1;
|
|
34
|
+
const easeInExp2 = (t) => t <= 0 ? 0 : 2 ** (10 * t - 10);
|
|
35
|
+
const easeOutExp2 = (t) => t >= 1 ? 1 : 1 - 2 ** (-10 * t);
|
|
36
|
+
const easeInOutExp2 = (t) => t < 0 ? 0 : t >= 1 ? 1 : t < 0.5 ? 2 ** (20 * t - 10) / 2 : (2 - 2 ** (-20 * t + 10)) / 2;
|
|
37
|
+
const easeInSine = (t) => 1 - cos(t * HALF_PI);
|
|
38
|
+
const easeOutSine = (t) => sin(t * HALF_PI);
|
|
39
|
+
const easeInOutSine = (t) => -(cos(PI * t) - 1) / 2;
|
|
40
|
+
export {
|
|
41
|
+
defEaseInExp,
|
|
42
|
+
defEaseInOutExp,
|
|
43
|
+
defEaseOutExp,
|
|
44
|
+
easeIn2,
|
|
45
|
+
easeIn3,
|
|
46
|
+
easeIn4,
|
|
47
|
+
easeIn5,
|
|
48
|
+
easeInBack,
|
|
49
|
+
easeInBounce,
|
|
50
|
+
easeInCirc,
|
|
51
|
+
easeInElastic,
|
|
52
|
+
easeInExp2,
|
|
53
|
+
easeInOut2,
|
|
54
|
+
easeInOut3,
|
|
55
|
+
easeInOut4,
|
|
56
|
+
easeInOut5,
|
|
57
|
+
easeInOutBack,
|
|
58
|
+
easeInOutBounce,
|
|
59
|
+
easeInOutCirc,
|
|
60
|
+
easeInOutElastic,
|
|
61
|
+
easeInOutExp2,
|
|
62
|
+
easeInOutSine,
|
|
63
|
+
easeInSine,
|
|
64
|
+
easeLinear,
|
|
65
|
+
easeOut2,
|
|
66
|
+
easeOut3,
|
|
67
|
+
easeOut4,
|
|
68
|
+
easeOut5,
|
|
69
|
+
easeOutBack,
|
|
70
|
+
easeOutBounce,
|
|
71
|
+
easeOutCirc,
|
|
72
|
+
easeOutElastic,
|
|
73
|
+
easeOutExp2,
|
|
74
|
+
easeOutSine
|
|
75
|
+
};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/math",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.1",
|
|
4
4
|
"description": "Assorted common math functions & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -38,19 +38,20 @@
|
|
|
38
38
|
"test": "bun test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@thi.ng/api": "^8.9.
|
|
41
|
+
"@thi.ng/api": "^8.9.23"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-extractor": "^7.
|
|
45
|
-
"esbuild": "^0.
|
|
44
|
+
"@microsoft/api-extractor": "^7.40.1",
|
|
45
|
+
"esbuild": "^0.20.0",
|
|
46
46
|
"rimraf": "^5.0.5",
|
|
47
|
-
"typedoc": "^0.25.
|
|
47
|
+
"typedoc": "^0.25.7",
|
|
48
48
|
"typescript": "^5.3.3"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"animation",
|
|
52
52
|
"bezier",
|
|
53
53
|
"cubic",
|
|
54
|
+
"easing",
|
|
54
55
|
"hermite",
|
|
55
56
|
"interpolation",
|
|
56
57
|
"interval",
|
|
@@ -89,6 +90,9 @@
|
|
|
89
90
|
"./crossing": {
|
|
90
91
|
"default": "./crossing.js"
|
|
91
92
|
},
|
|
93
|
+
"./easing": {
|
|
94
|
+
"default": "./easing.js"
|
|
95
|
+
},
|
|
92
96
|
"./eqdelta": {
|
|
93
97
|
"default": "./eqdelta.js"
|
|
94
98
|
},
|
|
@@ -138,5 +142,5 @@
|
|
|
138
142
|
"thi.ng": {
|
|
139
143
|
"year": 2013
|
|
140
144
|
},
|
|
141
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "e5e7d5c6ed2eadee7a91d59cbd0c86ce880ab1c5\n"
|
|
142
146
|
}
|