Android Code Snippet Animation easing functions

After having seen the first post of this tread: My favourite animation trick: exponential smoothing.
I decided to make a B4XPages project for the different easing functions and posted it there.
The source of the equations comes from this site: Easing Equations
Then, I was suggested to post it here because the other thread is in the Chit chat forum.
I did not remember that these equations were already converted to B4X by @epiCode in the thread Easing Functions.

I have used this kind of animation in the xRotaryKnob library, but inspired by a code from Erel in the Gauges thread.

With the CSpline and CBezier easings you can move the green and red handles to modify the curves.
With the CSpline easing you can do some 'exotic' easings.

To use only one equation you can change it in the AnimateTo routine.
The commented line is specific for CubicTimeEaseInOut.
These two lines are also not needed:
DrawMovingDot(DateTime.Now - BeginTime, Duration)

    Private CurrentPosition As Int
    Private BeginTime As Long = DateTime.Now
    CurrentPosition = MoveTo
    Dim tempValueA As Float
    Do While DateTime.Now < BeginTime + Duration
        tempValueA = CallAnimation(DateTime.Now - BeginTime, MoveFrom, MoveTo - MoveFrom, Duration)
'        tempValueA = CubicTimeEaseInOut(DateTime.Now - BeginTime, MoveFrom, MoveTo - MoveFrom, Duration)
        If MoveTo <> CurrentPosition Then Return 'will happen if another update has started
        DrawMovingDot(DateTime.Now - BeginTime, Duration)



    20 KB · Views: 45
Last edited:


Licensed User
Longtime User
A few years ago I researched how to make animations in my applications.
Here are some other tutorials that will be of interest to some.


online tool