ImAnim:为ImGui应用程序提供现代动画功能
ImAnim: Modern animation capabilities to ImGui applications

原始链接: https://github.com/soufianekhiat/ImAnim

## ImAnim:为 Dear ImGui 设计的现代动画引擎 ImAnim 是一个轻量级的动画引擎,专为 Dear ImGui 设计,能够以最少的代码和零依赖(除了 Dear ImGui 本身)实现流畅的 UI 动画。它无缝地运行在 ImGui 的即时模式范式中。 主要特性包括:**缓动**,用于动画化各种数据类型(浮点数、向量、颜色等),具有可定制的缓动函数和策略;**片段**,用于基于时间线的动画,具有关键帧和循环;**路径**,使用贝塞尔曲线;以及 **程序化效果**,如振荡和噪声。 ImAnim 拥有超过 30 个缓动函数、感知色彩混合以及响应式、锚点相关的动画。它易于集成,只需将两个文件添加到您的项目中,并在每一帧调用 `iam_update_begin_frame()` 即可。 提供全面的文档、功能丰富的演示以及交互式工具(缓动可视化工具、贝塞尔编辑器)。ImAnim 是开源的(MIT 许可证),并积极开发,通过 Patreon 提供社区支持。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 ImAnim: 将现代动画能力带到 ImGui 应用 (github.com/soufianekhiat) 17 分,klaussilveira 发表于 48 分钟前 | 隐藏 | 过去 | 收藏 | 2 条评论 ryanmcbride 发表于 32 分钟前 | 下一个 [–] 哇,这个时间点对我来说太棒了,谢谢,这正是我需要的类型,而且完全符合我的审美。 erichocean 发表于 20 分钟前 | 上一个 [–] 如果作者在场,你能简单介绍一下这个是如何实现的吗? 我自己也有一个即时模式 UI 框架,很好奇你是怎么做的。 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

Hero

Animation Engine for Dear ImGui

ImAnim brings modern animation capabilities to ImGui applications. Write smooth, UI animations with minimal code.

// Animate anything in one line
float alpha = iam_tween_float(id, channel, hovered ? 1.0f : 0.5f, 0.3f, ease, policy, dt);
  • Immediate-mode friendly - Works naturally with ImGui's paradigm
  • Zero dependencies - Only requires Dear ImGui
  • Large easing collection - 30+ easing functions including spring physics
  • Perceptual color blending - OKLAB and OKLCH
  • Responsive layouts - Anchor-relative animations that survive window resizing
Category Capabilities
Tweens Float, Vec2, Vec4, Int, Color with crossfade/cut/queue policies
Clips Timeline keyframes, looping, callbacks, chaining, stagger
Easing Quad to Bounce presets, cubic-bezier, steps, spring physics
Paths Bezier curves, Catmull-Rom splines, text along paths
Procedural Oscillators, shake, wiggle, Perlin/Simplex noise
Extras Style interpolation, scroll animation, debug inspector
#include "im_anim.h"

// Each frame
iam_update_begin_frame();
iam_clip_update(dt);

// Hover animation
bool hovered = ImGui::IsItemHovered();
float scale = iam_tween_float(
    ImGui::GetID("button"), ImHashStr("scale"),
    hovered ? 1.1f : 1.0f,
    0.15f,
    iam_ease_preset(iam_ease_out_back),
    iam_policy_crossfade,
    dt
);

Add two files to your project:

src/im_anim.h
src/im_anim.cpp

That's it. No build system changes, no external dependencies.

Full documentation in the docs/ folder:

The demo/ folder contains a comprehensive demo showcasing all features:

  • Interactive easing curve visualizer
  • Cubic bezier editor
  • Spring physics playground
  • All animation types with live controls
  • Performance benchmarks

ImGui Integration


ImGui Integration

Development is supported through Patreon:

Patreon

MIT License - see LICENSE for details.


Made for the Dear ImGui community

联系我们 contact @ memedata.com