colorized

Crates.iocolorized
lib.rscolorized
version1.0.0
sourcesrc
created_at2022-12-30 06:41:38.479075
updated_at2022-12-31 10:05:59.027052
descriptionA tool to colorized output
homepagehttps://github.com/xavierbrasher/colorized
repositoryhttps://github.com/xavierbrasher/colorized
max_upload_size
id747710
size10,839
Xavier Brasher (xavierbrasher)

documentation

https://docs.rs/crate/colorized/latest

README

Colorized

Colorized is a simple rust library that allows for you to display color to the console

Getting Started

Just add the line on crates.io to your Cargo.toml to install it

Usage

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

Documentation

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.

Colors Enum

This enum makes it easy to access all of the colors and color values.

Examples

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

Implementation

The implementation that allows the Colors Enum to a &str value

Examples

use colorized::Colors;

fn main() {
  assert_eq!(Colors::BlueFg.value(), "\x1b[34m")
}

Colors Traits

This allows Strings and &str to have color with .color(COLOR_ENUM)

Examples

use colorized::*;

fn main() {
    println!("{}", "Wow".color(Colors::CyanFg));
    let john: String = String::from(":)");
    println!("{}",  john.color(Colors::BrightMagentaBg));
}

Colorize Print

This is a funcition that prints a full colored sentence without a new line charactor

Examples

use colorized::*;

fn main() {
  colorize_print("Wow this is great", Colors::BrightCyanFg);
}

Colorize PrintLn

This is a funcition that prints a full colored sentence with a new line charactor

Examples

use colorized::*;

fn main() {
  colorize_println("Wow this is great", Colors::BrightCyanFg);
}

Colorize this

This function adds color to anything that isn't implemented

Examples

use colorized::*;

fn main() {
  let this: String = colorize_this("wowzers", Colors::BrightBlackBg);
}

Format of color

Colors::{COLORNAME}_

All Posible Colors

  1. black
  2. red
  3. green
  4. yellow
  5. blue
  6. magenta
  7. cyan
  8. white
  9. bright_black
  10. bright_red
  11. bright_green
  12. bright_yellow
  13. bright_blue
  14. bright_magenta
  15. bright_cyan
  16. bright_white

License

MIT

Commit count: 13

cargo fmt