52 lines
1014 B
Plaintext
52 lines
1014 B
Plaintext
declare function Lerp{
|
|
parameter a.
|
|
parameter b.
|
|
parameter t.
|
|
return a + (b - a) * t.
|
|
}
|
|
|
|
declare function Map{
|
|
parameter value.
|
|
parameter low1.
|
|
parameter high1.
|
|
parameter low2.
|
|
parameter high2.
|
|
return low2 + (high2 - low2) * ((value - low1) / (high1 - low1)).
|
|
}
|
|
|
|
declare function ApproximateExp {
|
|
parameter x.
|
|
local result is 1.0.
|
|
local xPower is 1.0.
|
|
local nFact is 1.0.
|
|
|
|
// Loop 4 times (for terms 1 through 4, total 5 terms)
|
|
from { local n is 1.} until n = 5 step {set n to n + 1.} do {
|
|
SET xPower TO xPower * x.
|
|
SET nFact TO nFact * n.
|
|
SET result TO result + (xPower / nFact).
|
|
}
|
|
RETURN result.
|
|
}
|
|
|
|
declare function EaseOutExpo {
|
|
parameter x.
|
|
parameter p is 10.
|
|
if x = 1 {
|
|
return 1.
|
|
} else{
|
|
return 1 - (2 ^ (-p * x)).
|
|
}
|
|
}
|
|
|
|
declare function EaseOutCirc{
|
|
parameter x.
|
|
return sqrt(1 - (x - 1)^2).
|
|
}
|
|
|
|
declare function EaseOutExp{
|
|
parameter x.
|
|
parameter n is 2.0.
|
|
return x ^ (2.0 * n).
|
|
}
|