Expand description
egui-text-animation
provides simple text animation utilities for the egui library.
This library offers the TextAnimator
struct to create various text animations. It’s designed to be
easy to integrate into your existing egui applications. The core of the library is the
TextAnimator
struct, which manages the state of the animation, and the AnimationType
enum,
which determines the type of animation to perform.
§Features
- Fade-in Animation: Animate text to gradually appear, character by character. See
AnimationType::FadeIn
. - Typewriter Animation: Animate text to appear as if it’s being typed. See
AnimationType::Typewriter
. - Hacker Animation: Animate text to appear as if it’s being decoded. See
AnimationType::Hacker
. - Customizable Speed: Control the speed of the animation with
TextAnimator::set_speed
. - Easy Integration: Simply create a
TextAnimator
, callTextAnimator::process_animation
each frame, and then render withTextAnimator::render
. - Automatic Repainting: Call
ctx.request_repaint()
inside your update loop to ensure smooth animation. - Animation Control: You can check if the animation is finished with
TextAnimator::is_animation_finished
and reset it withTextAnimator::reset
.
§Animation Types
The AnimationType
enum provides the following animation types:
AnimationType::FadeIn
: Characters gradually fade in from transparent to fully opaque.AnimationType::Typewriter
: Characters appear one by one, simulating a typewriter effect.AnimationType::Hacker
: Characters cycle through random characters before settling on the final character.
§Notes
- The
unstable_dt
value fromctx.input(|i| i.unstable_dt)
is used for frame-independent animation timing. This ensures the animation runs at the correct speed regardless of the application’s frame rate. - It’s crucial to call
ctx.request_repaint()
during the animation to ensure that egui re-renders the UI, thus updating the animation.
Structs§
- Text
Animator - A struct for creating and managing text animations.
Enums§
- Animation
Type - Enum representing the available animation types.