[go: up one dir, main page]

[][src]Struct termwiz::color::RgbColor

pub struct RgbColor {
    pub red: u8,
    pub green: u8,
    pub blue: u8,
}

Describes a color in the SRGB colorspace using red, green and blue components in the range 0-255.

Fields

red: u8green: u8blue: u8

Implementations

impl RgbColor[src]

pub fn new(red: u8, green: u8, blue: u8) -> Self[src]

Construct a color from discrete red, green, blue values in the range 0-255.

pub fn to_tuple_rgba(self) -> RgbaTuple[src]

pub fn to_linear_tuple_rgba(self) -> RgbaTuple[src]

pub fn from_named(name: &str) -> Option<RgbColor>[src]

Construct a color from an X11/SVG/CSS3 color name. Returns None if the supplied name is not recognized. The list of names can be found here: https://en.wikipedia.org/wiki/X11_color_names

pub fn to_rgb_string(self) -> String[src]

Returns a string of the form #RRGGBB

pub fn to_x11_16bit_rgb_string(self) -> String[src]

Returns a string of the form rgb:RRRR/GGGG/BBBB

pub fn from_rgb_str(s: &str) -> Option<RgbColor>[src]

Construct a color from a string of the form #RRGGBB where R, G and B are all hex digits.

pub fn from_named_or_rgb_string(s: &str) -> Option<Self>[src]

Construct a color from an SVG/CSS3 color name. or from a string of the form #RRGGBB where R, G and B are all hex digits. Returns None if the supplied name is not recognized. The list of names can be found here: https://ogeon.github.io/docs/palette/master/palette/named/index.html

Trait Implementations

impl Clone for RgbColor[src]

impl Copy for RgbColor[src]

impl Debug for RgbColor[src]

impl Default for RgbColor[src]

impl<'de> Deserialize<'de> for RgbColor[src]

impl Eq for RgbColor[src]

impl From<RgbColor> for ColorSpec[src]

impl Hash for RgbColor[src]

impl PartialEq<RgbColor> for RgbColor[src]

impl Serialize for RgbColor[src]

This is mildly unfortunate: in order to round trip RgbColor with serde we need to provide a Serialize impl equivalent to the Deserialize impl below. We use the impl below to allow more flexible specification of color strings in the config file. A side effect of doing it this way is that we have to serialize RgbColor as a 7-byte string when we could otherwise serialize it as a 3-byte array. There's probably a way to make this work more efficiently, but for now this will do.

impl StructuralEq for RgbColor[src]

impl StructuralPartialEq for RgbColor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.