[−][src]Struct colors_transform::Rgb
Methods
impl 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_tuple((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
fn new() -> Rgb[src]
fn get_red(&self) -> f32[src]
fn get_green(&self) -> f32[src]
fn get_blue(&self) -> f32[src]
fn set_red(&self, val: f32) -> Rgb[src]
fn set_green(&self, val: f32) -> Rgb[src]
fn set_blue(&self, val: f32) -> Rgb[src]
fn get_hue(&self) -> f32[src]
fn get_saturation(&self) -> f32[src]
fn get_lightness(&self) -> f32[src]
fn set_hue(&self, val: f32) -> Rgb[src]
fn set_saturation(&self, val: f32) -> Rgb[src]
fn set_lightness(&self, val: f32) -> Rgb[src]
fn to_rgb(&self) -> Rgb[src]
fn to_rgba(&self) -> Rgba[src]
fn to_hsl(&self) -> Hsl[src]
fn to_hsla(&self) -> Hsla[src]
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)");
fn from_tuple(t: ColorTuple) -> Rgb[src]
fn as_tuple(&self) -> ColorTuple[src]
fn lighten(&self, amt: f32) -> Rgb[src]
fn saturate(&self, amt: f32) -> Rgb[src]
fn adjust_hue(&self, amt: f32) -> Rgb[src]
fn adjust_color(&self, name: RgbColor, val: f32) -> Rgb[src]
impl Copy for Rgb[src]
impl PartialEq<Rgb> for Rgb[src]
impl Clone for Rgb[src]
fn clone(&self) -> Rgb[src]
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.
fn from_str(s: &str) -> Result<Rgb, ParseError>[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
impl<T> From for T[src]
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,