@x1a0ma17x/zeppos-fx 2.0.3

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.
Files changed (46) hide show
  1. package/.z18n.config.json +11 -0
  2. package/License +21 -0
  3. package/README.md +190 -0
  4. package/README_zh-CN.md +196 -0
  5. package/example/app-side/i18n/en-US.po +2 -0
  6. package/example/app-side/index.js +13 -0
  7. package/example/app.js +10 -0
  8. package/example/app.json +52 -0
  9. package/example/assets/default.b/icon.png +0 -0
  10. package/example/assets/default.r/icon.png +0 -0
  11. package/example/assets/default.s/icon.png +0 -0
  12. package/example/global.d.ts +1 -0
  13. package/example/jsconfig.json +9 -0
  14. package/example/package.json +14 -0
  15. package/example/page/i18n/en-US.po +2 -0
  16. package/example/page/i18n/fr-FR.po +4 -0
  17. package/example/page/i18n/ru-RU.po +4 -0
  18. package/example/page/i18n/zh-CN.po +2 -0
  19. package/example/page/i18n/zh-TW.po +4 -0
  20. package/example/page/index.anim.js +37 -0
  21. package/example/page/index.js +19 -0
  22. package/example/page/index.r.layout.js +6 -0
  23. package/example/page/index.style.js +13 -0
  24. package/example/setting/i18n/en-US.po +2 -0
  25. package/example/setting/index.js +7 -0
  26. package/fx.js +623 -0
  27. package/fx.js.png +0 -0
  28. package/index.js +1 -0
  29. package/old/v1.0/fx.js +706 -0
  30. package/old/v1.0/smoothTimer.js +92 -0
  31. package/old/v2.0/fx.js +761 -0
  32. package/old/v2.0/zeppos_timer.js +64 -0
  33. package/package.json +25 -0
  34. package/src/example/app.js +10 -0
  35. package/src/example/app.json +46 -0
  36. package/src/example/assets/default.b/icon.png +0 -0
  37. package/src/example/assets/default.r/icon.png +0 -0
  38. package/src/example/assets/default.s/icon.png +0 -0
  39. package/src/example/global.d.ts +1 -0
  40. package/src/example/jsconfig.json +9 -0
  41. package/src/example/libs/fx.js +325 -0
  42. package/src/example/package.json +14 -0
  43. package/src/example/page/anim.js +60 -0
  44. package/src/example/page/i18n/en-US.po +2 -0
  45. package/src/example/page/index.js +13 -0
  46. package/src/example/page/index.r.layout.js +6 -0
package/old/v1.0/fx.js ADDED
@@ -0,0 +1,706 @@
1
+ /**
2
+ * fx.js
3
+ * @description A library for providing simple animations in ZeppOS. 一个用于在ZeppOS中提供简单动画的库
4
+ * @version 1.0.4
5
+ * @date 2023/03/15
6
+ * @author CuberQAQ XiaomaiTX
7
+ * @license MIT
8
+ * https://github.com/XiaomaiTX/zeppos-fx
9
+ *
10
+ * @class Fx Animations
11
+ * Provides two ways to use the preset and not to use the preset. 提供了使用预设和不使用预设两种方式
12
+ * A total of 31 presets are currently available, see @Fx.Style. 目前提供的预设共31种,详见下面的Fx.Style
13
+ * It's too much of a hassle not to use presets. 不使用预设太麻烦了 不如不用
14
+ * @example let fx = new Fx({params})
15
+ * let fx = new Fx({
16
+ * begin: 100, // Initial value of function. 初始函数值
17
+ * end: 200, // Target value of function. 目标函数值
18
+ * fps: 60, // FPS. 帧率
19
+ * time: 1, // Total during time (s). 总时长(秒)
20
+ * style: Fx.Styles.EASE_IN_OUT_QUAD, // Types of animation presets used, seeing @Fx.Style. 预设类型 见下面的Fx.Style
21
+ * onStop() {console.log("anim stop")}, // Callback function at the end of the animation. 动画结束后的回调函数
22
+ *
23
+ * // Callback function for each frame, the parameter is the current function value, the value range is [begin, end]
24
+ * // 每一帧的回调函数,参数为当前函数值,取值范围为[begin, end]
25
+ * func: result => text.setProperty(hmUI.prop.X, result)
26
+ * })
27
+ * fx.restart() // Replay animation can be called multiple times. 播放动画 可以重复多次调用
28
+ *
29
+ * @function getMixColor()
30
+ * It also provides a @function getMixColor() designed for color gradients, which can get the middle color of two colors.
31
+ * 还提供了一个专为颜色渐变设计的函数getMixColor,可以获取两个颜色的中间色
32
+ * @example ```js
33
+ * let rect = hmUI.createWidget(hmUI.widget.FILL_RECT, {
34
+ * x: 0,
35
+ * y: 0,
36
+ * w: 50,
37
+ * h: 100,
38
+ * radius: 10,
39
+ * color: 0xff3232,
40
+ * });
41
+ * let fx = new Fx({
42
+ * begin: 0, // 初始函数值
43
+ * end: 1, // 结束函数值
44
+ * fps: 60, // 帧率
45
+ * time: 1, // 总时长(秒)
46
+ * style: Fx.Styles.EASE_IN_OUT_QUAD, // 预设类型 见注释第7-9行
47
+ * onStop() {
48
+ * console.log("anim stop");
49
+ * }, // 动画结束后的回调函数
50
+ * // 每一帧的回调函数,参数为当前函数值,取值范围为[begin, end]
51
+ * func: (result) => {
52
+ * rect.setProperty(
53
+ * hmUI.prop.COLOR,
54
+ * Fx.getMixColor(0xff3232, 0x3232ff, result)
55
+ * );
56
+ * rect.setProperty(hmUI.prop.MORE, {
57
+ * ...Fx.getMixBorder(
58
+ * {
59
+ * x: 0,
60
+ * y: 0,
61
+ * w: 50,
62
+ * h: 100,
63
+ * radius: 10,
64
+ * },
65
+ * {
66
+ * x: 150,
67
+ * y: 200,
68
+ * w: 200,
69
+ * h: 250,
70
+ * radius: 75
71
+ * },
72
+ * result
73
+ * ),
74
+ * });
75
+ * },
76
+ * // useSmoothTimer: false // 若不需要稳定的计时器可取消注释
77
+ * });
78
+ * fx.restart(); // 播放动画 可以重复多次调用
79
+ * ```
80
+ * */
81
+ import { SmoothTimer, createSmoothTimer, stopSmoothTimer } from "./smoothTimer";
82
+
83
+ const bounceOut = function (x) {
84
+ /**
85
+ * Returns the bounce out result of x
86
+ * @param {number} x
87
+ * @returns {number}
88
+ */
89
+ const n1 = 7.5625;
90
+ const d1 = 2.75;
91
+
92
+ if (x < 1 / d1) {
93
+ return n1 * x * x;
94
+ } else if (x < 2 / d1) {
95
+ return n1 * (x -= 1.5 / d1) * x + 0.75;
96
+ } else if (x < 2.5 / d1) {
97
+ return n1 * (x -= 2.25 / d1) * x + 0.9375;
98
+ } else {
99
+ return n1 * (x -= 2.625 / d1) * x + 0.984375;
100
+ }
101
+ };
102
+
103
+ export class Fx {
104
+ /**
105
+ * @class Fx
106
+ *
107
+ * @constructor 构造函数
108
+ *
109
+ * @description Provide animations method. 提供动画的方法,使用例子上述已说明
110
+ *
111
+ * @param {number} delay 延迟执行
112
+ * @param {number} begin 初始函数值
113
+ * @param {number} end 目标函数值
114
+ * @param {number} (已弃用) x_start 函数开始的x坐标
115
+ * @param {number} (已弃用) x_end 函数结束的x坐标
116
+ * @param {number} time 执行总时间
117
+ * @param {*} (已弃用) fx x => y 动画函数
118
+ * @param {*} func 执行的函数,每次的y值会作为第一个参数传给func
119
+ * @param {number} fps 动画帧率
120
+ * @param {*} enable
121
+ * @param {string} style 内置预设类型
122
+ * @param {*} onStop 结束后执行的函数
123
+ */
124
+ constructor({
125
+ delay,
126
+ begin,
127
+ end,
128
+ x_start,
129
+ x_end,
130
+ time,
131
+ fx,
132
+ func,
133
+ fps,
134
+ enable,
135
+ style,
136
+ onStop,
137
+ }) {
138
+ if (fx) {
139
+ // 不使用预设
140
+ this.x_start = x_start * 1.0;
141
+ this.x_end = x_end * 1.0;
142
+ this.fx = fx;
143
+ this.speed = (x_end - x_start) / (time * fps);
144
+ } else {
145
+ // 使用预设
146
+ this.begin = begin;
147
+ this.end = end;
148
+ this.fps = fps;
149
+ this.time = time;
150
+ switch (style) {
151
+ case Fx.Styles.LINEAR:
152
+ this.fx = (x) => fx_inside.LINEAR(x, begin, end, fps * time);
153
+ this.x_start = 0;
154
+ this.x_end = fps * time;
155
+ this.speed = 1;
156
+ break;
157
+ case Fx.Styles.EASE_IN_SINE:
158
+ this.fx = (x) => fx_inside.EASE_IN_SINE(x, begin, end, fps * time);
159
+ this.x_start = 0;
160
+ this.x_end = fps * time;
161
+ this.speed = 1;
162
+ break;
163
+ case Fx.Styles.EASE_OUT_SINE:
164
+ this.fx = (x) => fx_inside.EASE_OUT_SINE(x, begin, end, fps * time);
165
+ this.x_start = 0;
166
+ this.x_end = fps * time;
167
+ this.speed = 1;
168
+ break;
169
+ case Fx.Styles.EASE_IN_OUT_SINE:
170
+ this.fx = (x) =>
171
+ fx_inside.EASE_IN_OUT_SINE(x, begin, end, fps * time);
172
+ this.x_start = 0;
173
+ this.x_end = fps * time;
174
+ this.speed = 1;
175
+ break;
176
+ case Fx.Styles.EASE_IN_QUAD:
177
+ this.fx = (x) => fx_inside.EASE_IN_QUAD(x, begin, end, fps * time);
178
+ this.x_start = 0;
179
+ this.x_end = fps * time;
180
+ this.speed = 1;
181
+ break;
182
+ case Fx.Styles.EASE_OUT_QUAD:
183
+ this.fx = (x) => fx_inside.EASE_OUT_QUAD(x, begin, end, fps * time);
184
+ this.x_start = 0;
185
+ this.x_end = fps * time;
186
+ this.speed = 1;
187
+ break;
188
+ case Fx.Styles.EASE_IN_OUT_QUAD:
189
+ this.fx = (x) =>
190
+ fx_inside.EASE_IN_OUT_QUAD(x, begin, end, fps * time);
191
+ this.x_start = 0;
192
+ this.x_end = fps * time;
193
+ this.speed = 1;
194
+ break;
195
+ case Fx.Styles.EASE_IN_CUBIC:
196
+ this.fx = (x) => fx_inside.EASE_IN_CUBIC(x, begin, end, fps * time);
197
+ this.x_start = 0;
198
+ this.x_end = fps * time;
199
+ this.speed = 1;
200
+ break;
201
+ case Fx.Styles.EASE_OUT_CUBIC:
202
+ this.fx = (x) => fx_inside.EASE_OUT_CUBIC(x, begin, end, fps * time);
203
+ this.x_start = 0;
204
+ this.x_end = fps * time;
205
+ this.speed = 1;
206
+ break;
207
+ case Fx.Styles.EASE_IN_OUT_CUBIC:
208
+ this.fx = (x) =>
209
+ fx_inside.EASE_IN_OUT_CUBIC(x, begin, end, fps * time);
210
+ this.x_start = 0;
211
+ this.x_end = fps * time;
212
+ this.speed = 1;
213
+ break;
214
+ case Fx.Styles.EASE_IN_QUART:
215
+ this.fx = (x) => fx_inside.EASE_IN_QUART(x, begin, end, fps * time);
216
+ this.x_start = 0;
217
+ this.x_end = fps * time;
218
+ this.speed = 1;
219
+ break;
220
+ case Fx.Styles.EASE_OUT_QUART:
221
+ this.fx = (x) => fx_inside.EASE_OUT_QUART(x, begin, end, fps * time);
222
+ this.x_start = 0;
223
+ this.x_end = fps * time;
224
+ this.speed = 1;
225
+ break;
226
+ case Fx.Styles.EASE_IN_OUT_QUART:
227
+ this.fx = (x) =>
228
+ fx_inside.EASE_IN_OUT_QUART(x, begin, end, fps * time);
229
+ this.x_start = 0;
230
+ this.x_end = fps * time;
231
+ this.speed = 1;
232
+ break;
233
+ case Fx.Styles.EASE_IN_QUINT:
234
+ this.fx = (x) => fx_inside.EASE_IN_QUINT(x, begin, end, fps * time);
235
+ this.x_start = 0;
236
+ this.x_end = fps * time;
237
+ this.speed = 1;
238
+ break;
239
+ case Fx.Styles.EASE_OUT_QUINT:
240
+ this.fx = (x) => fx_inside.EASE_OUT_QUINT(x, begin, end, fps * time);
241
+ this.x_start = 0;
242
+ this.x_end = fps * time;
243
+ this.speed = 1;
244
+ break;
245
+ case Fx.Styles.EASE_IN_OUT_QUINT:
246
+ this.fx = (x) =>
247
+ fx_inside.EASE_IN_OUT_QUINT(x, begin, end, fps * time);
248
+ this.x_start = 0;
249
+ this.x_end = fps * time;
250
+ this.speed = 1;
251
+ break;
252
+ case Fx.Styles.EASE_IN_EXPO:
253
+ this.fx = (x) => fx_inside.EASE_IN_EXPO(x, begin, end, fps * time);
254
+ this.x_start = 0;
255
+ this.x_end = fps * time;
256
+ this.speed = 1;
257
+ break;
258
+ case Fx.Styles.EASE_OUT_EXPO:
259
+ this.fx = (x) => fx_inside.EASE_OUT_EXPO(x, begin, end, fps * time);
260
+ this.x_start = 0;
261
+ this.x_end = fps * time;
262
+ this.speed = 1;
263
+ break;
264
+ case Fx.Styles.EASE_IN_OUT_EXPO:
265
+ this.fx = (x) =>
266
+ fx_inside.EASE_IN_OUT_EXPO(x, begin, end, fps * time);
267
+ this.x_start = 0;
268
+ this.x_end = fps * time;
269
+ this.speed = 1;
270
+ break;
271
+ case Fx.Styles.EASE_IN_CIRC:
272
+ this.fx = (x) => fx_inside.EASE_IN_CIRC(x, begin, end, fps * time);
273
+ this.x_start = 0;
274
+ this.x_end = fps * time;
275
+ this.speed = 1;
276
+ break;
277
+ case Fx.Styles.EASE_OUT_CIRC:
278
+ this.fx = (x) => fx_inside.EASE_OUT_CIRC(x, begin, end, fps * time);
279
+ this.x_start = 0;
280
+ this.x_end = fps * time;
281
+ this.speed = 1;
282
+ break;
283
+ case Fx.Styles.EASE_IN_OUT_CIRC:
284
+ this.fx = (x) =>
285
+ fx_inside.EASE_IN_OUT_CIRC(x, begin, end, fps * time);
286
+ this.x_start = 0;
287
+ this.x_end = fps * time;
288
+ this.speed = 1;
289
+ break;
290
+ case Fx.Styles.EASE_IN_BACK:
291
+ this.fx = (x) => fx_inside.EASE_IN_BACK(x, begin, end, fps * time);
292
+ this.x_start = 0;
293
+ this.x_end = fps * time;
294
+ this.speed = 1;
295
+ break;
296
+ case Fx.Styles.EASE_OUT_BACK:
297
+ this.fx = (x) => fx_inside.EASE_OUT_BACK(x, begin, end, fps * time);
298
+ this.x_start = 0;
299
+ this.x_end = fps * time;
300
+ this.speed = 1;
301
+ break;
302
+ case Fx.Styles.EASE_IN_OUT_BACK:
303
+ this.fx = (x) =>
304
+ fx_inside.EASE_IN_OUT_BACK(x, begin, end, fps * time);
305
+ this.x_start = 0;
306
+ this.x_end = fps * time;
307
+ this.speed = 1;
308
+ break;
309
+ case Fx.Styles.EASE_IN_ELASTIC:
310
+ this.fx = (x) => fx_inside.EASE_IN_ELASTIC(x, begin, end, fps * time);
311
+ this.x_start = 0;
312
+ this.x_end = fps * time;
313
+ this.speed = 1;
314
+ break;
315
+ case Fx.Styles.EASE_OUT_ELASTIC:
316
+ this.fx = (x) =>
317
+ fx_inside.EASE_OUT_ELASTIC(x, begin, end, fps * time);
318
+ this.x_start = 0;
319
+ this.x_end = fps * time;
320
+ this.speed = 1;
321
+ break;
322
+ case Fx.Styles.EASE_IN_OUT_ELASTIC:
323
+ this.fx = (x) =>
324
+ fx_inside.EASE_IN_OUT_ELASTIC(x, begin, end, fps * time);
325
+ this.x_start = 0;
326
+ this.x_end = fps * time;
327
+ this.speed = 1;
328
+ break;
329
+ case Fx.Styles.EASE_IN_BOUNCE:
330
+ this.fx = (x) => fx_inside.EASE_IN_BOUNCE(x, begin, end, fps * time);
331
+ this.x_start = 0;
332
+ this.x_end = fps * time;
333
+ this.speed = 1;
334
+ break;
335
+ case Fx.Styles.EASE_OUT_BOUNCE:
336
+ this.fx = (x) => fx_inside.EASE_OUT_BOUNCE(x, begin, end, fps * time);
337
+ this.x_start = 0;
338
+ this.x_end = fps * time;
339
+ this.speed = 1;
340
+ break;
341
+ case Fx.Styles.EASE_IN_OUT_BOUNCE:
342
+ this.fx = (x) =>
343
+ fx_inside.EASE_IN_OUT_BOUNCE(x, begin, end, fps * time);
344
+ this.x_start = 0;
345
+ this.x_end = fps * time;
346
+ this.speed = 1;
347
+ break;
348
+ }
349
+ }
350
+ this.per_clock = 1000 / fps;
351
+ this.delay = delay;
352
+ this.func = func;
353
+ this.x_now = this.x_start;
354
+ this.onStop = onStop;
355
+ if (enable == undefined) {
356
+ this.enable = true;
357
+ } else {
358
+ this.enable = enable;
359
+ }
360
+ this.timer = null;
361
+
362
+ this.setEnable(this.enable);
363
+ }
364
+ restart() {
365
+ this.x_now = this.x_start;
366
+ this.setEnable(false);
367
+ this.setEnable(true);
368
+ }
369
+ setEnable(enable) {
370
+ if (enable) {
371
+ this.registerTimer();
372
+ } else {
373
+ if (this.timer) {
374
+ timer.stopTimer(this.timer);
375
+ this.timer = null;
376
+ }
377
+ }
378
+ }
379
+ registerTimer() {
380
+ this.timer = new createSmoothTimer(
381
+ this.delay ? this.delay : 0,
382
+ this.per_clock,
383
+ (option) => {
384
+ this.func(this.fx((this.x_now += this.speed)));
385
+ if (this.x_now > this.x_end) {
386
+ //防止不到终点
387
+ this.func(this.fx(this.x_end));
388
+ //执行onStop
389
+ if (this.onStop != undefined) {
390
+ this.onStop();
391
+ }
392
+ //停止timer
393
+ stopSmoothTimer(this.timer);
394
+ this.timer = null;
395
+ this.enable = false;
396
+ }
397
+ },
398
+ {}
399
+ );
400
+ }
401
+ /**
402
+ * @function getMixColor()
403
+ * @description Get the middle color of two colors.
404
+ * @param {number} color 1. 初始颜色1 (6位十六进制)
405
+ * @param {number} color 2. 初始颜色2 (6位十六进制)
406
+ * @param {number} percentage (range [0,1], the smaller the closer to color0). 混合百分比(范围[0,1],越小越接近color0)
407
+ */
408
+ static getMixColor(color1, color2, percentage) {
409
+ let r0 = color1 & 0xff0000,
410
+ g0 = color1 & 0x00ff00,
411
+ b0 = color1 & 0x0000ff;
412
+ let r1 = color2 & 0xff0000,
413
+ g1 = color2 & 0x00ff00,
414
+ b1 = color2 & 0x0000ff;
415
+ return (
416
+ (Math.floor((r1 - r0) * percentage + r0) & 0xff0000) +
417
+ (Math.floor((g1 - g0) * percentage + g0) & 0x00ff00) +
418
+ (Math.floor((b1 - b0) * percentage + b0) & 0x0000ff)
419
+ );
420
+ }
421
+ /**
422
+ * @description Get the mixture of to border(x, y, w, h, radius) 获取两个边框(x,y,w,h)的混合值
423
+ * @param {{x?:number, y?:number, w?:number, h?:number, radius?:number}} border1 边框1 不一定需要给四个参数
424
+ * @param {{x?:number, y?:number, w?:number, h?:number, radius?:number}} border2 边框2 不一定需要给四个参数
425
+ * @param {number} percentage 混合百分比 取值[0,1] 若取0则为border1 取1则为border2
426
+ * @returns {x?:number, y?:number, w?:number, h?:number, radius?:number} 混合后的边框
427
+ */
428
+ static getMixBorder(border1, border2, percentage) {
429
+ return {
430
+ x: border1.x + (border2.x - border1.x) * percentage,
431
+ y: border1.y + (border2.y - border1.y) * percentage,
432
+ w: border1.w + (border2.w - border1.w) * percentage,
433
+ h: border1.h + (border2.h - border1.h) * percentage,
434
+ radius: border1.radius + (border2.radius - border1.radius) * percentage,
435
+ };
436
+ }
437
+ }Fx.Styles = {
438
+ /**
439
+ * List of preset styles
440
+ * @example EXAMPLE: indexNumber,
441
+ */
442
+ LINEAR: 0,
443
+ EASE_IN_SINE: 1,
444
+ EASE_OUT_SINE: 2,
445
+ EASE_IN_OUT_SINE: 3,
446
+ EASE_IN_QUAD: 4,
447
+ EASE_OUT_QUAD: 5,
448
+ EASE_IN_OUT_QUAD: 6,
449
+ EASE_IN_CUBIC: 7,
450
+ EASE_OUT_CUBIC: 8,
451
+ EASE_IN_OUT_CUBIC: 9,
452
+ EASE_IN_QUART: 10,
453
+ EASE_OUT_QUART: 11,
454
+ EASE_IN_OUT_QUART: 12,
455
+ EASE_IN_QUINT: 13,
456
+ EASE_OUT_QUINT: 14,
457
+ EASE_IN_OUT_QUINT: 15,
458
+ EASE_IN_EXPO: 16,
459
+ EASE_OUT_EXPO: 17,
460
+ EASE_IN_OUT_EXPO: 18,
461
+ EASE_IN_CIRC: 19,
462
+ EASE_OUT_CIRC: 20,
463
+ EASE_IN_OUT_CIRC: 21,
464
+ EASE_IN_BACK: 22,
465
+ EASE_OUT_BACK: 23,
466
+ EASE_IN_OUT_BACK: 24,
467
+ EASE_IN_ELASTIC: 25,
468
+ EASE_OUT_ELASTIC: 26,
469
+ EASE_IN_OUT_ELASTIC: 27,
470
+ EASE_IN_BOUNCE: 28,
471
+ EASE_OUT_BOUNCE: 29,
472
+ EASE_IN_OUT_BOUNCE: 31,
473
+ };
474
+ const fx_inside = {
475
+ // TODO Add more style
476
+
477
+ // The following presets are available for reference https://easings.net/
478
+ // 以下预设可参考 https://easings.net/
479
+
480
+ LINEAR: function (now_x, begin, end, max_x) {
481
+ function math_func(x) {
482
+ return x;
483
+ }
484
+ return begin + (end - begin) * math_func(now_x / max_x);
485
+ },
486
+ EASE_IN_SINE: function (now_x, begin, end, max_x) {
487
+ function math_func(x) {
488
+ return 1 - cos((x * Math.PI) / 2);
489
+ }
490
+ return begin + (end - begin) * math_func(now_x / max_x);
491
+ },
492
+ EASE_OUT_SINE: function (now_x, begin, end, max_x) {
493
+ function math_func(x) {
494
+ return sin((x * Math.PI) / 2);
495
+ }
496
+ return begin + (end - begin) * math_func(now_x / max_x);
497
+ },
498
+ EASE_IN_OUT_SINE: function (now_x, begin, end, max_x) {
499
+ function math_func(x) {
500
+ return -(cos(Math.PI * x) - 1) / 2;
501
+ }
502
+ return begin + (end - begin) * math_func(now_x / max_x);
503
+ },
504
+ EASE_IN_QUAD: function (now_x, begin, end, max_x) {
505
+ function math_func(x) {
506
+ return x * x;
507
+ }
508
+ return begin + (end - begin) * math_func(now_x / max_x);
509
+ },
510
+ EASE_OUT_QUAD: function (now_x, begin, end, max_x) {
511
+ function math_func(x) {
512
+ return 1 - (1 - x) * (1 - x);
513
+ }
514
+ return begin + (end - begin) * math_func(now_x / max_x);
515
+ },
516
+ EASE_IN_OUT_QUAD: function (now_x, begin, end, max_x) {
517
+ function math_func(x) {
518
+ return x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;
519
+ }
520
+ return begin + (end - begin) * math_func(now_x / max_x);
521
+ },
522
+ EASE_IN_CUBIC: function (now_x, begin, end, max_x) {
523
+ function math_func(x) {
524
+ return x * x * x;
525
+ }
526
+ return begin + (end - begin) * math_func(now_x / max_x);
527
+ },
528
+ EASE_OUT_CUBIC: function (now_x, begin, end, max_x) {
529
+ function math_func(x) {
530
+ return 1 - Math.pow(1 - x, 3);
531
+ }
532
+ return begin + (end - begin) * math_func(now_x / max_x);
533
+ },
534
+ EASE_IN_OUT_CUBIC: function (now_x, begin, end, max_x) {
535
+ function math_func(x) {
536
+ return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
537
+ }
538
+ return begin + (end - begin) * math_func(now_x / max_x);
539
+ },
540
+ EASE_IN_QUART: function (now_x, begin, end, max_x) {
541
+ function math_func(x) {
542
+ return x * x * x * x;
543
+ }
544
+ return begin + (end - begin) * math_func(now_x / max_x);
545
+ },
546
+ EASE_OUT_QUART: function (now_x, begin, end, max_x) {
547
+ function math_func(x) {
548
+ return 1 - Math.pow(1 - x, 4);
549
+ }
550
+ return begin + (end - begin) * math_func(now_x / max_x);
551
+ },
552
+ EASE_IN_OUT_QUART: function (now_x, begin, end, max_x) {
553
+ function math_func(x) {
554
+ return x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2;
555
+ }
556
+ return begin + (end - begin) * math_func(now_x / max_x);
557
+ },
558
+ EASE_IN_QUINT: function (now_x, begin, end, max_x) {
559
+ function math_func(x) {
560
+ return x * x * x * x * x;
561
+ }
562
+ return begin + (end - begin) * math_func(now_x / max_x);
563
+ },
564
+ EASE_OUT_QUINT: function (now_x, begin, end, max_x) {
565
+ function math_func(x) {
566
+ return 1 - Math.pow(1 - x, 4);
567
+ }
568
+ return begin + (end - begin) * math_func(now_x / max_x);
569
+ },
570
+ EASE_IN_OUT_QUINT: function (now_x, begin, end, max_x) {
571
+ function math_func(x) {
572
+ return x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2;
573
+ }
574
+ return begin + (end - begin) * math_func(now_x / max_x);
575
+ },
576
+ EASE_IN_EXPO: function (now_x, begin, end, max_x) {
577
+ function math_func(x) {
578
+ return x === 0 ? 0 : Math.pow(2, 10 * x - 10);
579
+ }
580
+ return begin + (end - begin) * math_func(now_x / max_x);
581
+ },
582
+ EASE_OUT_EXPO: function (now_x, begin, end, max_x) {
583
+ function math_func(x) {
584
+ return x === 1 ? 1 : 1 - Math.pow(2, -10 * x);
585
+ }
586
+ return begin + (end - begin) * math_func(now_x / max_x);
587
+ },
588
+ EASE_IN_OUT_EXPO: function (now_x, begin, end, max_x) {
589
+ function math_func(x) {
590
+ return x === 0
591
+ ? 0
592
+ : x === 1
593
+ ? 1
594
+ : x < 0.5
595
+ ? Math.pow(2, 20 * x - 10) / 2
596
+ : (2 - Math.pow(2, -20 * x + 10)) / 2;
597
+ }
598
+ return begin + (end - begin) * math_func(now_x / max_x);
599
+ },
600
+ EASE_IN_CIRC: function (now_x, begin, end, max_x) {
601
+ function math_func(x) {
602
+ return 1 - Math.sqrt(1 - Math.pow(x, 2));
603
+ }
604
+ return begin + (end - begin) * math_func(now_x / max_x);
605
+ },
606
+ EASE_OUT_CIRC: function (now_x, begin, end, max_x) {
607
+ function math_func(x) {
608
+ return Math.sqrt(1 - Math.pow(x - 1, 2));
609
+ }
610
+ return begin + (end - begin) * math_func(now_x / max_x);
611
+ },
612
+ EASE_IN_OUT_CIRC: function (now_x, begin, end, max_x) {
613
+ function math_func(x) {
614
+ return x < 0.5
615
+ ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2
616
+ : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2;
617
+ }
618
+ return begin + (end - begin) * math_func(now_x / max_x);
619
+ },
620
+ EASE_IN_BACK: function (now_x, begin, end, max_x) {
621
+ function math_func(x) {
622
+ return 1.70158 + 1 * x * x * x - 1.70158 * x * x;
623
+ }
624
+ return begin + (end - begin) * math_func(now_x / max_x);
625
+ },
626
+ EASE_OUT_BACK: function (now_x, begin, end, max_x) {
627
+ function math_func(x) {
628
+ return (
629
+ 1 + 1.70158 + 1 * Math.pow(x - 1, 3) + 1.70158 * Math.pow(x - 1, 2)
630
+ );
631
+ }
632
+ return begin + (end - begin) * math_func(now_x / max_x);
633
+ },
634
+ EASE_IN_OUT_BACK: function (now_x, begin, end, max_x) {
635
+ function math_func(x) {
636
+ return x < 0.5
637
+ ? (Math.pow(2 * x, 2) *
638
+ ((1.70158 * 1.525 + 1) * 2 * x - 1.70158 * 1.525)) /
639
+ 2
640
+ : (Math.pow(2 * x - 2, 2) *
641
+ ((1.70158 * 1.525 + 1) * (x * 2 - 2) + 1.70158 * 1.525) +
642
+ 2) /
643
+ 2;
644
+ }
645
+ return begin + (end - begin) * math_func(now_x / max_x);
646
+ },
647
+ EASE_IN_ELASTIC: function (now_x, begin, end, max_x) {
648
+ function math_func(x) {
649
+ return x === 0
650
+ ? 0
651
+ : x === 1
652
+ ? 1
653
+ : -Math.pow(2, 10 * x - 10) *
654
+ sin(((x * 10 - 10.75) * (2 * Math.PI)) / 3);
655
+ }
656
+ return begin + (end - begin) * math_func(now_x / max_x);
657
+ },
658
+ EASE_OUT_ELASTIC: function (now_x, begin, end, max_x) {
659
+ function math_func(x) {
660
+ return x === 0
661
+ ? 0
662
+ : x === 1
663
+ ? 1
664
+ : Math.pow(2, -10 * x) * sin(((x * 10 - 0.75) * (2 * Math.PI)) / 3) + 1;
665
+ }
666
+ return begin + (end - begin) * math_func(now_x / max_x);
667
+ },
668
+ EASE_IN_OUT_ELASTIC: function (now_x, begin, end, max_x) {
669
+ function math_func(x) {
670
+ return x === 0
671
+ ? 0
672
+ : x === 1
673
+ ? 1
674
+ : x < 0.5
675
+ ? -(
676
+ Math.pow(2, 20 * x - 10) *
677
+ sin(((20 * x - 11.125) * (2 * Math.PI)) / 4.5)
678
+ ) / 2
679
+ : (Math.pow(2, -20 * x + 10) *
680
+ sin(((20 * x - 11.125) * (2 * Math.PI)) / 4.5)) /
681
+ 2 +
682
+ 1;
683
+ }
684
+ return begin + (end - begin) * math_func(now_x / max_x);
685
+ },
686
+ EASE_IN_BOUNCE: function (now_x, begin, end, max_x) {
687
+ function math_func(x) {
688
+ return 1 - bounceOut(1 - x);
689
+ }
690
+ return begin + (end - begin) * math_func(now_x / max_x);
691
+ },
692
+ EASE_OUT_BOUNCE: function (now_x, begin, end, max_x) {
693
+ function math_func(x) {
694
+ return bounceOut(x);
695
+ }
696
+ return begin + (end - begin) * math_func(now_x / max_x);
697
+ },
698
+ EASE_IN_OUT_BOUNCE: function (now_x, begin, end, max_x) {
699
+ function math_func(x) {
700
+ return x < 0.5
701
+ ? (1 - bounceOut(1 - 2 * x)) / 2
702
+ : (1 + bounceOut(2 * x - 1)) / 2;
703
+ }
704
+ return begin + (end - begin) * math_func(now_x / max_x);
705
+ },
706
+ };