@vpmedia/phaser 1.0.1 → 1.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 (112) hide show
  1. package/README.md +20 -3
  2. package/dist/phaser.cjs +1 -1
  3. package/dist/phaser.cjs.LICENSE.txt +1 -1
  4. package/dist/phaser.cjs.map +1 -1
  5. package/dist/phaser.js +1 -1
  6. package/dist/phaser.js.LICENSE.txt +1 -1
  7. package/dist/phaser.js.map +1 -1
  8. package/package.json +23 -17
  9. package/src/index.js +142 -0
  10. package/src/phaser/core/animation.js +355 -0
  11. package/src/phaser/core/animation_manager.js +238 -0
  12. package/src/phaser/core/animation_parser.js +133 -0
  13. package/src/phaser/core/array_set.js +107 -0
  14. package/src/phaser/core/cache.js +558 -0
  15. package/src/phaser/core/const.js +106 -0
  16. package/src/phaser/core/device.js +67 -0
  17. package/src/phaser/core/device_util.js +388 -0
  18. package/src/phaser/core/dom.js +207 -0
  19. package/src/phaser/core/event_manager.js +243 -0
  20. package/src/phaser/core/factory.js +74 -0
  21. package/src/phaser/core/frame.js +75 -0
  22. package/src/phaser/core/frame_data.js +84 -0
  23. package/src/phaser/core/frame_util.js +33 -0
  24. package/src/phaser/core/game.js +412 -0
  25. package/src/phaser/core/input.js +401 -0
  26. package/src/phaser/core/input_button.js +102 -0
  27. package/src/phaser/core/input_handler.js +687 -0
  28. package/src/phaser/core/input_mouse.js +289 -0
  29. package/src/phaser/core/input_mspointer.js +197 -0
  30. package/src/phaser/core/input_pointer.js +427 -0
  31. package/src/phaser/core/input_touch.js +157 -0
  32. package/src/phaser/core/loader.js +1057 -0
  33. package/src/phaser/core/loader_parser.js +109 -0
  34. package/src/phaser/core/raf.js +46 -0
  35. package/src/phaser/core/raf_fb.js +75 -0
  36. package/src/phaser/core/raf_to.js +34 -0
  37. package/src/phaser/core/scale_manager.js +806 -0
  38. package/src/phaser/core/scene.js +65 -0
  39. package/src/phaser/core/scene_manager.js +309 -0
  40. package/src/phaser/core/signal.js +175 -0
  41. package/src/phaser/core/signal_binding.js +69 -0
  42. package/src/phaser/core/sound.js +538 -0
  43. package/src/phaser/core/sound_manager.js +364 -0
  44. package/src/phaser/core/stage.js +108 -0
  45. package/src/phaser/core/time.js +203 -0
  46. package/src/phaser/core/timer.js +276 -0
  47. package/src/phaser/core/timer_event.js +21 -0
  48. package/src/phaser/core/tween.js +329 -0
  49. package/src/phaser/core/tween_data.js +258 -0
  50. package/src/phaser/core/tween_easing.js +341 -0
  51. package/src/phaser/core/tween_manager.js +185 -0
  52. package/src/phaser/core/world.js +18 -0
  53. package/src/phaser/display/bitmap_text.js +322 -0
  54. package/src/phaser/display/button.js +194 -0
  55. package/src/phaser/display/canvas/buffer.js +36 -0
  56. package/src/phaser/display/canvas/graphics.js +227 -0
  57. package/src/phaser/display/canvas/masker.js +39 -0
  58. package/src/phaser/display/canvas/pool.js +126 -0
  59. package/src/phaser/display/canvas/renderer.js +123 -0
  60. package/src/phaser/display/canvas/tinter.js +144 -0
  61. package/src/phaser/display/canvas/util.js +159 -0
  62. package/src/phaser/display/display_object.js +597 -0
  63. package/src/phaser/display/graphics.js +723 -0
  64. package/src/phaser/display/graphics_data.js +27 -0
  65. package/src/phaser/display/graphics_data_util.js +15 -0
  66. package/src/phaser/display/group.js +227 -0
  67. package/src/phaser/display/image.js +288 -0
  68. package/src/phaser/display/sprite_batch.js +15 -0
  69. package/src/phaser/display/sprite_util.js +250 -0
  70. package/src/phaser/display/text.js +1089 -0
  71. package/src/phaser/display/webgl/abstract_filter.js +25 -0
  72. package/src/phaser/display/webgl/base_texture.js +68 -0
  73. package/src/phaser/display/webgl/blend_manager.js +35 -0
  74. package/src/phaser/display/webgl/earcut.js +662 -0
  75. package/src/phaser/display/webgl/earcut_node.js +28 -0
  76. package/src/phaser/display/webgl/fast_sprite_batch.js +242 -0
  77. package/src/phaser/display/webgl/filter_manager.js +46 -0
  78. package/src/phaser/display/webgl/filter_texture.js +61 -0
  79. package/src/phaser/display/webgl/graphics.js +624 -0
  80. package/src/phaser/display/webgl/graphics_data.js +42 -0
  81. package/src/phaser/display/webgl/mask_manager.js +36 -0
  82. package/src/phaser/display/webgl/render_texture.js +81 -0
  83. package/src/phaser/display/webgl/renderer.js +234 -0
  84. package/src/phaser/display/webgl/shader/complex.js +74 -0
  85. package/src/phaser/display/webgl/shader/fast.js +97 -0
  86. package/src/phaser/display/webgl/shader/normal.js +225 -0
  87. package/src/phaser/display/webgl/shader/primitive.js +72 -0
  88. package/src/phaser/display/webgl/shader/strip.js +77 -0
  89. package/src/phaser/display/webgl/shader_manager.js +89 -0
  90. package/src/phaser/display/webgl/sprite_batch.js +320 -0
  91. package/src/phaser/display/webgl/stencil_manager.js +170 -0
  92. package/src/phaser/display/webgl/texture.js +117 -0
  93. package/src/phaser/display/webgl/texture_util.js +34 -0
  94. package/src/phaser/display/webgl/util.js +78 -0
  95. package/src/phaser/geom/circle.js +186 -0
  96. package/src/phaser/geom/ellipse.js +65 -0
  97. package/src/phaser/geom/line.js +190 -0
  98. package/src/phaser/geom/matrix.js +147 -0
  99. package/src/phaser/geom/point.js +164 -0
  100. package/src/phaser/geom/polygon.js +140 -0
  101. package/src/phaser/geom/rectangle.js +306 -0
  102. package/src/phaser/geom/rounded_rectangle.js +36 -0
  103. package/src/phaser/geom/util/circle.js +122 -0
  104. package/src/phaser/geom/util/ellipse.js +34 -0
  105. package/src/phaser/geom/util/line.js +135 -0
  106. package/src/phaser/geom/util/matrix.js +53 -0
  107. package/src/phaser/geom/util/point.js +296 -0
  108. package/src/phaser/geom/util/polygon.js +28 -0
  109. package/src/phaser/geom/util/rectangle.js +229 -0
  110. package/src/phaser/geom/util/rounded_rectangle.js +32 -0
  111. package/src/phaser/util/math.js +297 -0
  112. package/src/phaser/util/string.js +32 -0
@@ -0,0 +1,258 @@
1
+ /**
2
+ * @author Andras Csizmadia <andras@vpmedia.hu>
3
+ * @author Richard Davey <rich@photonstorm.com>
4
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
+ */
6
+ import * as MathUtils from '../util/math';
7
+ import { TWEEN_PENDING, TWEEN_RUNNING, TWEEN_COMPLETE, TWEEN_LOOPED } from './const';
8
+
9
+ export default class {
10
+
11
+ constructor(parent) {
12
+ this.parent = parent;
13
+ this.game = parent.game;
14
+ this.vStart = {};
15
+ this.vStartCache = {};
16
+ this.vEnd = {};
17
+ this.vEndCache = {};
18
+ this.duration = 1000;
19
+ this.percent = 0;
20
+ this.value = 0;
21
+ this.repeatCounter = 0;
22
+ this.repeatDelay = 0;
23
+ this.repeatTotal = 0;
24
+ this.interpolate = false;
25
+ this.yoyo = false;
26
+ this.yoyoDelay = 0;
27
+ this.inReverse = false;
28
+ this.delay = 0;
29
+ this.dt = 0;
30
+ this.startTime = null;
31
+ this.easingFunction = 'Linear';
32
+ this.interpolationFunction = MathUtils.linearInterpolation;
33
+ this.interpolationContext = MathUtils;
34
+ this.isRunning = false;
35
+ this.isFrom = false;
36
+ }
37
+
38
+ to(properties, duration, ease, delay, repeat, yoyo) {
39
+ this.vEnd = properties;
40
+ this.duration = duration;
41
+ this.easingFunction = ease;
42
+ this.delay = delay;
43
+ this.repeatTotal = repeat;
44
+ this.yoyo = yoyo;
45
+ this.isFrom = false;
46
+ return this;
47
+ }
48
+
49
+ from(properties, duration, ease, delay, repeat, yoyo) {
50
+ this.vEnd = properties;
51
+ this.duration = duration;
52
+ this.easingFunction = ease;
53
+ this.delay = delay;
54
+ this.repeatTotal = repeat;
55
+ this.yoyo = yoyo;
56
+ this.isFrom = true;
57
+ return this;
58
+ }
59
+
60
+ start() {
61
+ this.startTime = this.game.time.time + this.delay;
62
+ if (this.parent.reverse) {
63
+ this.dt = this.duration;
64
+ } else {
65
+ this.dt = 0;
66
+ }
67
+ if (this.delay > 0) {
68
+ this.isRunning = false;
69
+ } else {
70
+ this.isRunning = true;
71
+ }
72
+ if (this.isFrom) {
73
+ // Reverse them all and instant set them
74
+ const keys = Object.keys(this.vStartCache);
75
+ for (let k = 0; k < keys.length; k += 1) {
76
+ const property = keys[k];
77
+ this.vStart[property] = this.vEndCache[property];
78
+ this.vEnd[property] = this.vStartCache[property];
79
+ this.parent.target[property] = this.vStart[property];
80
+ }
81
+ }
82
+ this.value = 0;
83
+ this.yoyoCounter = 0;
84
+ this.repeatCounter = this.repeatTotal;
85
+ return this;
86
+ }
87
+
88
+ loadValues() {
89
+ const keys = Object.keys(this.parent.properties);
90
+ for (let k = 0; k < keys.length; k += 1) {
91
+ const property = keys[k];
92
+ // Load the property from the parent object
93
+ this.vStart[property] = this.parent.properties[property];
94
+ // Check if an Array was provided as property value
95
+ if (Array.isArray(this.vEnd[property])) {
96
+ if (this.vEnd[property].length === 0) {
97
+ // pass
98
+ // TODO: this was continue;
99
+ } else if (this.percent === 0) {
100
+ // Put the start value at the beginning of the array
101
+ // but we only want to do this once, if the Tween hasn't run before
102
+ this.vEnd[property] = [this.vStart[property]].concat(this.vEnd[property]);
103
+ }
104
+ }
105
+ if (typeof this.vEnd[property] !== 'undefined') {
106
+ if (typeof this.vEnd[property] === 'string') {
107
+ // Parses relative end values with start as base (e.g.: +10, -3)
108
+ this.vEnd[property] = this.vStart[property] + parseFloat(this.vEnd[property], 10);
109
+ }
110
+ this.parent.properties[property] = this.vEnd[property];
111
+ } else {
112
+ // Null tween
113
+ this.vEnd[property] = this.vStart[property];
114
+ }
115
+ this.vStartCache[property] = this.vStart[property];
116
+ this.vEndCache[property] = this.vEnd[property];
117
+ }
118
+ return this;
119
+ }
120
+
121
+ update(time) {
122
+ if (!this.isRunning) {
123
+ if (time >= this.startTime) {
124
+ this.isRunning = true;
125
+ } else {
126
+ return TWEEN_PENDING;
127
+ }
128
+ } else if (time < this.startTime) {
129
+ // Is Running, but is waiting to repeat
130
+ return TWEEN_RUNNING;
131
+ }
132
+ const ms = (this.parent.frameBased) ? this.game.time.physicsElapsedMS : this.game.time.elapsedMS;
133
+ if (this.parent.reverse) {
134
+ this.dt -= ms * this.parent.timeScale;
135
+ this.dt = Math.max(this.dt, 0);
136
+ } else {
137
+ this.dt += ms * this.parent.timeScale;
138
+ this.dt = Math.min(this.dt, this.duration);
139
+ }
140
+ this.percent = this.dt / this.duration;
141
+ this.value = this.easingFunction(this.percent);
142
+ const keys = Object.keys(this.vEnd);
143
+ for (let k = 0; k < keys.length; k += 1) {
144
+ const property = keys[k];
145
+ const start = this.vStart[property];
146
+ const end = this.vEnd[property];
147
+ if (Array.isArray(end)) {
148
+ this.parent.target[property] = this.interpolationFunction.call(this.interpolationContext, end, this.value);
149
+ } else {
150
+ this.parent.target[property] = start + ((end - start) * this.value);
151
+ }
152
+ }
153
+ if ((!this.parent.reverse && this.percent === 1) || (this.parent.reverse && this.percent === 0)) {
154
+ return this.repeat();
155
+ }
156
+ return TWEEN_RUNNING;
157
+ }
158
+
159
+ generateData(frameRate) {
160
+ if (this.parent.reverse) {
161
+ this.dt = this.duration;
162
+ } else {
163
+ this.dt = 0;
164
+ }
165
+ let data = [];
166
+ let complete = false;
167
+ const fps = (1 / frameRate) * 1000;
168
+ do {
169
+ if (this.parent.reverse) {
170
+ this.dt -= fps;
171
+ this.dt = Math.max(this.dt, 0);
172
+ } else {
173
+ this.dt += fps;
174
+ this.dt = Math.min(this.dt, this.duration);
175
+ }
176
+ this.percent = this.dt / this.duration;
177
+ this.value = this.easingFunction(this.percent);
178
+ const blob = {};
179
+ const keys = Object.keys(this.vEnd);
180
+ for (let k = 0; k < keys.length; k += 1) {
181
+ const property = keys[k];
182
+ const start = this.vStart[property];
183
+ const end = this.vEnd[property];
184
+ if (Array.isArray(end)) {
185
+ blob[property] = this.interpolationFunction(end, this.value);
186
+ } else {
187
+ blob[property] = start + ((end - start) * this.value);
188
+ }
189
+ }
190
+ data.push(blob);
191
+ if ((!this.parent.reverse && this.percent === 1) || (this.parent.reverse && this.percent === 0)) {
192
+ complete = true;
193
+ }
194
+ } while (!complete);
195
+ if (this.yoyo) {
196
+ const reversed = data.slice();
197
+ reversed.reverse();
198
+ data = data.concat(reversed);
199
+ }
200
+ return data;
201
+ }
202
+
203
+ repeat() {
204
+ // If not a yoyo and repeatCounter = 0 then we're done
205
+ if (this.yoyo) {
206
+ // We're already in reverse mode, which means the yoyo has finished and there's no repeats, so end
207
+ if (this.inReverse && this.repeatCounter === 0) {
208
+ // Restore the properties
209
+ const keys = Object.keys(this.vStartCache);
210
+ for (let k = 0; k < keys.length; k += 1) {
211
+ const property = keys[k];
212
+ this.vStart[property] = this.vStartCache[property];
213
+ this.vEnd[property] = this.vEndCache[property];
214
+ }
215
+ this.inReverse = false;
216
+ return TWEEN_COMPLETE;
217
+ }
218
+ this.inReverse = !this.inReverse;
219
+ } else if (this.repeatCounter === 0) {
220
+ return TWEEN_COMPLETE;
221
+ }
222
+ if (this.inReverse) {
223
+ // If inReverse we're going from vEnd to vStartCache
224
+ const keys = Object.keys(this.vStartCache);
225
+ for (let k = 0; k < keys.length; k += 1) {
226
+ const property = keys[k];
227
+ this.vStart[property] = this.vEndCache[property];
228
+ this.vEnd[property] = this.vStartCache[property];
229
+ }
230
+ } else {
231
+ // If not inReverse we're just repopulating the cache again
232
+ const keys = Object.keys(this.vStartCache);
233
+ for (let k = 0; k < keys.length; k += 1) {
234
+ const property = keys[k];
235
+ this.vStart[property] = this.vStartCache[property];
236
+ this.vEnd[property] = this.vEndCache[property];
237
+ }
238
+ // -1 means repeat forever, otherwise decrement the repeatCounter
239
+ // We only decrement this counter if the tween isn't doing a yoyo, as that doesn't count towards the repeat total
240
+ if (this.repeatCounter > 0) {
241
+ this.repeatCounter -= 1;
242
+ }
243
+ }
244
+ this.startTime = this.game.time.time;
245
+ if (this.yoyo && this.inReverse) {
246
+ this.startTime += this.yoyoDelay;
247
+ } else if (!this.inReverse) {
248
+ this.startTime += this.repeatDelay;
249
+ }
250
+ if (this.parent.reverse) {
251
+ this.dt = this.duration;
252
+ } else {
253
+ this.dt = 0;
254
+ }
255
+ return TWEEN_LOOPED;
256
+ }
257
+
258
+ }
@@ -0,0 +1,341 @@
1
+ /**
2
+ * @author Andras Csizmadia <andras@vpmedia.hu>
3
+ * @author Richard Davey <rich@photonstorm.com>
4
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
+ */
6
+
7
+ /**
8
+ *
9
+ * @param {number} k TBD
10
+ * @returns {number} TBD
11
+ */
12
+ export function LinearNone(k) {
13
+ return k;
14
+ }
15
+
16
+ /**
17
+ *
18
+ * @param {number} k TBD
19
+ * @returns {number} TBD
20
+ */
21
+ export function QuadraticIn(k) {
22
+ return k * k;
23
+ }
24
+
25
+ /**
26
+ *
27
+ * @param {number} k TBD
28
+ * @returns {number} TBD
29
+ */
30
+ export function QuadraticOut(k) {
31
+ return k * (2 - k);
32
+ }
33
+
34
+ /**
35
+ *
36
+ * @param {number} k TBD
37
+ * @returns {number} TBD
38
+ */
39
+ export function QuadraticInOut(k) {
40
+ if ((k *= 2) < 1) return 0.5 * k * k;
41
+ return -0.5 * (--k * (k - 2) - 1);
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @param {number} k TBD
47
+ * @returns {number} TBD
48
+ */
49
+ export function CubicIn(k) {
50
+ return k * k * k;
51
+ }
52
+
53
+ /**
54
+ *
55
+ * @param {number} k TBD
56
+ * @returns {number} TBD
57
+ */
58
+ export function CubicOut(k) {
59
+ return --k * k * k + 1;
60
+ }
61
+
62
+ /**
63
+ *
64
+ * @param {number} k TBD
65
+ * @returns {number} TBD
66
+ */
67
+ export function CubicInOut(k) {
68
+ if ((k *= 2) < 1) return 0.5 * k * k * k;
69
+ return 0.5 * ((k -= 2) * k * k + 2);
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @param {number} k TBD
75
+ * @returns {number} TBD
76
+ */
77
+ export function QuarticIn(k) {
78
+ return k * k * k * k;
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @param {number} k TBD
84
+ * @returns {number} TBD
85
+ */
86
+ export function QuarticOut(k) {
87
+ return 1 - (--k * k * k * k);
88
+ }
89
+
90
+ /**
91
+ *
92
+ * @param {number} k TBD
93
+ * @returns {number} TBD
94
+ */
95
+ export function QuarticInOut(k) {
96
+ if ((k *= 2) < 1) return 0.5 * k * k * k * k;
97
+ return -0.5 * ((k -= 2) * k * k * k - 2);
98
+ }
99
+
100
+ /**
101
+ *
102
+ * @param {number} k TBD
103
+ * @returns {number} TBD
104
+ */
105
+ export function QuinticIn(k) {
106
+ return k * k * k * k * k;
107
+ }
108
+
109
+ /**
110
+ *
111
+ * @param {number} k TBD
112
+ * @returns {number} TBD
113
+ */
114
+ export function QuinticOut(k) {
115
+ return --k * k * k * k * k + 1;
116
+ }
117
+
118
+ /**
119
+ *
120
+ * @param {number} k TBD
121
+ * @returns {number} TBD
122
+ */
123
+ export function QuinticInOut(k) {
124
+ if ((k *= 2) < 1) return 0.5 * k * k * k * k * k;
125
+ return 0.5 * ((k -= 2) * k * k * k * k + 2);
126
+ }
127
+
128
+ /**
129
+ *
130
+ * @param {number} k TBD
131
+ * @returns {number} TBD
132
+ */
133
+ export function SinusoidalIn(k) {
134
+ if (k === 0) return 0;
135
+ if (k === 1) return 1;
136
+ return 1 - Math.cos(k * Math.PI / 2);
137
+ }
138
+
139
+ /**
140
+ *
141
+ * @param {number} k TBD
142
+ * @returns {number} TBD
143
+ */
144
+ export function SinusoidalOut(k) {
145
+ if (k === 0) return 0;
146
+ if (k === 1) return 1;
147
+ return Math.sin(k * Math.PI / 2);
148
+ }
149
+
150
+ /**
151
+ *
152
+ * @param {number} k TBD
153
+ * @returns {number} TBD
154
+ */
155
+ export function SinusoidalInOut(k) {
156
+ if (k === 0) return 0;
157
+ if (k === 1) return 1;
158
+ return 0.5 * (1 - Math.cos(Math.PI * k));
159
+ }
160
+
161
+ /**
162
+ *
163
+ * @param {number} k TBD
164
+ * @returns {number} TBD
165
+ */
166
+ export function ExponentialIn(k) {
167
+ return k === 0 ? 0 : Math.pow(1024, k - 1);
168
+ }
169
+
170
+ /**
171
+ *
172
+ * @param {number} k TBD
173
+ * @returns {number} TBD
174
+ */
175
+ export function ExponentialOut(k) {
176
+ return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
177
+ }
178
+
179
+ /**
180
+ *
181
+ * @param {number} k TBD
182
+ * @returns {number} TBD
183
+ */
184
+ export function ExponentialInOut(k) {
185
+ if (k === 0) return 0;
186
+ if (k === 1) return 1;
187
+ if ((k *= 2) < 1) return 0.5 * Math.pow(1024, k - 1);
188
+ return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
189
+ }
190
+
191
+ /**
192
+ *
193
+ * @param {number} k TBD
194
+ * @returns {number} TBD
195
+ */
196
+ export function CircularIn(k) {
197
+ return 1 - Math.sqrt(1 - k * k);
198
+ }
199
+
200
+ /**
201
+ *
202
+ * @param {number} k TBD
203
+ * @returns {number} TBD
204
+ */
205
+ export function CircularOut(k) {
206
+ return Math.sqrt(1 - (--k * k));
207
+ }
208
+
209
+ /**
210
+ *
211
+ * @param {number} k TBD
212
+ * @returns {number} TBD
213
+ */
214
+ export function CircularInOut(k) {
215
+ if ((k *= 2) < 1) return -0.5 * (Math.sqrt(1 - k * k) - 1);
216
+ return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
217
+ }
218
+
219
+ /**
220
+ *
221
+ * @param {number} k TBD
222
+ * @returns {number} TBD
223
+ */
224
+ export function ElasticIn(k) {
225
+ let s;
226
+ let a = 0.1;
227
+ const p = 0.4;
228
+ if (k === 0) return 0;
229
+ if (k === 1) return 1;
230
+ if (!a || a < 1) {
231
+ a = 1; s = p / 4;
232
+ } else {
233
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
234
+ }
235
+ return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
236
+ }
237
+
238
+ /**
239
+ *
240
+ * @param {number} k TBD
241
+ * @returns {number} TBD
242
+ */
243
+ export function ElasticOut(k) {
244
+ let s;
245
+ let a = 0.1;
246
+ const p = 0.4;
247
+ if (k === 0) return 0;
248
+ if (k === 1) return 1;
249
+ if (!a || a < 1) {
250
+ a = 1; s = p / 4;
251
+ } else {
252
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
253
+ }
254
+ return (a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1);
255
+ }
256
+
257
+ /**
258
+ *
259
+ * @param {number} k TBD
260
+ * @returns {number} TBD
261
+ */
262
+ export function ElasticInOut(k) {
263
+ let s;
264
+ let a = 0.1;
265
+ const p = 0.4;
266
+ if (k === 0) return 0;
267
+ if (k === 1) return 1;
268
+ if (!a || a < 1) {
269
+ a = 1; s = p / 4;
270
+ } else {
271
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
272
+ }
273
+ if ((k *= 2) < 1) return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
274
+ return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
275
+ }
276
+
277
+ /**
278
+ *
279
+ * @param {number} k TBD
280
+ * @returns {number} TBD
281
+ */
282
+ export function BackIn(k) {
283
+ const s = 1.70158;
284
+ return k * k * ((s + 1) * k - s);
285
+ }
286
+
287
+ /**
288
+ *
289
+ * @param {number} k TBD
290
+ * @returns {number} TBD
291
+ */
292
+ export function BackOut(k) {
293
+ const s = 1.70158;
294
+ return --k * k * ((s + 1) * k + s) + 1;
295
+ }
296
+
297
+ /**
298
+ *
299
+ * @param {number} k TBD
300
+ * @returns {number} TBD
301
+ */
302
+ export function BackInOut(k) {
303
+ const s = 1.70158 * 1.525;
304
+ if ((k *= 2) < 1) return 0.5 * (k * k * ((s + 1) * k - s));
305
+ return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
306
+ }
307
+
308
+ /**
309
+ *
310
+ * @param {number} k TBD
311
+ * @returns {number} TBD
312
+ */
313
+ export function BounceOut(k) {
314
+ if (k < (1 / 2.75)) {
315
+ return 7.5625 * k * k;
316
+ } else if (k < (2 / 2.75)) {
317
+ return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
318
+ } else if (k < (2.5 / 2.75)) {
319
+ return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
320
+ }
321
+ return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
322
+ }
323
+
324
+ /**
325
+ *
326
+ * @param {number} k TBD
327
+ * @returns {number} TBD
328
+ */
329
+ export function BounceIn(k) {
330
+ return 1 - BounceOut(1 - k);
331
+ }
332
+
333
+ /**
334
+ *
335
+ * @param {number} k TBD
336
+ * @returns {number} TBD
337
+ */
338
+ export function BounceInOut(k) {
339
+ if (k < 0.5) return BounceIn(k * 2) * 0.5;
340
+ return BounceOut(k * 2 - 1) * 0.5 + 0.5;
341
+ }