#effect #scroll #text #terminal #animator #engine #scattering

bin+lib terani

A Terminal Animator Engine In Rust

1 unstable release

0.1.0 Jun 1, 2024

#16 in #scroll

MIT license

15KB
268 lines

Terminal Animator Engine In Rust

This is a terminal animator engine written in Rust. It provides several text effects that can be used to animate text in the terminal.

Features

Text Effects

  1. Scattering: This effect makes the text appear as if it's scattering across the terminal. Implemented in scattering.rs.

  2. Typewriter: This effect makes the text appear as if it's being typed out in real-time. Implemented in typewriter.rs.

  3. Scrolling: This effect makes the text appear as if it's scrolling across the terminal. There are two variants of this effect: ScrollingLeft and ScrollingRight. Implemented in scrolling.rs.

  4. Blinking: This effect makes the text blink in the terminal. Implemented in blinking.rs.

  5. Color Changing: This effect changes the color of the text in the terminal. Implemented in color_changing.rs.

  6. Climbing: This effect makes the text appear as if it's climbing up the terminal. Implemented in climbing.rs.

Animation

The Animation struct is used to create an animation from a sequence of frames. Each frame consists of a string of text and a text effect. The animation plays each frame in sequence, applying the text effect to the text before displaying it in the terminal.

Usage

To use the terminal animator engine, create an Animation with a sequence of Frames, then call animation.next_frame() in a loop. Here is an example:

let frames = vec![
    Frame::new("I am in love with you please marry me!", Climbing),
    Frame::new("Alice alice alice alice alice alice", Climbing),
    Frame::new("I want to be with you forever!", Climbing),
];
let mut animation = Animation::new(frames, Duration::from_millis(100));
loop {
    if let Err(e) = animation.next_frame() {
        eprintln!("Error displaying frame: {}", e);
        break;
    }
}

Dependencies

~2.5–9.5MB
~89K SLoC