Enum terminal_graphics::display::colour::Colour
[−]
[src]
pub enum Colour { Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite, }
The Colour enum is used to set the colours in the Terminal
The available colours come from the ANSI_escape_codes https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
Variants
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
BrightBlack
BrightRed
BrightGreen
BrightYellow
BrightBlue
BrightMagenta
BrightCyan
BrightWhite
Methods
impl Colour
[src]
pub fn of(colour: &str) -> Colour
[src]
Get the enum value from a string
use terminal_graphics::Colour; let black = Colour::of("Black"); assert_eq!(Colour::Black, black);
pub fn to_str(&self) -> &str
[src]
pub fn variants() -> [Colour; 16]
[src]
Returns an array of all the colours. Useful for iterating over the enum.
use terminal_graphics::Colour; assert_eq!(Colour::variants().len(), 16);
pub fn from_rgb(red: u8, green: u8, blue: u8) -> Colour
[src]
Get the enum value from an RGB value. Finds the closest colour using euclidean distance.
use terminal_graphics::Colour; assert_eq!(Colour::Black, Colour::from_rgb(0,0,0)); assert_eq!(Colour::BrightWhite, Colour::from_rgb(255,255,255)); assert_eq!(Colour::BrightGreen, Colour::from_rgb(0, 255, 0));
pub fn get_codes(&self) -> (u32, u32)
[src]
Gets the values for the colour: from https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
use terminal_graphics::Colour; let red = Colour::Red; let (character_colour, background_colour) = red.get_codes(); assert_eq!(character_colour, 31); assert_eq!(background_colour, 41);
pub fn get_rbg(&self) -> (u8, u8, u8)
[src]
Gets the RBG tiple for the colour.
use terminal_graphics::Colour; let cyan = Colour::Cyan; let (r, b, g) = cyan.get_rbg(); assert_eq!(r, 0); assert_eq!(b, 128); assert_eq!(g, 128);
Trait Implementations
impl Copy for Colour
[src]
impl Clone for Colour
[src]
fn clone(&self) -> Colour
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Colour
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more