@bitbybit-dev/base 0.19.8 → 0.19.9
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/babel.config.cjs +1 -0
- package/babel.config.d.cts +5 -0
- package/index.d.ts +1 -0
- package/{index.ts → index.js} +1 -2
- package/lib/api/index.js +1 -0
- package/lib/api/inputs/base-inputs.d.ts +35 -0
- package/lib/api/inputs/base-inputs.js +1 -0
- package/lib/api/inputs/{color-inputs.ts → color-inputs.d.ts} +26 -48
- package/lib/api/inputs/color-inputs.js +164 -0
- package/lib/api/inputs/index.js +9 -0
- package/lib/api/inputs/inputs.js +9 -0
- package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
- package/lib/api/inputs/lists-inputs.js +576 -0
- package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
- package/lib/api/inputs/logic-inputs.js +111 -0
- package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
- package/lib/api/inputs/math-inputs.js +391 -0
- package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
- package/lib/api/inputs/point-inputs.js +521 -0
- package/lib/api/inputs/text-inputs.d.ts +83 -0
- package/lib/api/inputs/text-inputs.js +120 -0
- package/lib/api/inputs/{transforms-inputs.ts → transforms-inputs.d.ts} +35 -64
- package/lib/api/inputs/transforms-inputs.js +200 -0
- package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
- package/lib/api/inputs/vector-inputs.js +304 -0
- package/lib/api/services/color.d.ts +114 -0
- package/lib/api/services/{color.ts → color.js} +15 -34
- package/lib/api/services/geometry-helper.d.ts +15 -0
- package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
- package/lib/api/services/{index.ts → index.d.ts} +1 -1
- package/lib/api/services/index.js +9 -0
- package/lib/api/services/lists.d.ts +287 -0
- package/lib/api/services/{lists.ts → lists.js} +59 -83
- package/lib/api/services/logic.d.ts +99 -0
- package/lib/api/services/{logic.ts → logic.js} +24 -32
- package/lib/api/services/math.d.ts +349 -0
- package/lib/api/services/{math.ts → math.js} +71 -136
- package/lib/api/services/point.d.ts +222 -0
- package/lib/api/services/{point.ts → point.js} +32 -67
- package/lib/api/services/text.d.ts +69 -0
- package/lib/api/services/{text.ts → text.js} +7 -17
- package/lib/api/services/transforms.d.ts +122 -0
- package/lib/api/services/{transforms.ts → transforms.js} +37 -83
- package/lib/api/services/vector.d.ts +320 -0
- package/lib/api/services/{vector.ts → vector.js} +42 -80
- package/lib/{index.ts → index.d.ts} +0 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/lib/api/inputs/base-inputs.ts +0 -18
- package/lib/api/inputs/text-inputs.ts +0 -108
- package/lib/api/services/color.test.ts +0 -86
- package/lib/api/services/lists.test.ts +0 -612
- package/lib/api/services/logic.test.ts +0 -187
- package/lib/api/services/math.test.ts +0 -622
- package/lib/api/services/text.test.ts +0 -55
- package/lib/api/services/vector.test.ts +0 -360
- package/tsconfig.bitbybit.json +0 -26
- package/tsconfig.json +0 -24
- /package/lib/api/{index.ts → index.d.ts} +0 -0
- /package/lib/api/inputs/{index.ts → index.d.ts} +0 -0
- /package/lib/api/inputs/{inputs.ts → inputs.d.ts} +0 -0
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as Inputs from "../inputs";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Contains various math methods.
|
|
5
4
|
*/
|
|
6
5
|
export class MathBitByBit {
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* Creates a number
|
|
10
8
|
* @param inputs a number to be created
|
|
@@ -13,10 +11,9 @@ export class MathBitByBit {
|
|
|
13
11
|
* @shortname number
|
|
14
12
|
* @drawable false
|
|
15
13
|
*/
|
|
16
|
-
number(inputs
|
|
14
|
+
number(inputs) {
|
|
17
15
|
return inputs.number;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
/**
|
|
21
18
|
* Does basic math operations
|
|
22
19
|
* @param inputs two numbers and operator
|
|
@@ -25,7 +22,7 @@ export class MathBitByBit {
|
|
|
25
22
|
* @shortname two numbers
|
|
26
23
|
* @drawable false
|
|
27
24
|
*/
|
|
28
|
-
twoNrOperation(inputs
|
|
25
|
+
twoNrOperation(inputs) {
|
|
29
26
|
let result;
|
|
30
27
|
switch (inputs.operation) {
|
|
31
28
|
case Inputs.Math.mathTwoNrOperatorEnum.add:
|
|
@@ -51,7 +48,6 @@ export class MathBitByBit {
|
|
|
51
48
|
}
|
|
52
49
|
return result;
|
|
53
50
|
}
|
|
54
|
-
|
|
55
51
|
/**
|
|
56
52
|
* Does modulus operation
|
|
57
53
|
* @param inputs two numbers and operator
|
|
@@ -60,10 +56,9 @@ export class MathBitByBit {
|
|
|
60
56
|
* @shortname modulus
|
|
61
57
|
* @drawable false
|
|
62
58
|
*/
|
|
63
|
-
modulus(inputs
|
|
59
|
+
modulus(inputs) {
|
|
64
60
|
return this.twoNrOperation({ first: inputs.number, second: inputs.modulus, operation: Inputs.Math.mathTwoNrOperatorEnum.modulus });
|
|
65
61
|
}
|
|
66
|
-
|
|
67
62
|
/**
|
|
68
63
|
* Does rounding to decimals
|
|
69
64
|
* @param inputs a number and decimal places
|
|
@@ -72,10 +67,9 @@ export class MathBitByBit {
|
|
|
72
67
|
* @shortname round to decimals
|
|
73
68
|
* @drawable false
|
|
74
69
|
*/
|
|
75
|
-
roundToDecimals(inputs
|
|
70
|
+
roundToDecimals(inputs) {
|
|
76
71
|
return Math.round(inputs.number * Math.pow(10, inputs.decimalPlaces)) / Math.pow(10, inputs.decimalPlaces);
|
|
77
72
|
}
|
|
78
|
-
|
|
79
73
|
/**
|
|
80
74
|
* Does basic math operations on one number
|
|
81
75
|
* @param inputs one number and operator action
|
|
@@ -84,7 +78,7 @@ export class MathBitByBit {
|
|
|
84
78
|
* @shortname one number
|
|
85
79
|
* @drawable false
|
|
86
80
|
*/
|
|
87
|
-
oneNrOperation(inputs
|
|
81
|
+
oneNrOperation(inputs) {
|
|
88
82
|
let result;
|
|
89
83
|
switch (inputs.operation) {
|
|
90
84
|
case Inputs.Math.mathOneNrOperatorEnum.absolute:
|
|
@@ -149,7 +143,6 @@ export class MathBitByBit {
|
|
|
149
143
|
}
|
|
150
144
|
return result;
|
|
151
145
|
}
|
|
152
|
-
|
|
153
146
|
/**
|
|
154
147
|
* Remaps a number from one range to another
|
|
155
148
|
* @param inputs one number and operator action
|
|
@@ -158,10 +151,9 @@ export class MathBitByBit {
|
|
|
158
151
|
* @shortname remap
|
|
159
152
|
* @drawable false
|
|
160
153
|
*/
|
|
161
|
-
remap(inputs
|
|
154
|
+
remap(inputs) {
|
|
162
155
|
return (inputs.number - inputs.fromLow) * (inputs.toHigh - inputs.toLow) / (inputs.fromHigh - inputs.fromLow) + inputs.toLow;
|
|
163
156
|
}
|
|
164
|
-
|
|
165
157
|
/**
|
|
166
158
|
* Creates a random number between 0 and 1
|
|
167
159
|
* @returns A random number between 0 and 1
|
|
@@ -169,10 +161,9 @@ export class MathBitByBit {
|
|
|
169
161
|
* @shortname random 0 - 1
|
|
170
162
|
* @drawable false
|
|
171
163
|
*/
|
|
172
|
-
random()
|
|
164
|
+
random() {
|
|
173
165
|
return Math.random();
|
|
174
166
|
}
|
|
175
|
-
|
|
176
167
|
/**
|
|
177
168
|
* Creates a random number between low and high value
|
|
178
169
|
* @param inputs low and high numbers
|
|
@@ -181,10 +172,9 @@ export class MathBitByBit {
|
|
|
181
172
|
* @shortname random number
|
|
182
173
|
* @drawable false
|
|
183
174
|
*/
|
|
184
|
-
randomNumber(inputs
|
|
175
|
+
randomNumber(inputs) {
|
|
185
176
|
return Math.random() * (inputs.high - inputs.low) + inputs.low;
|
|
186
177
|
}
|
|
187
|
-
|
|
188
178
|
/**
|
|
189
179
|
* Creates random numbers between low and high values
|
|
190
180
|
* @param inputs low and high numbers
|
|
@@ -193,14 +183,13 @@ export class MathBitByBit {
|
|
|
193
183
|
* @shortname random numbers
|
|
194
184
|
* @drawable false
|
|
195
185
|
*/
|
|
196
|
-
randomNumbers(inputs
|
|
186
|
+
randomNumbers(inputs) {
|
|
197
187
|
const result = [];
|
|
198
188
|
for (let i = 0; i < inputs.count; i++) {
|
|
199
189
|
result.push(this.randomNumber(inputs));
|
|
200
190
|
}
|
|
201
191
|
return result;
|
|
202
192
|
}
|
|
203
|
-
|
|
204
193
|
/**
|
|
205
194
|
* Creates a PI number
|
|
206
195
|
* @returns A number PI
|
|
@@ -208,10 +197,9 @@ export class MathBitByBit {
|
|
|
208
197
|
* @shortname π
|
|
209
198
|
* @drawable false
|
|
210
199
|
*/
|
|
211
|
-
pi()
|
|
200
|
+
pi() {
|
|
212
201
|
return Math.PI;
|
|
213
202
|
}
|
|
214
|
-
|
|
215
203
|
/**
|
|
216
204
|
* Rounds the number to decimal places
|
|
217
205
|
* @param inputs a number to be rounded to decimal places
|
|
@@ -220,10 +208,9 @@ export class MathBitByBit {
|
|
|
220
208
|
* @shortname to fixed
|
|
221
209
|
* @drawable false
|
|
222
210
|
*/
|
|
223
|
-
toFixed(inputs
|
|
211
|
+
toFixed(inputs) {
|
|
224
212
|
return inputs.number.toFixed(inputs.decimalPlaces);
|
|
225
213
|
}
|
|
226
|
-
|
|
227
214
|
/**
|
|
228
215
|
* Adds two numbers
|
|
229
216
|
* @param inputs two numbers
|
|
@@ -232,10 +219,9 @@ export class MathBitByBit {
|
|
|
232
219
|
* @shortname add
|
|
233
220
|
* @drawable false
|
|
234
221
|
*/
|
|
235
|
-
add(inputs
|
|
222
|
+
add(inputs) {
|
|
236
223
|
return inputs.first + inputs.second;
|
|
237
224
|
}
|
|
238
|
-
|
|
239
225
|
/**
|
|
240
226
|
* Subtracts two numbers
|
|
241
227
|
* @param inputs two numbers
|
|
@@ -244,10 +230,9 @@ export class MathBitByBit {
|
|
|
244
230
|
* @shortname subtract
|
|
245
231
|
* @drawable false
|
|
246
232
|
*/
|
|
247
|
-
subtract(inputs
|
|
233
|
+
subtract(inputs) {
|
|
248
234
|
return inputs.first - inputs.second;
|
|
249
235
|
}
|
|
250
|
-
|
|
251
236
|
/**
|
|
252
237
|
* Multiplies two numbers
|
|
253
238
|
* @param inputs two numbers
|
|
@@ -256,10 +241,9 @@ export class MathBitByBit {
|
|
|
256
241
|
* @shortname multiply
|
|
257
242
|
* @drawable false
|
|
258
243
|
*/
|
|
259
|
-
multiply(inputs
|
|
244
|
+
multiply(inputs) {
|
|
260
245
|
return inputs.first * inputs.second;
|
|
261
246
|
}
|
|
262
|
-
|
|
263
247
|
/**
|
|
264
248
|
* Divides two numbers
|
|
265
249
|
* @param inputs two numbers
|
|
@@ -268,10 +252,9 @@ export class MathBitByBit {
|
|
|
268
252
|
* @shortname divide
|
|
269
253
|
* @drawable false
|
|
270
254
|
*/
|
|
271
|
-
divide(inputs
|
|
255
|
+
divide(inputs) {
|
|
272
256
|
return inputs.first / inputs.second;
|
|
273
257
|
}
|
|
274
|
-
|
|
275
258
|
/**
|
|
276
259
|
* Powers a number
|
|
277
260
|
* @param inputs two numbers
|
|
@@ -280,10 +263,9 @@ export class MathBitByBit {
|
|
|
280
263
|
* @shortname power
|
|
281
264
|
* @drawable false
|
|
282
265
|
*/
|
|
283
|
-
power(inputs
|
|
266
|
+
power(inputs) {
|
|
284
267
|
return Math.pow(inputs.first, inputs.second);
|
|
285
268
|
}
|
|
286
|
-
|
|
287
269
|
/**
|
|
288
270
|
* Gets the square root of a number
|
|
289
271
|
* @param inputs a number
|
|
@@ -292,10 +274,9 @@ export class MathBitByBit {
|
|
|
292
274
|
* @shortname sqrt
|
|
293
275
|
* @drawable false
|
|
294
276
|
*/
|
|
295
|
-
sqrt(inputs
|
|
277
|
+
sqrt(inputs) {
|
|
296
278
|
return Math.sqrt(inputs.number);
|
|
297
279
|
}
|
|
298
|
-
|
|
299
280
|
/**
|
|
300
281
|
* Gets the absolute value of a number
|
|
301
282
|
* @param inputs a number
|
|
@@ -304,10 +285,9 @@ export class MathBitByBit {
|
|
|
304
285
|
* @shortname abs
|
|
305
286
|
* @drawable false
|
|
306
287
|
*/
|
|
307
|
-
abs(inputs
|
|
288
|
+
abs(inputs) {
|
|
308
289
|
return Math.abs(inputs.number);
|
|
309
290
|
}
|
|
310
|
-
|
|
311
291
|
/**
|
|
312
292
|
* Rounds a number
|
|
313
293
|
* @param inputs a number
|
|
@@ -316,10 +296,9 @@ export class MathBitByBit {
|
|
|
316
296
|
* @shortname round
|
|
317
297
|
* @drawable false
|
|
318
298
|
*/
|
|
319
|
-
round(inputs
|
|
299
|
+
round(inputs) {
|
|
320
300
|
return Math.round(inputs.number);
|
|
321
301
|
}
|
|
322
|
-
|
|
323
302
|
/**
|
|
324
303
|
* Floors a number
|
|
325
304
|
* @param inputs a number
|
|
@@ -328,10 +307,9 @@ export class MathBitByBit {
|
|
|
328
307
|
* @shortname floor
|
|
329
308
|
* @drawable false
|
|
330
309
|
*/
|
|
331
|
-
floor(inputs
|
|
310
|
+
floor(inputs) {
|
|
332
311
|
return Math.floor(inputs.number);
|
|
333
312
|
}
|
|
334
|
-
|
|
335
313
|
/**
|
|
336
314
|
* Ceils a number
|
|
337
315
|
* @param inputs a number
|
|
@@ -340,10 +318,9 @@ export class MathBitByBit {
|
|
|
340
318
|
* @shortname ceil
|
|
341
319
|
* @drawable false
|
|
342
320
|
*/
|
|
343
|
-
ceil(inputs
|
|
321
|
+
ceil(inputs) {
|
|
344
322
|
return Math.ceil(inputs.number);
|
|
345
323
|
}
|
|
346
|
-
|
|
347
324
|
/**
|
|
348
325
|
* Negates a number
|
|
349
326
|
* @param inputs a number
|
|
@@ -352,10 +329,9 @@ export class MathBitByBit {
|
|
|
352
329
|
* @shortname negate
|
|
353
330
|
* @drawable false
|
|
354
331
|
*/
|
|
355
|
-
negate(inputs
|
|
332
|
+
negate(inputs) {
|
|
356
333
|
return -inputs.number;
|
|
357
334
|
}
|
|
358
|
-
|
|
359
335
|
/**
|
|
360
336
|
* Gets the natural logarithm of a number
|
|
361
337
|
* @param inputs a number
|
|
@@ -364,10 +340,9 @@ export class MathBitByBit {
|
|
|
364
340
|
* @shortname ln
|
|
365
341
|
* @drawable false
|
|
366
342
|
*/
|
|
367
|
-
ln(inputs
|
|
343
|
+
ln(inputs) {
|
|
368
344
|
return Math.log(inputs.number);
|
|
369
345
|
}
|
|
370
|
-
|
|
371
346
|
/**
|
|
372
347
|
* Gets the base 10 logarithm of a number
|
|
373
348
|
* @param inputs a number
|
|
@@ -376,10 +351,9 @@ export class MathBitByBit {
|
|
|
376
351
|
* @shortname log10
|
|
377
352
|
* @drawable false
|
|
378
353
|
*/
|
|
379
|
-
log10(inputs
|
|
354
|
+
log10(inputs) {
|
|
380
355
|
return Math.log10(inputs.number);
|
|
381
356
|
}
|
|
382
|
-
|
|
383
357
|
/**
|
|
384
358
|
* Raises 10 to the power of a number
|
|
385
359
|
* @param inputs a number
|
|
@@ -388,10 +362,9 @@ export class MathBitByBit {
|
|
|
388
362
|
* @shortname ten pow
|
|
389
363
|
* @drawable false
|
|
390
364
|
*/
|
|
391
|
-
tenPow(inputs
|
|
365
|
+
tenPow(inputs) {
|
|
392
366
|
return Math.pow(10, inputs.number);
|
|
393
367
|
}
|
|
394
|
-
|
|
395
368
|
/**
|
|
396
369
|
* Gets the sine of a number
|
|
397
370
|
* @param inputs a number
|
|
@@ -400,10 +373,9 @@ export class MathBitByBit {
|
|
|
400
373
|
* @shortname sin
|
|
401
374
|
* @drawable false
|
|
402
375
|
*/
|
|
403
|
-
sin(inputs
|
|
376
|
+
sin(inputs) {
|
|
404
377
|
return Math.sin(inputs.number);
|
|
405
378
|
}
|
|
406
|
-
|
|
407
379
|
/**
|
|
408
380
|
* Gets the cosine of a number
|
|
409
381
|
* @param inputs a number
|
|
@@ -412,10 +384,9 @@ export class MathBitByBit {
|
|
|
412
384
|
* @shortname cos
|
|
413
385
|
* @drawable false
|
|
414
386
|
*/
|
|
415
|
-
cos(inputs
|
|
387
|
+
cos(inputs) {
|
|
416
388
|
return Math.cos(inputs.number);
|
|
417
389
|
}
|
|
418
|
-
|
|
419
390
|
/**
|
|
420
391
|
* Gets the tangent of a number
|
|
421
392
|
* @param inputs a number
|
|
@@ -424,10 +395,9 @@ export class MathBitByBit {
|
|
|
424
395
|
* @shortname tan
|
|
425
396
|
* @drawable false
|
|
426
397
|
*/
|
|
427
|
-
tan(inputs
|
|
398
|
+
tan(inputs) {
|
|
428
399
|
return Math.tan(inputs.number);
|
|
429
400
|
}
|
|
430
|
-
|
|
431
401
|
/**
|
|
432
402
|
* Gets the arcsine of a number
|
|
433
403
|
* @param inputs a number
|
|
@@ -436,10 +406,9 @@ export class MathBitByBit {
|
|
|
436
406
|
* @shortname asin
|
|
437
407
|
* @drawable false
|
|
438
408
|
*/
|
|
439
|
-
asin(inputs
|
|
409
|
+
asin(inputs) {
|
|
440
410
|
return Math.asin(inputs.number);
|
|
441
411
|
}
|
|
442
|
-
|
|
443
412
|
/**
|
|
444
413
|
* Gets the arccosine of a number
|
|
445
414
|
* @param inputs a number
|
|
@@ -448,10 +417,9 @@ export class MathBitByBit {
|
|
|
448
417
|
* @shortname acos
|
|
449
418
|
* @drawable false
|
|
450
419
|
*/
|
|
451
|
-
acos(inputs
|
|
420
|
+
acos(inputs) {
|
|
452
421
|
return Math.acos(inputs.number);
|
|
453
422
|
}
|
|
454
|
-
|
|
455
423
|
/**
|
|
456
424
|
* Gets the arctangent of a number
|
|
457
425
|
* @param inputs a number
|
|
@@ -460,10 +428,9 @@ export class MathBitByBit {
|
|
|
460
428
|
* @shortname atan
|
|
461
429
|
* @drawable false
|
|
462
430
|
*/
|
|
463
|
-
atan(inputs
|
|
431
|
+
atan(inputs) {
|
|
464
432
|
return Math.atan(inputs.number);
|
|
465
433
|
}
|
|
466
|
-
|
|
467
434
|
/**
|
|
468
435
|
* Gets the natural exponent of a number
|
|
469
436
|
* @param inputs a number
|
|
@@ -472,10 +439,9 @@ export class MathBitByBit {
|
|
|
472
439
|
* @shortname exp
|
|
473
440
|
* @drawable false
|
|
474
441
|
*/
|
|
475
|
-
exp(inputs
|
|
442
|
+
exp(inputs) {
|
|
476
443
|
return Math.exp(inputs.number);
|
|
477
444
|
}
|
|
478
|
-
|
|
479
445
|
/**
|
|
480
446
|
* Converts degrees to radians
|
|
481
447
|
* @param inputs a number in degrees
|
|
@@ -484,10 +450,9 @@ export class MathBitByBit {
|
|
|
484
450
|
* @shortname deg to rad
|
|
485
451
|
* @drawable false
|
|
486
452
|
*/
|
|
487
|
-
degToRad(inputs
|
|
453
|
+
degToRad(inputs) {
|
|
488
454
|
return inputs.number * Math.PI / 180;
|
|
489
455
|
}
|
|
490
|
-
|
|
491
456
|
/**
|
|
492
457
|
* Converts radians to degrees
|
|
493
458
|
* @param inputs a number in radians
|
|
@@ -496,10 +461,9 @@ export class MathBitByBit {
|
|
|
496
461
|
* @shortname rad to deg
|
|
497
462
|
* @drawable false
|
|
498
463
|
*/
|
|
499
|
-
radToDeg(inputs
|
|
464
|
+
radToDeg(inputs) {
|
|
500
465
|
return inputs.number * 180 / Math.PI;
|
|
501
466
|
}
|
|
502
|
-
|
|
503
467
|
/**
|
|
504
468
|
* Eases a number by providing x parameter 0-1 and a range of output values
|
|
505
469
|
* @param inputs a number, min and max values, and ease type
|
|
@@ -508,85 +472,66 @@ export class MathBitByBit {
|
|
|
508
472
|
* @shortname ease
|
|
509
473
|
* @drawable false
|
|
510
474
|
*/
|
|
511
|
-
ease(inputs
|
|
475
|
+
ease(inputs) {
|
|
512
476
|
const x = inputs.x;
|
|
513
477
|
const min = inputs.min;
|
|
514
478
|
const max = inputs.max;
|
|
515
|
-
|
|
516
479
|
const y = this[inputs.ease](x);
|
|
517
480
|
const res = this.remap({ number: y, fromLow: 0, fromHigh: 1, toLow: min, toHigh: max });
|
|
518
481
|
return res;
|
|
519
482
|
}
|
|
520
|
-
|
|
521
|
-
private easeInSine(x: number): number {
|
|
483
|
+
easeInSine(x) {
|
|
522
484
|
return 1 - Math.cos((x * Math.PI) / 2);
|
|
523
485
|
}
|
|
524
|
-
|
|
525
|
-
private easeOutSine(x: number): number {
|
|
486
|
+
easeOutSine(x) {
|
|
526
487
|
return Math.sin((x * Math.PI) / 2);
|
|
527
488
|
}
|
|
528
|
-
|
|
529
|
-
private easeInOutSine(x: number): number {
|
|
489
|
+
easeInOutSine(x) {
|
|
530
490
|
return -(Math.cos(Math.PI * x) - 1) / 2;
|
|
531
491
|
}
|
|
532
|
-
|
|
533
|
-
private easeInQuad(x: number): number {
|
|
492
|
+
easeInQuad(x) {
|
|
534
493
|
return x * x;
|
|
535
494
|
}
|
|
536
|
-
|
|
537
|
-
private easeOutQuad(x: number): number {
|
|
495
|
+
easeOutQuad(x) {
|
|
538
496
|
return 1 - (1 - x) * (1 - x);
|
|
539
497
|
}
|
|
540
|
-
|
|
541
|
-
private easeInOutQuad(x: number): number {
|
|
498
|
+
easeInOutQuad(x) {
|
|
542
499
|
return x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;
|
|
543
500
|
}
|
|
544
|
-
|
|
545
|
-
private easeInCubic(x: number): number {
|
|
501
|
+
easeInCubic(x) {
|
|
546
502
|
return x * x * x;
|
|
547
503
|
}
|
|
548
|
-
|
|
549
|
-
private easeOutCubic(x: number): number {
|
|
504
|
+
easeOutCubic(x) {
|
|
550
505
|
return 1 - Math.pow(1 - x, 3);
|
|
551
506
|
}
|
|
552
|
-
|
|
553
|
-
private easeInOutCubic(x: number): number {
|
|
507
|
+
easeInOutCubic(x) {
|
|
554
508
|
return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
|
|
555
509
|
}
|
|
556
|
-
|
|
557
|
-
private easeInQuart(x: number): number {
|
|
510
|
+
easeInQuart(x) {
|
|
558
511
|
return x * x * x * x;
|
|
559
512
|
}
|
|
560
|
-
|
|
561
|
-
private easeOutQuart(x: number): number {
|
|
513
|
+
easeOutQuart(x) {
|
|
562
514
|
return 1 - Math.pow(1 - x, 4);
|
|
563
515
|
}
|
|
564
|
-
|
|
565
|
-
private easeInOutQuart(x: number): number {
|
|
516
|
+
easeInOutQuart(x) {
|
|
566
517
|
return x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2;
|
|
567
518
|
}
|
|
568
|
-
|
|
569
|
-
private easeInQuint(x: number): number {
|
|
519
|
+
easeInQuint(x) {
|
|
570
520
|
return x * x * x * x * x;
|
|
571
521
|
}
|
|
572
|
-
|
|
573
|
-
private easeOutQuint(x: number): number {
|
|
522
|
+
easeOutQuint(x) {
|
|
574
523
|
return 1 - Math.pow(1 - x, 5);
|
|
575
524
|
}
|
|
576
|
-
|
|
577
|
-
private easeInOutQuint(x: number): number {
|
|
525
|
+
easeInOutQuint(x) {
|
|
578
526
|
return x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2;
|
|
579
527
|
}
|
|
580
|
-
|
|
581
|
-
private easeInExpo(x: number): number {
|
|
528
|
+
easeInExpo(x) {
|
|
582
529
|
return x === 0 ? 0 : Math.pow(2, 10 * x - 10);
|
|
583
530
|
}
|
|
584
|
-
|
|
585
|
-
private easeOutExpo(x: number): number {
|
|
531
|
+
easeOutExpo(x) {
|
|
586
532
|
return x === 1 ? 1 : 1 - Math.pow(2, -10 * x);
|
|
587
533
|
}
|
|
588
|
-
|
|
589
|
-
private easeInOutExpo(x: number): number {
|
|
534
|
+
easeInOutExpo(x) {
|
|
590
535
|
return x === 0
|
|
591
536
|
? 0
|
|
592
537
|
: x === 1
|
|
@@ -595,42 +540,35 @@ export class MathBitByBit {
|
|
|
595
540
|
? Math.pow(2, 20 * x - 10) / 2
|
|
596
541
|
: (2 - Math.pow(2, -20 * x + 10)) / 2;
|
|
597
542
|
}
|
|
598
|
-
|
|
599
|
-
private easeInCirc(x: number): number {
|
|
543
|
+
easeInCirc(x) {
|
|
600
544
|
return 1 - Math.sqrt(1 - x * x);
|
|
601
545
|
}
|
|
602
|
-
|
|
603
|
-
private easeOutCirc(x: number): number {
|
|
546
|
+
easeOutCirc(x) {
|
|
604
547
|
return Math.sqrt(1 - Math.pow(x - 1, 2));
|
|
605
548
|
}
|
|
606
|
-
|
|
607
|
-
private easeInOutCirc(x: number): number {
|
|
549
|
+
easeInOutCirc(x) {
|
|
608
550
|
return x < 0.5
|
|
609
551
|
? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2
|
|
610
552
|
: (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2;
|
|
611
553
|
}
|
|
612
|
-
|
|
613
|
-
private easeInBack(x: number): number {
|
|
554
|
+
easeInBack(x) {
|
|
614
555
|
const c1 = 1.70158;
|
|
615
556
|
const c3 = c1 + 1;
|
|
616
557
|
return c3 * x * x * x - c1 * x * x;
|
|
617
558
|
}
|
|
618
|
-
|
|
619
|
-
private easeOutBack(x: number): number {
|
|
559
|
+
easeOutBack(x) {
|
|
620
560
|
const c1 = 1.70158;
|
|
621
561
|
const c3 = c1 + 1;
|
|
622
562
|
return 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2);
|
|
623
563
|
}
|
|
624
|
-
|
|
625
|
-
private easeInOutBack(x: number): number {
|
|
564
|
+
easeInOutBack(x) {
|
|
626
565
|
const c1 = 1.70158;
|
|
627
566
|
const c2 = c1 * 1.525;
|
|
628
567
|
return x < 0.5
|
|
629
568
|
? (Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2
|
|
630
569
|
: (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
|
|
631
570
|
}
|
|
632
|
-
|
|
633
|
-
private easeInElastic(x: number): number {
|
|
571
|
+
easeInElastic(x) {
|
|
634
572
|
const c4 = (2 * Math.PI) / 3;
|
|
635
573
|
return x === 0
|
|
636
574
|
? 0
|
|
@@ -638,8 +576,7 @@ export class MathBitByBit {
|
|
|
638
576
|
? 1
|
|
639
577
|
: -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4);
|
|
640
578
|
}
|
|
641
|
-
|
|
642
|
-
private easeOutElastic(x: number): number {
|
|
579
|
+
easeOutElastic(x) {
|
|
643
580
|
const c4 = (2 * Math.PI) / 3;
|
|
644
581
|
return x === 0
|
|
645
582
|
? 0
|
|
@@ -647,8 +584,7 @@ export class MathBitByBit {
|
|
|
647
584
|
? 1
|
|
648
585
|
: Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
|
|
649
586
|
}
|
|
650
|
-
|
|
651
|
-
private easeInOutElastic(x: number): number {
|
|
587
|
+
easeInOutElastic(x) {
|
|
652
588
|
const c5 = (2 * Math.PI) / 4.5;
|
|
653
589
|
return x === 0
|
|
654
590
|
? 0
|
|
@@ -658,29 +594,28 @@ export class MathBitByBit {
|
|
|
658
594
|
? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2
|
|
659
595
|
: (Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5)) / 2 + 1;
|
|
660
596
|
}
|
|
661
|
-
|
|
662
|
-
private easeInBounce(x: number): number {
|
|
597
|
+
easeInBounce(x) {
|
|
663
598
|
return 1 - this.easeOutBounce(1 - x);
|
|
664
599
|
}
|
|
665
|
-
|
|
666
|
-
private easeOutBounce(x: number): number {
|
|
600
|
+
easeOutBounce(x) {
|
|
667
601
|
const n1 = 7.5625;
|
|
668
602
|
const d1 = 2.75;
|
|
669
603
|
if (x < 1 / d1) {
|
|
670
604
|
return n1 * x * x;
|
|
671
|
-
}
|
|
605
|
+
}
|
|
606
|
+
else if (x < 2 / d1) {
|
|
672
607
|
return n1 * (x -= 1.5 / d1) * x + 0.75;
|
|
673
|
-
}
|
|
608
|
+
}
|
|
609
|
+
else if (x < 2.5 / d1) {
|
|
674
610
|
return n1 * (x -= 2.25 / d1) * x + 0.9375;
|
|
675
|
-
}
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
676
613
|
return n1 * (x -= 2.625 / d1) * x + 0.984375;
|
|
677
614
|
}
|
|
678
615
|
}
|
|
679
|
-
|
|
680
|
-
private easeInOutBounce(x: number): number {
|
|
616
|
+
easeInOutBounce(x) {
|
|
681
617
|
return x < 0.5
|
|
682
618
|
? (1 - this.easeOutBounce(1 - 2 * x)) / 2
|
|
683
619
|
: (1 + this.easeOutBounce(2 * x - 1)) / 2;
|
|
684
620
|
}
|
|
685
|
-
|
|
686
621
|
}
|