ziko 0.48.1 → 0.48.2
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/ziko.cjs +158 -128
- package/dist/ziko.js +158 -128
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +123 -93
- package/package.json +8 -8
- package/src/__ziko__/__signature__.js +0 -0
- package/src/math/complex/index.js +6 -17
- package/src/time/animation/index.js +2 -2
- package/src/time/ease/index.js +115 -74
- package/types/index.d.ts +2 -0
- package/types/math/complex/index.d.ts +52 -0
- package/types/math/index.d.ts +2 -0
- package/types/math/utils/index.d.ts +1 -0
- package/types/math/utils/mapfun.d.ts +43 -0
- package/types/time/ease/index.d.ts +103 -0
- package/types/time/index.d.ts +1 -0
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Fri Nov 21 2025 22:08:16 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -3781,27 +3781,27 @@ class Complex extends ZikoMath{
|
|
|
3781
3781
|
this.b=a.b;
|
|
3782
3782
|
}
|
|
3783
3783
|
else if(typeof(a)==="object"){
|
|
3784
|
-
if(("a" in
|
|
3784
|
+
if(("a" in a && "b" in a)){
|
|
3785
3785
|
this.a=a.a;
|
|
3786
3786
|
this.b=a.b;
|
|
3787
3787
|
}
|
|
3788
|
-
else if(("a" in
|
|
3788
|
+
else if(("a" in a && "z" in a)){
|
|
3789
3789
|
this.a=a.a;
|
|
3790
3790
|
this.b=sqrt$2((a.z**2)-(a.a**2));
|
|
3791
3791
|
}
|
|
3792
|
-
else if(("a" in
|
|
3792
|
+
else if(("a" in a && "phi" in a)){
|
|
3793
3793
|
this.a=a.a;
|
|
3794
3794
|
this.b=a.a*tan(a.phi);
|
|
3795
3795
|
}
|
|
3796
|
-
else if(("b" in
|
|
3796
|
+
else if(("b" in a && "z" in a)){
|
|
3797
3797
|
this.b=a.b;
|
|
3798
3798
|
this.a=sqrt$2((a.z**2)-(a.b**2));
|
|
3799
3799
|
}
|
|
3800
|
-
else if(("b" in
|
|
3800
|
+
else if(("b" in a && "phi" in a)){
|
|
3801
3801
|
this.b=b;
|
|
3802
3802
|
this.a=a.b/tan(a.phi);
|
|
3803
3803
|
}
|
|
3804
|
-
else if(("z" in
|
|
3804
|
+
else if(("z" in a && "phi" in a)){
|
|
3805
3805
|
this.a=a.z*cos$2(a.phi);
|
|
3806
3806
|
this.a=a.z*sin$2(a.phi);
|
|
3807
3807
|
}
|
|
@@ -3940,17 +3940,6 @@ class Complex extends ZikoMath{
|
|
|
3940
3940
|
const de=cos$2(this.a*2)+cosh$1(this.b*2);
|
|
3941
3941
|
return complex(sin$2(2*this.a)/de,sinh$1(2*this.b)/de);
|
|
3942
3942
|
}
|
|
3943
|
-
printInConsole() {
|
|
3944
|
-
let string = this.a + " + " + this.b + " * i";
|
|
3945
|
-
console.log(string);
|
|
3946
|
-
return string;
|
|
3947
|
-
}
|
|
3948
|
-
print() {
|
|
3949
|
-
//return text(this.a + " + i * " + this.b);
|
|
3950
|
-
}
|
|
3951
|
-
UI() {
|
|
3952
|
-
return "<span>" + this.a + " + i * " + this.b + "</span>";
|
|
3953
|
-
}
|
|
3954
3943
|
}
|
|
3955
3944
|
const complex=(a,b)=>{
|
|
3956
3945
|
if((a instanceof Array||ArrayBuffer.isView(a)) && (b instanceof Array||ArrayBuffer.isView(a)))return a.map((n,i)=>complex(a[i],b[i]));
|
|
@@ -4078,86 +4067,127 @@ const hypot=(...x)=>{
|
|
|
4078
4067
|
)
|
|
4079
4068
|
};
|
|
4080
4069
|
|
|
4081
|
-
const {PI, sqrt: sqrt$1, cos: cos$1, sin: sin$1, acos, pow} = Math;
|
|
4082
|
-
|
|
4083
|
-
const
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
const
|
|
4087
|
-
|
|
4088
|
-
const
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
const
|
|
4093
|
-
const
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
const
|
|
4098
|
-
const
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
const
|
|
4105
|
-
const
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
const
|
|
4110
|
-
const
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
const
|
|
4117
|
-
const
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
const
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
const
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
const
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4070
|
+
const { PI, sqrt: sqrt$1, cos: cos$1, sin: sin$1, acos, pow } = Math;
|
|
4071
|
+
|
|
4072
|
+
const linear = t => t;
|
|
4073
|
+
|
|
4074
|
+
// --- Sin ---
|
|
4075
|
+
const in_sin = t => 1 - cos$1((t * PI) / 2);
|
|
4076
|
+
const out_sin = t => sin$1((t * PI) / 2);
|
|
4077
|
+
const in_out_sin = t => -(cos$1(PI * t) - 1) / 2;
|
|
4078
|
+
|
|
4079
|
+
// --- Quad ---
|
|
4080
|
+
const in_quad = t => t ** 2;
|
|
4081
|
+
const out_quad = t => 1 - (1 - t) ** 2;
|
|
4082
|
+
const in_out_quad = t =>
|
|
4083
|
+
t < 0.5 ? 2 * (t ** 2) : 1 - (-2 * t + 2) ** 2 / 2;
|
|
4084
|
+
|
|
4085
|
+
// --- Cubic ---
|
|
4086
|
+
const in_cubic = t => t ** 3;
|
|
4087
|
+
const out_cubic = t => 1 - (1 - t) ** 3;
|
|
4088
|
+
const in_out_cubic = t =>
|
|
4089
|
+
t < 0.5 ? 4 * (t ** 3) : 1 - (-2 * t + 2) ** 3 / 2;
|
|
4090
|
+
|
|
4091
|
+
// --- Quart ---
|
|
4092
|
+
const in_quart = t => t ** 4;
|
|
4093
|
+
const out_quart = t => 1 - (1 - t) ** 4;
|
|
4094
|
+
const in_out_quart = t =>
|
|
4095
|
+
t < 0.5 ? 8 * (t ** 4) : 1 - (-2 * t + 2) ** 4 / 2;
|
|
4096
|
+
|
|
4097
|
+
// --- Quint ---
|
|
4098
|
+
const in_quint = t => t ** 5;
|
|
4099
|
+
const out_quint = t => 1 - (1 - t) ** 5;
|
|
4100
|
+
const in_out_quint = t =>
|
|
4101
|
+
t < 0.5 ? 16 * (t ** 5) : 1 - (-2 * t + 2) ** 5 / 2;
|
|
4102
|
+
|
|
4103
|
+
// --- Expo ---
|
|
4104
|
+
const in_expo = t => (t === 0 ? 0 : 2 ** (10 * t - 10));
|
|
4105
|
+
const out_expo = t => (t === 1 ? 1 : 1 - 2 ** (-10 * t));
|
|
4106
|
+
const in_out_expo = t =>
|
|
4107
|
+
t === 0
|
|
4108
|
+
? 0
|
|
4109
|
+
: t === 1
|
|
4110
|
+
? 1
|
|
4111
|
+
: t < 0.5
|
|
4112
|
+
? 2 ** (20 * t - 10) / 2
|
|
4113
|
+
: (2 - 2 ** (-20 * t + 10)) / 2;
|
|
4114
|
+
|
|
4115
|
+
// --- Circ ---
|
|
4116
|
+
const in_circ = t => 1 - sqrt$1(1 - t ** 2);
|
|
4117
|
+
const out_circ = t => sqrt$1(1 - (t - 1) ** 2);
|
|
4118
|
+
const in_out_circ = t =>
|
|
4119
|
+
t < 0.5
|
|
4120
|
+
? (1 - sqrt$1(1 - (2 * t) ** 2)) / 2
|
|
4121
|
+
: (sqrt$1(1 - (-2 * t + 2) ** 2) + 1) / 2;
|
|
4122
|
+
|
|
4123
|
+
// --- Arc ---
|
|
4124
|
+
const arc = t => 1 - sin$1(acos(t));
|
|
4125
|
+
|
|
4126
|
+
// --- Back ---
|
|
4127
|
+
const back = (t, x = 1) => (t ** 2) * ((x + 1) * t - x);
|
|
4128
|
+
|
|
4129
|
+
// --- Elastic ---
|
|
4130
|
+
const elastic = t =>
|
|
4131
|
+
-2 * pow(2, 10 * (t - 1)) * cos$1((20 * PI * t) / 3 * t);
|
|
4132
|
+
|
|
4133
|
+
// --- Back variations ---
|
|
4134
|
+
const in_back = (t, c1 = 1.70158, c3 = c1 + 1) =>
|
|
4135
|
+
c3 * pow(t, 3) - c1 * (t ** 2);
|
|
4136
|
+
|
|
4137
|
+
const out_back = (t, c1 = 1.70158, c3 = c1 + 1) =>
|
|
4138
|
+
1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
|
|
4139
|
+
|
|
4140
|
+
const in_out_back = (t, c1 = 1.70158, c2 = c1 * 1.525) =>
|
|
4141
|
+
t < 0.5
|
|
4142
|
+
? (pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2
|
|
4143
|
+
: (pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2;
|
|
4144
|
+
|
|
4145
|
+
// --- Elastic variations ---
|
|
4146
|
+
const in_elastic = (t, c4 = (2 * PI) / 3) =>
|
|
4147
|
+
t === 0
|
|
4148
|
+
? 0
|
|
4149
|
+
: t === 1
|
|
4150
|
+
? 1
|
|
4151
|
+
: -pow(2, 10 * t - 10) * sin$1((t * 10 - 10.75) * c4);
|
|
4152
|
+
|
|
4153
|
+
const out_elastic = (t, c4 = (2 * PI) / 3) =>
|
|
4154
|
+
t === 0
|
|
4155
|
+
? 0
|
|
4156
|
+
: t === 1
|
|
4157
|
+
? 1
|
|
4158
|
+
: pow(2, -10 * t) * sin$1((t * 10 - 0.75) * c4) + 1;
|
|
4159
|
+
|
|
4160
|
+
const in_out_elastic = (t, c5 = (2 * PI) / 4.5) =>
|
|
4161
|
+
t === 0
|
|
4162
|
+
? 0
|
|
4163
|
+
: t === 1
|
|
4164
|
+
? 1
|
|
4165
|
+
: t < 0.5
|
|
4166
|
+
? -(pow(2, 20 * t - 10) * sin$1((20 * t - 11.125) * c5)) / 2
|
|
4167
|
+
: (pow(2, -20 * t + 10) * sin$1((20 * t - 11.125) * c5)) / 2 + 1;
|
|
4168
|
+
|
|
4169
|
+
// --- Bounce ---
|
|
4170
|
+
const in_bounce = (t, n1 = 7.5625, d1 = 2.75) =>
|
|
4171
|
+
1 - out_bounce(1 - t, n1, d1);
|
|
4172
|
+
|
|
4173
|
+
const out_bounce = (t, n1 = 7.5625, d1 = 2.75) => {
|
|
4174
|
+
if (t < 1 / d1) return n1 * t * t;
|
|
4175
|
+
if (t < 2 / d1) return n1 * (t -= 1.5 / d1) * t + 0.75;
|
|
4176
|
+
if (t < 2.5 / d1) return n1 * (t -= 2.25 / d1) * t + 0.9375;
|
|
4150
4177
|
return n1 * (t -= 2.625 / d1) * t + 0.984375;
|
|
4151
4178
|
};
|
|
4152
4179
|
|
|
4153
|
-
const
|
|
4154
|
-
|
|
4180
|
+
const in_out_bounce = (t, n1 = 7.5625, d1 = 2.75) =>
|
|
4181
|
+
t < 0.5
|
|
4182
|
+
? out_bounce(1 - 2 * t, n1, d1) / 2
|
|
4183
|
+
: out_bounce(2 * t - 1, n1, d1) / 2;
|
|
4155
4184
|
|
|
4156
|
-
|
|
4157
|
-
const
|
|
4185
|
+
// --- Step / Discrete ---
|
|
4186
|
+
const step = (t, steps = 5) => Math.floor(t * steps) / steps;
|
|
4187
|
+
const discret = (t, segments = 5) => Math.ceil(t * segments) / segments;
|
|
4158
4188
|
|
|
4159
4189
|
class TimeAnimation {
|
|
4160
|
-
constructor(callback, { ease =
|
|
4190
|
+
constructor(callback, { ease = linear, step = 50, t0 = 0, start = true, duration = 3000 } = {}) {
|
|
4161
4191
|
this.callback = callback;
|
|
4162
4192
|
this.state = {
|
|
4163
4193
|
isRunning: false,
|
|
@@ -5359,4 +5389,4 @@ if(globalThis?.document){
|
|
|
5359
5389
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
5360
5390
|
}
|
|
5361
5391
|
|
|
5362
|
-
export { App,
|
|
5392
|
+
export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, Utils, View, ZikoApp, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventHash, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventTouch, ZikoEventWheel, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, e, elastic, fact, floor, geomspace, getEvent, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useDerived, useEventEmitter, useLocaleStorage, useReactive, useRoot, useSessionStorage, useState, useThread, wait, waitForUIElm, waitForUIElmSync, zeros };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.2",
|
|
4
4
|
"description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"front-end",
|
|
@@ -24,16 +24,17 @@
|
|
|
24
24
|
"types",
|
|
25
25
|
"LICENCE"
|
|
26
26
|
],
|
|
27
|
-
"types": "./types/global.d.ts",
|
|
28
27
|
"exports": {
|
|
29
|
-
"./*":
|
|
28
|
+
"./*": {
|
|
29
|
+
"import" : "./src/*/index.js",
|
|
30
|
+
"types" : "./types/*/index.d.ts"
|
|
31
|
+
},
|
|
30
32
|
".": {
|
|
31
33
|
"import": "./dist/ziko.mjs",
|
|
32
|
-
"require": "./dist/ziko.cjs"
|
|
33
|
-
|
|
34
|
-
"./math": {
|
|
35
|
-
"import": "./src/math/index.js"
|
|
34
|
+
"require": "./dist/ziko.cjs",
|
|
35
|
+
"types" : "./types/index.d.ts"
|
|
36
36
|
},
|
|
37
|
+
|
|
37
38
|
"./helpers": {
|
|
38
39
|
"import": "./src/__helpers__.js"
|
|
39
40
|
},
|
|
@@ -59,7 +60,6 @@
|
|
|
59
60
|
"./src": "./src/index.js",
|
|
60
61
|
"./html": {},
|
|
61
62
|
"./app": {},
|
|
62
|
-
"./time": {},
|
|
63
63
|
"./components": {}
|
|
64
64
|
},
|
|
65
65
|
"sideEffects" : true,
|
|
File without changes
|
|
@@ -23,27 +23,27 @@ class Complex extends ZikoMath{
|
|
|
23
23
|
this.b=a.b;
|
|
24
24
|
}
|
|
25
25
|
else if(typeof(a)==="object"){
|
|
26
|
-
if(("a" in
|
|
26
|
+
if(("a" in a && "b" in a)){
|
|
27
27
|
this.a=a.a;
|
|
28
28
|
this.b=a.b;
|
|
29
29
|
}
|
|
30
|
-
else if(("a" in
|
|
30
|
+
else if(("a" in a && "z" in a)){
|
|
31
31
|
this.a=a.a;
|
|
32
32
|
this.b=sqrt((a.z**2)-(a.a**2));
|
|
33
33
|
}
|
|
34
|
-
else if(("a" in
|
|
34
|
+
else if(("a" in a && "phi" in a)){
|
|
35
35
|
this.a=a.a;
|
|
36
36
|
this.b=a.a*tan(a.phi);
|
|
37
37
|
}
|
|
38
|
-
else if(("b" in
|
|
38
|
+
else if(("b" in a && "z" in a)){
|
|
39
39
|
this.b=a.b;
|
|
40
40
|
this.a=sqrt((a.z**2)-(a.b**2));
|
|
41
41
|
}
|
|
42
|
-
else if(("b" in
|
|
42
|
+
else if(("b" in a && "phi" in a)){
|
|
43
43
|
this.b=b;
|
|
44
44
|
this.a=a.b/tan(a.phi);
|
|
45
45
|
}
|
|
46
|
-
else if(("z" in
|
|
46
|
+
else if(("z" in a && "phi" in a)){
|
|
47
47
|
this.a=a.z*cos(a.phi);
|
|
48
48
|
this.a=a.z*sin(a.phi);
|
|
49
49
|
}
|
|
@@ -182,17 +182,6 @@ class Complex extends ZikoMath{
|
|
|
182
182
|
const de=cos(this.a*2)+cosh(this.b*2);
|
|
183
183
|
return complex(sin(2*this.a)/de,sinh(2*this.b)/de);
|
|
184
184
|
}
|
|
185
|
-
printInConsole() {
|
|
186
|
-
let string = this.a + " + " + this.b + " * i";
|
|
187
|
-
console.log(string);
|
|
188
|
-
return string;
|
|
189
|
-
}
|
|
190
|
-
print() {
|
|
191
|
-
//return text(this.a + " + i * " + this.b);
|
|
192
|
-
}
|
|
193
|
-
UI() {
|
|
194
|
-
return "<span>" + this.a + " + i * " + this.b + "</span>";
|
|
195
|
-
}
|
|
196
185
|
}
|
|
197
186
|
const complex=(a,b)=>{
|
|
198
187
|
if((a instanceof Array||ArrayBuffer.isView(a)) && (b instanceof Array||ArrayBuffer.isView(a)))return a.map((n,i)=>complex(a[i],b[i]));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { linear } from "../ease/index.js";
|
|
2
2
|
import { map } from "../../math/utils/index.js";
|
|
3
3
|
|
|
4
4
|
class TimeAnimation {
|
|
5
|
-
constructor(callback, { ease =
|
|
5
|
+
constructor(callback, { ease = linear, step = 50, t0 = 0, start = true, duration = 3000 } = {}) {
|
|
6
6
|
this.callback = callback;
|
|
7
7
|
this.state = {
|
|
8
8
|
isRunning: false,
|
package/src/time/ease/index.js
CHANGED
|
@@ -1,77 +1,118 @@
|
|
|
1
|
-
const {PI, sqrt, cos, sin, acos, pow} = Math;
|
|
2
|
-
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export const
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export const
|
|
37
|
-
export const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export const
|
|
56
|
-
return t === 0
|
|
57
|
-
? 0
|
|
58
|
-
: t === 1
|
|
59
|
-
? 1
|
|
60
|
-
: t < 0.5
|
|
61
|
-
? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
|
|
62
|
-
: (pow(2, -20 * t + 10) * sin((20 * t - 11.125) * c5)) / 2 + 1;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const InBounce = (t, n1 = 7.5625, d1 = 2.75) => 1 - OutBounce(1-t, n1, d1);
|
|
66
|
-
export const OutBounce = (t, n1 = 7.5625, d1 = 2.75) => {
|
|
67
|
-
if(t<1/d1) return n1 * t * t;
|
|
68
|
-
if(t < 2 / d1) return n1 * (t -= 1.5 / d1) * t + 0.75;
|
|
69
|
-
if(t < 2.5 / d1) return n1 * (t -= 2.25 / d1) * t + 0.9375;
|
|
70
|
-
return n1 * (t -= 2.625 / d1) * t + 0.984375;
|
|
71
|
-
}
|
|
1
|
+
const { PI, sqrt, cos, sin, acos, pow } = Math;
|
|
2
|
+
|
|
3
|
+
export const linear = t => t;
|
|
4
|
+
|
|
5
|
+
// --- Sin ---
|
|
6
|
+
export const in_sin = t => 1 - cos((t * PI) / 2);
|
|
7
|
+
export const out_sin = t => sin((t * PI) / 2);
|
|
8
|
+
export const in_out_sin = t => -(cos(PI * t) - 1) / 2;
|
|
9
|
+
|
|
10
|
+
// --- Quad ---
|
|
11
|
+
export const in_quad = t => t ** 2;
|
|
12
|
+
export const out_quad = t => 1 - (1 - t) ** 2;
|
|
13
|
+
export const in_out_quad = t =>
|
|
14
|
+
t < 0.5 ? 2 * (t ** 2) : 1 - (-2 * t + 2) ** 2 / 2;
|
|
15
|
+
|
|
16
|
+
// --- Cubic ---
|
|
17
|
+
export const in_cubic = t => t ** 3;
|
|
18
|
+
export const out_cubic = t => 1 - (1 - t) ** 3;
|
|
19
|
+
export const in_out_cubic = t =>
|
|
20
|
+
t < 0.5 ? 4 * (t ** 3) : 1 - (-2 * t + 2) ** 3 / 2;
|
|
21
|
+
|
|
22
|
+
// --- Quart ---
|
|
23
|
+
export const in_quart = t => t ** 4;
|
|
24
|
+
export const out_quart = t => 1 - (1 - t) ** 4;
|
|
25
|
+
export const in_out_quart = t =>
|
|
26
|
+
t < 0.5 ? 8 * (t ** 4) : 1 - (-2 * t + 2) ** 4 / 2;
|
|
27
|
+
|
|
28
|
+
// --- Quint ---
|
|
29
|
+
export const in_quint = t => t ** 5;
|
|
30
|
+
export const out_quint = t => 1 - (1 - t) ** 5;
|
|
31
|
+
export const in_out_quint = t =>
|
|
32
|
+
t < 0.5 ? 16 * (t ** 5) : 1 - (-2 * t + 2) ** 5 / 2;
|
|
33
|
+
|
|
34
|
+
// --- Expo ---
|
|
35
|
+
export const in_expo = t => (t === 0 ? 0 : 2 ** (10 * t - 10));
|
|
36
|
+
export const out_expo = t => (t === 1 ? 1 : 1 - 2 ** (-10 * t));
|
|
37
|
+
export const in_out_expo = t =>
|
|
38
|
+
t === 0
|
|
39
|
+
? 0
|
|
40
|
+
: t === 1
|
|
41
|
+
? 1
|
|
42
|
+
: t < 0.5
|
|
43
|
+
? 2 ** (20 * t - 10) / 2
|
|
44
|
+
: (2 - 2 ** (-20 * t + 10)) / 2;
|
|
45
|
+
|
|
46
|
+
// --- Circ ---
|
|
47
|
+
export const in_circ = t => 1 - sqrt(1 - t ** 2);
|
|
48
|
+
export const out_circ = t => sqrt(1 - (t - 1) ** 2);
|
|
49
|
+
export const in_out_circ = t =>
|
|
50
|
+
t < 0.5
|
|
51
|
+
? (1 - sqrt(1 - (2 * t) ** 2)) / 2
|
|
52
|
+
: (sqrt(1 - (-2 * t + 2) ** 2) + 1) / 2;
|
|
53
|
+
|
|
54
|
+
// --- Arc ---
|
|
55
|
+
export const arc = t => 1 - sin(acos(t));
|
|
72
56
|
|
|
73
|
-
|
|
57
|
+
// --- Back ---
|
|
58
|
+
export const back = (t, x = 1) => (t ** 2) * ((x + 1) * t - x);
|
|
59
|
+
|
|
60
|
+
// --- Elastic ---
|
|
61
|
+
export const elastic = t =>
|
|
62
|
+
-2 * pow(2, 10 * (t - 1)) * cos((20 * PI * t) / 3 * t);
|
|
63
|
+
|
|
64
|
+
// --- Back variations ---
|
|
65
|
+
export const in_back = (t, c1 = 1.70158, c3 = c1 + 1) =>
|
|
66
|
+
c3 * pow(t, 3) - c1 * (t ** 2);
|
|
67
|
+
|
|
68
|
+
export const out_back = (t, c1 = 1.70158, c3 = c1 + 1) =>
|
|
69
|
+
1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
|
|
70
|
+
|
|
71
|
+
export const in_out_back = (t, c1 = 1.70158, c2 = c1 * 1.525) =>
|
|
72
|
+
t < 0.5
|
|
73
|
+
? (pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2
|
|
74
|
+
: (pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2;
|
|
75
|
+
|
|
76
|
+
// --- Elastic variations ---
|
|
77
|
+
export const in_elastic = (t, c4 = (2 * PI) / 3) =>
|
|
78
|
+
t === 0
|
|
79
|
+
? 0
|
|
80
|
+
: t === 1
|
|
81
|
+
? 1
|
|
82
|
+
: -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * c4);
|
|
83
|
+
|
|
84
|
+
export const out_elastic = (t, c4 = (2 * PI) / 3) =>
|
|
85
|
+
t === 0
|
|
86
|
+
? 0
|
|
87
|
+
: t === 1
|
|
88
|
+
? 1
|
|
89
|
+
: pow(2, -10 * t) * sin((t * 10 - 0.75) * c4) + 1;
|
|
90
|
+
|
|
91
|
+
export const in_out_elastic = (t, c5 = (2 * PI) / 4.5) =>
|
|
92
|
+
t === 0
|
|
93
|
+
? 0
|
|
94
|
+
: t === 1
|
|
95
|
+
? 1
|
|
96
|
+
: t < 0.5
|
|
97
|
+
? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
|
|
98
|
+
: (pow(2, -20 * t + 10) * sin((20 * t - 11.125) * c5)) / 2 + 1;
|
|
99
|
+
|
|
100
|
+
// --- Bounce ---
|
|
101
|
+
export const in_bounce = (t, n1 = 7.5625, d1 = 2.75) =>
|
|
102
|
+
1 - out_bounce(1 - t, n1, d1);
|
|
103
|
+
|
|
104
|
+
export const out_bounce = (t, n1 = 7.5625, d1 = 2.75) => {
|
|
105
|
+
if (t < 1 / d1) return n1 * t * t;
|
|
106
|
+
if (t < 2 / d1) return n1 * (t -= 1.5 / d1) * t + 0.75;
|
|
107
|
+
if (t < 2.5 / d1) return n1 * (t -= 2.25 / d1) * t + 0.9375;
|
|
108
|
+
return n1 * (t -= 2.625 / d1) * t + 0.984375;
|
|
109
|
+
};
|
|
74
110
|
|
|
111
|
+
export const in_out_bounce = (t, n1 = 7.5625, d1 = 2.75) =>
|
|
112
|
+
t < 0.5
|
|
113
|
+
? out_bounce(1 - 2 * t, n1, d1) / 2
|
|
114
|
+
: out_bounce(2 * t - 1, n1, d1) / 2;
|
|
75
115
|
|
|
76
|
-
|
|
77
|
-
export const
|
|
116
|
+
// --- Step / Discrete ---
|
|
117
|
+
export const step = (t, steps = 5) => Math.floor(t * steps) / steps;
|
|
118
|
+
export const discret = (t, segments = 5) => Math.ceil(t * segments) / segments;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare class Complex {
|
|
2
|
+
a: number;
|
|
3
|
+
b: number;
|
|
4
|
+
|
|
5
|
+
constructor(a?: number, b?: number);
|
|
6
|
+
constructor(c: Complex);
|
|
7
|
+
constructor(a:
|
|
8
|
+
{ a: number; b: number } |
|
|
9
|
+
{ a: number; z: number } |
|
|
10
|
+
{ a: number; phi: number } |
|
|
11
|
+
{ b: number; z: number } |
|
|
12
|
+
{ b: number; phi: number } |
|
|
13
|
+
{ z: number; phi: number }
|
|
14
|
+
);
|
|
15
|
+
constructor();
|
|
16
|
+
|
|
17
|
+
isComplex(): true;
|
|
18
|
+
toString(): string;
|
|
19
|
+
|
|
20
|
+
readonly clone: Complex;
|
|
21
|
+
readonly z: number;
|
|
22
|
+
readonly phi: number;
|
|
23
|
+
readonly conj: Complex;
|
|
24
|
+
readonly inv: Complex;
|
|
25
|
+
readonly sqrt: Complex;
|
|
26
|
+
readonly log: Complex;
|
|
27
|
+
readonly cos: Complex;
|
|
28
|
+
readonly sin: Complex;
|
|
29
|
+
readonly tan: Complex;
|
|
30
|
+
expo: [number, number];
|
|
31
|
+
|
|
32
|
+
add(...z: (number | Complex)[]): this;
|
|
33
|
+
sub(...z: (number | Complex)[]): this;
|
|
34
|
+
mul(...z: (number | Complex)[]): this;
|
|
35
|
+
div(...z: (number | Complex)[]): this;
|
|
36
|
+
pow(n: number): this;
|
|
37
|
+
sqrtn(n?: number): Complex;
|
|
38
|
+
|
|
39
|
+
static Zero(): Complex;
|
|
40
|
+
static fromExpo(z: number, phi: number): Complex;
|
|
41
|
+
static add(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
42
|
+
static sub(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
43
|
+
static mul(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
44
|
+
static div(c: Complex, ...z: (number | Complex)[]): Complex;
|
|
45
|
+
static pow(c: Complex, n: number): Complex;
|
|
46
|
+
static xpowZ(x: number): Complex;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare function complex(a: number, b?: number): Complex;
|
|
50
|
+
export declare function complex(a: Complex): Complex;
|
|
51
|
+
export declare function complex(a: object): Complex;
|
|
52
|
+
export declare function complex(): Complex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './mapfun'
|