Syntax
Value.d = Transition_EaseInBounce(t.d, b.d, c.d, d.d)Description
Calculates an intermediate value using a "bounce" easing curve that starts with bounces and settles towards the end (ease-in). It's the reverse of the Transition_EaseOutBounce() effect.
Parameters
t.d
The current elapsed time of the animation in milliseconds.
b.d
The starting value of the property being animated.
c.d
The total change in value (target value - starting value).
d.d
The total duration of the animation in milliseconds.
Return Value
Returns the interpolated value (Double) at the current time `t` according to the ease-in bounce curve.
Remarks
This effect simulates an object bouncing at the beginning of its movement before coming to rest at the target value.
Example
IncludeFile "ProGUI_PB.pbi"
Structure MyAnimData
TargetValue.d
StartValue.d
y.d ; Animate Y position
EndStructure
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData.MyAnimData)
DrawClear(RGB(200, 200, 200), 1) ; Grey background
; Draw a box whose Y position is animated
DrawBox(( *EventData\width / 2) - 25, *UserData\y, 50, 50, RGB(255, 0, 0))
EndProcedure
Procedure AnimateHandler(Window, EventType, *EventData.PG_EventAnimate, *UserData.MyAnimData)
Select *EventData\state
Case #PG_Event_Animate_Start
Debug "Animation started."
Case #PG_Event_Animate_Update
; Calculate intermediate value using the ease-in-bounce transition
*UserData\y = Transition_EaseInBounce(*EventData\currentTime, *UserData\StartValue, *UserData\TargetValue - *UserData\StartValue, *EventData\duration)
WindowRedraw(Window)
Case #PG_Event_Animate_End
Debug "Animation ended"
; Ensure final value is set exactly
*UserData\y = *UserData\TargetValue
WindowRedraw(Window)
EndSelect
EndProcedure
StartProGUI()
MyWindow = CreateWindow(0, 0, 300, 250, "Transition_EaseInBounce Example")
If MyWindow
; Setup data for animation
*AnimData.MyAnimData = AllocateStructure(MyAnimData)
*AnimData\StartValue = 10
*AnimData\TargetValue = 180 ; Target Y position
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler(), *AnimData)
AddEventHandler(MyWindow, #PG_Event_Animate, @AnimateHandler(), *AnimData)
; Start a 2-second animation
AnimID = StartAnimation(MyWindow, #PG_Any, 2000)
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow
StopAnimation(MyWindow, AnimID)
FreeStructure(*AnimData)
EndIf
StopProGUI()See Also
Transition_EaseOutBounce, Transition_EaseInOutBounce, Transition_EaseOutInBounce, StartAnimation
Supported OS
Windows, Linux