Crates.io | tachyonfx |
lib.rs | tachyonfx |
version | 0.8.0 |
source | src |
created_at | 2024-06-20 15:30:01.64187 |
updated_at | 2024-10-21 17:46:44.557499 |
description | A ratatui library for creating shader-like effects in TUIs. |
homepage | https://github.com/junkdog/tachyonfx |
repository | https://github.com/junkdog/tachyonfx |
max_upload_size | |
id | 1278080 |
size | 465,165 |
tachyonfx is a ratatui library for creating shader-like effects in terminal UIs. This library provides a collection of effects that can be used to enhance the visual appeal of terminal applications, offering capabilities such as color transformations, animations, and complex effect combinations.
Add tachyonfx to your Cargo.toml
:
tachyonfx = "0.8.0"
sendable
: Enables the Send
trait for effects, shaders, and associated parameters. This allows effects to be
safely transferred across thread boundaries. Note that enabling this feature requires all Shader
implementations
to be Send
, which may impose additional constraints on custom shader implementations.std-duration
: Uses std::time::Duration
instead of a custom 32-bit duration type.The library includes a variety of effects, loosely categorized as follows:
effect_fn: Creates custom effects from user-defined functions, operating over CellIterator
.
effect_fn_buf: Creates custom effects from functions, operating over Buffer
.
offscreen_buffer: Wraps an existing effect and redirects its rendering to a separate buffer.
The EffectTimer is used to control the duration and interpolation of effects. It allows for precise timing and synchronization of visual effects within your application.
Effects can be applied to specific cells in the terminal UI, allowing for targeted visual modifications and animations.
// only apply to cells with `Light2` foreground color
fx::sweep_in(Direction::UpToDown, 15, 0, Dark0, timer)
.with_cell_selection(CellFilter::FgColor(Light2.into()))
CellFilter
s can be combined to form complex selection criteria.
// apply effect to cells on the outer border of the area
let margin = Margin::new(1, 1);
let border_text = CellFilter::AllOf(&[
CellFilter::Outer(margin),
CellFilter::Text
]);
prolong_start(duration, fx::fade_from(Dark0, Dark0, (320, QuadOut)),
.with_cell_selection(border_text)
minimal
cargo run --release --example=minimal
tweens
cargo run --release --example=tweens
basic-effects
cargo run --release --example=basic-effects
open-window
cargo run --release --example=open-window
fx-chart
A demo of the EffectTimelineWidget
showcasing the composition of effects. The widget is a "plain" widget
without any effects as part of its rendering. The effects are instead applied after rendering the widget.
cargo run --release --example=fx-chart