[][src]Struct colors_transform::Rgb

pub struct Rgb { /* fields omitted */ }

Methods

impl Rgb[src]

pub fn from(r: f32, g: f32, b: f32) -> Rgb[src]

pub fn grayscale(&self, method: GrayScaleMethod) -> Rgb[src]

pub fn from_hex_str(s: &str) -> Result<Rgb, ParseError>[src]

Try to parse string as hex color

Example

use colors_transform::{Rgb,Color};

assert_eq!(Rgb::from_hex_str("#e76B2c").unwrap(),Rgb::from(231.0,107.0,44.0));
assert_eq!(Rgb::from_hex_str("fc0").unwrap(),Rgb::from_tuple(&(255.0,204.0,0.0)));
assert!(Rgb::from_hex_str("cyan").is_err());

pub fn to_css_hex_string(&self) -> String[src]

Returns hexadecimal color string like in css. In lowercase with no reductions

Example

use colors_transform::{Rgb,Color};

let rgb1 = Rgb::from_tuple(&(231.0,107.0,44.0));
assert_eq!(rgb1.to_css_hex_string(),"#e76b2c");

let rgb2 = Rgb::from_hex_str("#0C7").unwrap();
assert_eq!(rgb2.to_css_hex_string(),"#00cc77");

Trait Implementations

impl Color for Rgb[src]

type Tuple = ColorTuple

ColorTuple or ColorTupleA.

type TupleA = ColorTupleA

fn to_css_string(&self) -> String[src]

Returns css string

Example

use colors_transform::{Rgb,Color};

let rgb = Rgb::from_tuple(&(225.0,101.7, 21.0));
assert_eq!(rgb.to_css_string(), "rgb(225,102,21)");

impl AlphaColor for Rgb[src]

impl Copy for Rgb[src]

impl PartialEq<Rgb> for Rgb[src]

impl Clone for Rgb[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Rgb[src]

impl FromStr for Rgb[src]

type Err = ParseError

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for Rgb

impl Sync for Rgb

Blanket Implementations

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

type Owned = T

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.