module Reanimate.Ease
( Signal
, constantS
, fromToS
, reverseS
, curveS
, powerS
, bellS
, oscillateS
, cubicBezierS
) where
type Signal = Double -> Double
constantS :: Double -> Signal
constantS :: Double -> Signal
constantS = Double -> Signal
forall a b. a -> b -> a
const
fromToS :: Double -> Double -> Signal
fromToS :: Double -> Double -> Signal
fromToS Double
from Double
to Double
t = Double
from Double -> Signal
forall a. Num a => a -> a -> a
+ (Double
toDouble -> Signal
forall a. Num a => a -> a -> a
-Double
from)Double -> Signal
forall a. Num a => a -> a -> a
*Double
t
reverseS :: Signal
reverseS :: Signal
reverseS Double
t = Double
1Double -> Signal
forall a. Num a => a -> a -> a
-Double
t
curveS :: Double -> Signal
curveS :: Double -> Signal
curveS Double
steepness Double
s =
if Double
s Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
< Double
0.5
then Double
0.5 Double -> Signal
forall a. Num a => a -> a -> a
* (Double
2Double -> Signal
forall a. Num a => a -> a -> a
*Double
s)Double -> Signal
forall a. Floating a => a -> a -> a
**Double
steepness
else Double
1Double -> Signal
forall a. Num a => a -> a -> a
-Double
0.5 Double -> Signal
forall a. Num a => a -> a -> a
* (Double
2 Double -> Signal
forall a. Num a => a -> a -> a
- Double
2Double -> Signal
forall a. Num a => a -> a -> a
*Double
s)Double -> Signal
forall a. Floating a => a -> a -> a
**Double
steepness
powerS :: Double -> Signal
powerS :: Double -> Signal
powerS Double
steepness Double
s = Double
sDouble -> Signal
forall a. Floating a => a -> a -> a
**Double
steepness
oscillateS :: Signal
oscillateS :: Signal
oscillateS Double
t =
if Double
t Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
< Double
1Double -> Signal
forall a. Fractional a => a -> a -> a
/Double
2
then Double
tDouble -> Signal
forall a. Num a => a -> a -> a
*Double
2
else Double
2Double -> Signal
forall a. Num a => a -> a -> a
-Double
tDouble -> Signal
forall a. Num a => a -> a -> a
*Double
2
bellS :: Double -> Signal
bellS :: Double -> Signal
bellS Double
steepness = Double -> Signal
curveS Double
steepness Signal -> Signal -> Signal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Signal
oscillateS
cubicBezierS :: (Double, Double, Double, Double) -> Signal
cubicBezierS :: (Double, Double, Double, Double) -> Signal
cubicBezierS (Double
x1, Double
x2, Double
x3, Double
x4) Double
s =
let ms :: Double
ms = Double
1Double -> Signal
forall a. Num a => a -> a -> a
-Double
s
in Double
x1Double -> Signal
forall a. Num a => a -> a -> a
*Double
msDouble -> Int -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^(Int
3::Int) Double -> Signal
forall a. Num a => a -> a -> a
+ Double
3Double -> Signal
forall a. Num a => a -> a -> a
*Double
x2Double -> Signal
forall a. Num a => a -> a -> a
*Double
msDouble -> Int -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^(Int
2::Int)Double -> Signal
forall a. Num a => a -> a -> a
*Double
s Double -> Signal
forall a. Num a => a -> a -> a
+ Double
3Double -> Signal
forall a. Num a => a -> a -> a
*Double
x3Double -> Signal
forall a. Num a => a -> a -> a
*Double
msDouble -> Signal
forall a. Num a => a -> a -> a
*Double
sDouble -> Int -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^(Int
2::Int) Double -> Signal
forall a. Num a => a -> a -> a
+ Double
x4Double -> Signal
forall a. Num a => a -> a -> a
*Double
sDouble -> Int -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^(Int
3::Int)