Crates.io | tinterm |
lib.rs | tinterm |
version | 0.1.0 |
source | src |
created_at | 2024-12-12 08:03:34.405905 |
updated_at | 2024-12-12 08:03:34.405905 |
description | A library for vibrant solid and gradient text in terminal outputs. |
homepage | |
repository | https://github.com/bratish/Tinterm |
max_upload_size | |
id | 1480964 |
size | 30,171 |
A Rust library for adding beautiful colors and gradients to your terminal output with an ergonomic API.
Add this to your Cargo.toml
:
[dependencies]
tinterm = "0.1.0"
use tinterm::*;
// Simple colored text
println!("Hello".color(Color::RED));
// Background color
println!("World".background_color(Color::BLUE));
// Gradient text
println!("Rainbow".gradient(Color::RED, Color::BLUE, None));
// Styled text
println!("Bold and Blue".bold().color(Color::BLUE));
// Using descriptive names
"Text".color(Color::RED);
"Text".background_color(Color::BLUE);
// Using short aliases
"Text".fg(Color::RED);
"Text".bg(Color::BLUE);
// Foreground gradient
"Gradient Text".gradient(Color::RED, Color::BLUE, None);
// Background gradient
"Gradient Background".gradient_bg(Color::RED, Color::BLUE, None);
// Multiline gradient with block mode
let text = "Line 1\nLine 2";
text.gradient(Color::RED, Color::BLUE, Some(true));
"This line is bold".bold();
"This line is italic".italic();
"This line is underline".underline();
"This line is strikethrough".strikethrough();
"This line is dim".dim();
"This line is blink".blink();
"This line is reverse".reverse();
"This line is hidden".hidden();
"This line is bright".bright();
"Styled Text"
.bold()
.color(Color::RED)
.background_color(Color::BLUE);
The library comes with several predefined colors:
Color::RED
Color::GREEN
Color::BLUE
// ... and more
You can also create custom colors:
// Using RGB values (0-255)
let custom_color = Color::new(255, 128, 0);
// Using hex values
let hex_color = Color::from_hex("#FF8000").unwrap();
// or without the hash
let hex_color = Color::from_hex("FF8000").unwrap();
// Using them in text
println!("Custom RGB".color(custom_color));
println!("Custom Hex".color(hex_color));
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.