//! utility types and functions for color operations use termion::color::{ Bg, Fg, Rgb, Reset }; pub type Color = Fg; pub type Colors = Vec>; pub static BLACK: Color = Fg(Rgb(0x00, 0x00, 0x00)); pub static WHITE: Color = Fg(Rgb(0xFF, 0xFF, 0xFF)); pub static RESET: Fg = Fg(Reset); pub static RESET_BG: Bg = Bg(Reset); /// produces a termion foreground color from the provided integer pub fn rgb(hex: u32) -> Color { // colors should be 0xrrggbb = 0x__rrggbb; drop the most significant byte let [_, r, g, b] = hex.to_be_bytes(); Fg(Rgb(r, g, b)) } /// produces a termion background color from the provided integer pub fn bg(hex: u32) -> Bg { let [_, r, g, b] = hex.to_be_bytes(); Bg(Rgb(r, g, b)) }