tinterm

Crates.iotinterm
lib.rstinterm
version0.1.0
sourcesrc
created_at2024-12-12 08:03:34.405905
updated_at2024-12-12 08:03:34.405905
descriptionA library for vibrant solid and gradient text in terminal outputs.
homepage
repositoryhttps://github.com/bratish/Tinterm
max_upload_size
id1480964
size30,171
Bratish Goswami (bratish)

documentation

README

Tinterm: Tinted Terminal with Colors and Gradients

A Rust library for adding beautiful colors and gradients to your terminal output with an ergonomic API.

Features

  • 🎨 RGB color support for both foreground and background
  • 🌈 Smooth color gradients
  • ⚡ Simple and intuitive API
  • 📝 Text styling (bold, italic, underline, etc.)
  • 🔄 Chainable methods
  • 📚 Comprehensive documentation and examples

Installation

Add this to your Cargo.toml:

[dependencies]
tinterm = "0.1.0"

Quick Start

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));

Color Methods

Basic Coloring

// Using descriptive names
"Text".color(Color::RED);
"Text".background_color(Color::BLUE);
// Using short aliases
"Text".fg(Color::RED);
"Text".bg(Color::BLUE);

Gradients

// 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));

Text Styling

"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();

Method Chaining

"Styled Text"
.bold()
.color(Color::RED)
.background_color(Color::BLUE);

Predefined Colors

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));

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 5

cargo fmt