Crates.io | colorized |
lib.rs | colorized |
version | 1.0.0 |
source | src |
created_at | 2022-12-30 06:41:38.479075 |
updated_at | 2022-12-31 10:05:59.027052 |
description | A tool to colorized output |
homepage | https://github.com/xavierbrasher/colorized |
repository | https://github.com/xavierbrasher/colorized |
max_upload_size | |
id | 747710 |
size | 10,839 |
Colorized is a simple rust library that allows for you to display color to the console
Just add the line on crates.io to your Cargo.toml to install it
To use Colorized all you have to do is
use colorized::*;
fn main() {
println!("{}", "This is so cool".color(Colors::BrightGreenFg));
let this: String = colorize_this("wowzers", Colors::BrightBlackBg);
colorize_print("Wow this is great", Colors::BrightCyanFg);
colorize_println("Wow this is great", Colors::BrightCyanFg);
}
Colorized uses ASCI Codes and thats how it remains very simple. In the source code you may be able to tell that it is my first time making and uploading a libary but I hope this libary could be useful.
This enum makes it easy to access all of the colors and color values.
use colorized::*;
fn main() {
println!("This is with color: {} woah {}", Colors::BlueFg.value(), Colors::Reset.value());
println!("Same thing but easier: {}", "Oh my".color(Colors::BrightCyanBg));
let coloredString = colorize_this("This is color", Colors::YellowFg);
}
The implementation that allows the Colors Enum to a &str value
use colorized::Colors;
fn main() {
assert_eq!(Colors::BlueFg.value(), "\x1b[34m")
}
This allows Strings and &str to have color with .color(COLOR_ENUM)
use colorized::*;
fn main() {
println!("{}", "Wow".color(Colors::CyanFg));
let john: String = String::from(":)");
println!("{}", john.color(Colors::BrightMagentaBg));
}
This is a funcition that prints a full colored sentence without a new line charactor
use colorized::*;
fn main() {
colorize_print("Wow this is great", Colors::BrightCyanFg);
}
This is a funcition that prints a full colored sentence with a new line charactor
use colorized::*;
fn main() {
colorize_println("Wow this is great", Colors::BrightCyanFg);
}
This function adds color to anything that isn't implemented
use colorized::*;
fn main() {
let this: String = colorize_this("wowzers", Colors::BrightBlackBg);
}
Colors::{COLORNAME}_
All Posible Colors
MIT