Immediate Mode animation extension for Dear ImGui.
You don't need to track any current value, animation start or state.
You just provide your start and end values, as well as the duration in milliseconds and your curve.
Function Signature
void Animate(float aStartValue, float aEndValue, float aDurationMs, float* aValue, ECurve aCurve = ECurve::Linear);
Example: Hover Animation
The animation above is generated by the following code.
static float imgSize = 1.0f;
ImGui::Image(icon, ImVec2(imgSize, imgSize));
if (ImGui::IsItemHovered)
{
ImGui::Animate(1.0f, 1.1f, 500, &imgSize, ECurve::InCubic);
}
else
{
ImGui::Animate(1.1f, 1.0, 500, &imgSize, ECurve::OutCubic);
}
The following easing functions are currently implemented.
enum class ECurve
{
Linear,
InSine,
OutSine,
InOutSine,
InQuad,
OutQuad,
InOutQuad,
InCubic,
OutCubic,
InOutCubic,
InQuart,
OutQuart,
InOutQuart,
InQuint,
OutQuint,
InOutQuint,
InExpo,
OutExpo,
InOutExpo,
InCirc,
OutCirc,
InOutCirc
};