@vpmedia/phaser 1.0.1 → 1.0.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.
Files changed (107) hide show
  1. package/dist/phaser.cjs.LICENSE.txt +1 -1
  2. package/dist/phaser.js.LICENSE.txt +1 -1
  3. package/package.json +2 -3
  4. package/src/index.js +99 -0
  5. package/src/phaser/core/animation.js +355 -0
  6. package/src/phaser/core/animation_manager.js +238 -0
  7. package/src/phaser/core/animation_parser.js +130 -0
  8. package/src/phaser/core/array_set.js +108 -0
  9. package/src/phaser/core/cache.js +558 -0
  10. package/src/phaser/core/const.js +106 -0
  11. package/src/phaser/core/device.js +67 -0
  12. package/src/phaser/core/device_util.js +386 -0
  13. package/src/phaser/core/dom.js +207 -0
  14. package/src/phaser/core/event_manager.js +243 -0
  15. package/src/phaser/core/factory.js +74 -0
  16. package/src/phaser/core/frame.js +75 -0
  17. package/src/phaser/core/frame_data.js +84 -0
  18. package/src/phaser/core/frame_util.js +31 -0
  19. package/src/phaser/core/game.js +412 -0
  20. package/src/phaser/core/input.js +401 -0
  21. package/src/phaser/core/input_button.js +102 -0
  22. package/src/phaser/core/input_handler.js +687 -0
  23. package/src/phaser/core/input_mouse.js +289 -0
  24. package/src/phaser/core/input_mspointer.js +197 -0
  25. package/src/phaser/core/input_pointer.js +427 -0
  26. package/src/phaser/core/input_touch.js +157 -0
  27. package/src/phaser/core/loader.js +946 -0
  28. package/src/phaser/core/loader_parser.js +105 -0
  29. package/src/phaser/core/raf.js +46 -0
  30. package/src/phaser/core/raf_fb.js +75 -0
  31. package/src/phaser/core/raf_to.js +34 -0
  32. package/src/phaser/core/scale_manager.js +806 -0
  33. package/src/phaser/core/scene.js +66 -0
  34. package/src/phaser/core/scene_manager.js +310 -0
  35. package/src/phaser/core/signal.js +175 -0
  36. package/src/phaser/core/signal_binding.js +69 -0
  37. package/src/phaser/core/sound.js +538 -0
  38. package/src/phaser/core/sound_manager.js +365 -0
  39. package/src/phaser/core/stage.js +108 -0
  40. package/src/phaser/core/time.js +203 -0
  41. package/src/phaser/core/timer.js +276 -0
  42. package/src/phaser/core/timer_event.js +21 -0
  43. package/src/phaser/core/tween.js +329 -0
  44. package/src/phaser/core/tween_data.js +258 -0
  45. package/src/phaser/core/tween_easing.js +316 -0
  46. package/src/phaser/core/tween_manager.js +185 -0
  47. package/src/phaser/core/world.js +18 -0
  48. package/src/phaser/display/bitmap_text.js +322 -0
  49. package/src/phaser/display/button.js +194 -0
  50. package/src/phaser/display/canvas/buffer.js +36 -0
  51. package/src/phaser/display/canvas/graphics.js +227 -0
  52. package/src/phaser/display/canvas/masker.js +39 -0
  53. package/src/phaser/display/canvas/pool.js +121 -0
  54. package/src/phaser/display/canvas/renderer.js +123 -0
  55. package/src/phaser/display/canvas/tinter.js +141 -0
  56. package/src/phaser/display/canvas/util.js +151 -0
  57. package/src/phaser/display/display_object.js +597 -0
  58. package/src/phaser/display/graphics.js +723 -0
  59. package/src/phaser/display/graphics_data.js +27 -0
  60. package/src/phaser/display/graphics_data_util.js +14 -0
  61. package/src/phaser/display/group.js +227 -0
  62. package/src/phaser/display/image.js +288 -0
  63. package/src/phaser/display/sprite_batch.js +15 -0
  64. package/src/phaser/display/sprite_util.js +248 -0
  65. package/src/phaser/display/text.js +1089 -0
  66. package/src/phaser/display/webgl/abstract_filter.js +25 -0
  67. package/src/phaser/display/webgl/base_texture.js +68 -0
  68. package/src/phaser/display/webgl/blend_manager.js +35 -0
  69. package/src/phaser/display/webgl/earcut.js +647 -0
  70. package/src/phaser/display/webgl/earcut_node.js +28 -0
  71. package/src/phaser/display/webgl/fast_sprite_batch.js +242 -0
  72. package/src/phaser/display/webgl/filter_manager.js +46 -0
  73. package/src/phaser/display/webgl/filter_texture.js +61 -0
  74. package/src/phaser/display/webgl/graphics.js +618 -0
  75. package/src/phaser/display/webgl/graphics_data.js +42 -0
  76. package/src/phaser/display/webgl/mask_manager.js +36 -0
  77. package/src/phaser/display/webgl/render_texture.js +81 -0
  78. package/src/phaser/display/webgl/renderer.js +234 -0
  79. package/src/phaser/display/webgl/shader/complex.js +74 -0
  80. package/src/phaser/display/webgl/shader/fast.js +97 -0
  81. package/src/phaser/display/webgl/shader/normal.js +225 -0
  82. package/src/phaser/display/webgl/shader/primitive.js +72 -0
  83. package/src/phaser/display/webgl/shader/strip.js +77 -0
  84. package/src/phaser/display/webgl/shader_manager.js +89 -0
  85. package/src/phaser/display/webgl/sprite_batch.js +320 -0
  86. package/src/phaser/display/webgl/stencil_manager.js +170 -0
  87. package/src/phaser/display/webgl/texture.js +117 -0
  88. package/src/phaser/display/webgl/texture_util.js +32 -0
  89. package/src/phaser/display/webgl/util.js +74 -0
  90. package/src/phaser/geom/circle.js +186 -0
  91. package/src/phaser/geom/ellipse.js +65 -0
  92. package/src/phaser/geom/line.js +190 -0
  93. package/src/phaser/geom/matrix.js +147 -0
  94. package/src/phaser/geom/point.js +164 -0
  95. package/src/phaser/geom/polygon.js +141 -0
  96. package/src/phaser/geom/rectangle.js +306 -0
  97. package/src/phaser/geom/rounded_rectangle.js +36 -0
  98. package/src/phaser/geom/util/circle.js +115 -0
  99. package/src/phaser/geom/util/ellipse.js +30 -0
  100. package/src/phaser/geom/util/line.js +130 -0
  101. package/src/phaser/geom/util/matrix.js +48 -0
  102. package/src/phaser/geom/util/point.js +276 -0
  103. package/src/phaser/geom/util/polygon.js +24 -0
  104. package/src/phaser/geom/util/rectangle.js +212 -0
  105. package/src/phaser/geom/util/rounded_rectangle.js +28 -0
  106. package/src/phaser/util/math.js +279 -0
  107. package/src/phaser/util/string.js +26 -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,316 @@
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
+ /* eslint-disable no-cond-assign */
7
+ /* eslint-disable no-return-assign */
8
+ /* eslint-disable no-restricted-properties */
9
+ /* eslint-disable no-plusplus */
10
+
11
+ // TODO fix eslint
12
+
13
+ /**
14
+ *
15
+ * @param k
16
+ */
17
+ export function LinearNone(k) {
18
+ return k;
19
+ }
20
+
21
+ /**
22
+ *
23
+ * @param k
24
+ */
25
+ export function QuadraticIn(k) {
26
+ return k * k;
27
+ }
28
+
29
+ /**
30
+ *
31
+ * @param k
32
+ */
33
+ export function QuadraticOut(k) {
34
+ return k * (2 - k);
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @param k
40
+ */
41
+ export function QuadraticInOut(k) {
42
+ if ((k *= 2) < 1) return 0.5 * k * k;
43
+ return -0.5 * (--k * (k - 2) - 1);
44
+ }
45
+
46
+ /**
47
+ *
48
+ * @param k
49
+ */
50
+ export function CubicIn(k) {
51
+ return k * k * k;
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @param k
57
+ */
58
+ export function CubicOut(k) {
59
+ return --k * k * k + 1;
60
+ }
61
+
62
+ /**
63
+ *
64
+ * @param k
65
+ */
66
+ export function CubicInOut(k) {
67
+ if ((k *= 2) < 1) return 0.5 * k * k * k;
68
+ return 0.5 * ((k -= 2) * k * k + 2);
69
+ }
70
+
71
+ /**
72
+ *
73
+ * @param k
74
+ */
75
+ export function QuarticIn(k) {
76
+ return k * k * k * k;
77
+ }
78
+
79
+ /**
80
+ *
81
+ * @param k
82
+ */
83
+ export function QuarticOut(k) {
84
+ return 1 - (--k * k * k * k);
85
+ }
86
+
87
+ /**
88
+ *
89
+ * @param k
90
+ */
91
+ export function QuarticInOut(k) {
92
+ if ((k *= 2) < 1) return 0.5 * k * k * k * k;
93
+ return -0.5 * ((k -= 2) * k * k * k - 2);
94
+ }
95
+
96
+ /**
97
+ *
98
+ * @param k
99
+ */
100
+ export function QuinticIn(k) {
101
+ return k * k * k * k * k;
102
+ }
103
+
104
+ /**
105
+ *
106
+ * @param k
107
+ */
108
+ export function QuinticOut(k) {
109
+ return --k * k * k * k * k + 1;
110
+ }
111
+
112
+ /**
113
+ *
114
+ * @param k
115
+ */
116
+ export function QuinticInOut(k) {
117
+ if ((k *= 2) < 1) return 0.5 * k * k * k * k * k;
118
+ return 0.5 * ((k -= 2) * k * k * k * k + 2);
119
+ }
120
+
121
+ /**
122
+ *
123
+ * @param k
124
+ */
125
+ export function SinusoidalIn(k) {
126
+ if (k === 0) return 0;
127
+ if (k === 1) return 1;
128
+ return 1 - Math.cos(k * Math.PI / 2);
129
+ }
130
+
131
+ /**
132
+ *
133
+ * @param k
134
+ */
135
+ export function SinusoidalOut(k) {
136
+ if (k === 0) return 0;
137
+ if (k === 1) return 1;
138
+ return Math.sin(k * Math.PI / 2);
139
+ }
140
+
141
+ /**
142
+ *
143
+ * @param k
144
+ */
145
+ export function SinusoidalInOut(k) {
146
+ if (k === 0) return 0;
147
+ if (k === 1) return 1;
148
+ return 0.5 * (1 - Math.cos(Math.PI * k));
149
+ }
150
+
151
+ /**
152
+ *
153
+ * @param k
154
+ */
155
+ export function ExponentialIn(k) {
156
+ return k === 0 ? 0 : Math.pow(1024, k - 1);
157
+ }
158
+
159
+ /**
160
+ *
161
+ * @param k
162
+ */
163
+ export function ExponentialOut(k) {
164
+ return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
165
+ }
166
+
167
+ /**
168
+ *
169
+ * @param k
170
+ */
171
+ export function ExponentialInOut(k) {
172
+ if (k === 0) return 0;
173
+ if (k === 1) return 1;
174
+ if ((k *= 2) < 1) return 0.5 * Math.pow(1024, k - 1);
175
+ return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
176
+ }
177
+
178
+ /**
179
+ *
180
+ * @param k
181
+ */
182
+ export function CircularIn(k) {
183
+ return 1 - Math.sqrt(1 - k * k);
184
+ }
185
+
186
+ /**
187
+ *
188
+ * @param k
189
+ */
190
+ export function CircularOut(k) {
191
+ return Math.sqrt(1 - (--k * k));
192
+ }
193
+
194
+ /**
195
+ *
196
+ * @param k
197
+ */
198
+ export function CircularInOut(k) {
199
+ if ((k *= 2) < 1) return -0.5 * (Math.sqrt(1 - k * k) - 1);
200
+ return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
201
+ }
202
+
203
+ /**
204
+ *
205
+ * @param k
206
+ */
207
+ export function ElasticIn(k) {
208
+ let s;
209
+ let a = 0.1;
210
+ const p = 0.4;
211
+ if (k === 0) return 0;
212
+ if (k === 1) return 1;
213
+ if (!a || a < 1) {
214
+ a = 1; s = p / 4;
215
+ } else {
216
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
217
+ }
218
+ return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
219
+ }
220
+
221
+ /**
222
+ *
223
+ * @param k
224
+ */
225
+ export function ElasticOut(k) {
226
+ let s;
227
+ let a = 0.1;
228
+ const p = 0.4;
229
+ if (k === 0) return 0;
230
+ if (k === 1) return 1;
231
+ if (!a || a < 1) {
232
+ a = 1; s = p / 4;
233
+ } else {
234
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
235
+ }
236
+ return (a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1);
237
+ }
238
+
239
+ /**
240
+ *
241
+ * @param k
242
+ */
243
+ export function ElasticInOut(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
+ if ((k *= 2) < 1) return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
255
+ return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
256
+ }
257
+
258
+ /**
259
+ *
260
+ * @param k
261
+ */
262
+ export function BackIn(k) {
263
+ const s = 1.70158;
264
+ return k * k * ((s + 1) * k - s);
265
+ }
266
+
267
+ /**
268
+ *
269
+ * @param k
270
+ */
271
+ export function BackOut(k) {
272
+ const s = 1.70158;
273
+ return --k * k * ((s + 1) * k + s) + 1;
274
+ }
275
+
276
+ /**
277
+ *
278
+ * @param k
279
+ */
280
+ export function BackInOut(k) {
281
+ const s = 1.70158 * 1.525;
282
+ if ((k *= 2) < 1) return 0.5 * (k * k * ((s + 1) * k - s));
283
+ return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
284
+ }
285
+
286
+ /**
287
+ *
288
+ * @param k
289
+ */
290
+ export function BounceOut(k) {
291
+ if (k < (1 / 2.75)) {
292
+ return 7.5625 * k * k;
293
+ } else if (k < (2 / 2.75)) {
294
+ return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
295
+ } else if (k < (2.5 / 2.75)) {
296
+ return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
297
+ }
298
+ return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
299
+ }
300
+
301
+ /**
302
+ *
303
+ * @param k
304
+ */
305
+ export function BounceIn(k) {
306
+ return 1 - BounceOut(1 - k);
307
+ }
308
+
309
+ /**
310
+ *
311
+ * @param k
312
+ */
313
+ export function BounceInOut(k) {
314
+ if (k < 0.5) return BounceIn(k * 2) * 0.5;
315
+ return BounceOut(k * 2 - 1) * 0.5 + 0.5;
316
+ }