forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIn.js
More file actions
49 lines (44 loc) · 1.08 KB
/
Copy pathIn.js
File metadata and controls
49 lines (44 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Elastic ease-in.
*
* @function Phaser.Math.Easing.Elastic.In
* @since 3.0.0
*
* @param {number} v - The value to be tweened.
* @param {number} [amplitude=0.1] - The amplitude of the elastic ease.
* @param {number} [period=0.1] - [description]
*
* @return {number} The tweened value.
*/
var In = function (v, amplitude, period)
{
if (amplitude === undefined) { amplitude = 0.1; }
if (period === undefined) { period = 0.1; }
if (v === 0)
{
return 0;
}
else if (v === 1)
{
return 1;
}
else
{
var s = period / 4;
if (amplitude < 1)
{
amplitude = 1;
}
else
{
s = period * Math.asin(1 / amplitude) / (2 * Math.PI);
}
return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period));
}
};
module.exports = In;