termcolor2rgb

Crates.iotermcolor2rgb
lib.rstermcolor2rgb
version1.0.1
sourcesrc
created_at2019-01-12 12:37:13.927234
updated_at2019-01-12 12:40:27.066739
descriptionSmall crate to convert termcolor::Color to RGB value
homepage
repositoryhttps://github.com/rhysd/termcolor2rgb
max_upload_size
id108148
size18,871
Linda_pp (rhysd)

documentation

README

termcolor2rgb

Build Status documentation

termcolor2rgb is a small crate to extend termcolor crate. It provides to_rgb() method to termcolor::Color instance.

use termcolor;

// Declare extending termcolor::Color by using a trait.
// .to_rgb() method is made available.
use termcolor2rgb::ColorExt;

// Basic 8 colors
assert_eq!(termcolor::Color::Red.to_rgb(), (0x80, 0, 0));

// ANSI 256 colors
assert_eq!(termcolor::Color::Ansi256(223).to_rgb(), (0xff, 0xd7, 0xaf));

// RGB color
assert_eq!(termcolor::Color::Rgb(0x12, 0x89, 0xef).to_rgb(), (0x12, 0x89, 0xef));

Documentation

Installation

Add dependencies to your Cargo.toml.

termcolor = "1.0"
termcolor2rgb = "1.0"

License

The MIT License

Commit count: 7

cargo fmt