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

Methods

impl Colour
[src]

[src]

Get the enum value from a string

use terminal_graphics::Colour;

let black = Colour::of("Black");
assert_eq!(Colour::Black, black);

[src]

[src]

Returns an array of all the colours. Useful for iterating over the enum.

use terminal_graphics::Colour;

assert_eq!(Colour::variants().len(), 16);

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

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

[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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Colour
[src]

[src]

Formats the value using the given formatter. Read more

impl PartialEq for Colour
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

Auto Trait Implementations

impl Send for Colour

impl Sync for Colour