Crates.io | tui-gradient-block |
lib.rs | tui-gradient-block |
version | 0.1.3 |
created_at | 2025-02-28 04:02:41.895523+00 |
updated_at | 2025-04-07 00:59:24.677361+00 |
description | a pretty extension to the block widget using colorgrad |
homepage | |
repository | https://github.com/F-77777/tui-gradient-block |
max_upload_size | |
id | 1572432 |
size | 142,631 |
Complex gradients may have a brief delay in rendering (no more than 100 ms)
Heavily relies on my other widget called tui-rule (https://crates.io/crates/tui-rule)
A single block is 4 instances of the rule widget (still renders with minimal delay)
Code before 0.1.3 will be COMPLETELY outdated
Updating is highly recommended
fn render_gradient_block(frame: &mut Frame) {
let block = GradientBlock::new()
.left_gradient(solid((48, 174, 209)))
.bottom_gradient(solid((48, 174, 209)))
.top_gradient(Box::new(
GradientBuilder::new()
.colors(&[
Color::from_rgba8(48, 174, 209, 1),
Color::from_rgba8(225, 22, 247, 1),
])
.build::<colorgrad::LinearGradient>()
.unwrap(),
))
.right_gradient(Box::new(
GradientBuilder::new()
.colors(&[
Color::from_rgba8(225, 22, 247, 1),
Color::from_rgba8(48, 174, 209, 1),
])
.build::<colorgrad::LinearGradient>()
.unwrap(),
))
.title_top(Line::from(generate_gradient_text!(
"Top title",
GradientBuilder::new().colors(&[
Color::from_rgba8(14, 67, 240),
Color::from_rgba8(90, 34, 128)
]).build::<colorgrad::LinearGradient>()
.unwrap()
)).centered());
frame.render_widget(block, frame.area());
}
Some of the gradients are from colormagic