1개월 전 · Jul 6, 2026 8:53 PM
Fluid tab animation system using exponential easing in C++:
CPP
float Lerp(float a, float b, float t) { return a + (b - a) * t; }
void DrawAnimatedTabBar(int& activeTab, const std::vector<const char*>& tabs) {
static float indicatorPos = 0.0f;
static float indicatorWidth = 80.0f;
float targetPos = activeTab * 90.0f;
indicatorPos = Lerp(indicatorPos, targetPos, ImGui::GetIO().DeltaTime * 12.0f);
ImDrawList* dl = ImGui::GetWindowDrawList();
ImVec2 p = ImGui::GetCursorScreenPos();
// Draw animated glow indicator line
dl->AddRectFilled(ImVec2(p.x + indicatorPos, p.y + 35.0f), ImVec2(p.x + indicatorPos + indicatorWidth, p.y + 38.0f), IM_COL32(0, 200, 255, 255), 2.0f);
for (int i = 0; i < (int)tabs.size(); i++) {
if (ImGui::Button(tabs[i], ImVec2(85, 30))) activeTab = i;
ImGui::SameLine();
}
ImGui::NewLine();
}