pub struct Rgb { /* private fields */ }Implementations§
Source§impl Rgb
impl Rgb
pub fn from(r: f32, g: f32, b: f32) -> Rgb
pub fn grayscale(&self, method: GrayScaleMethod) -> Rgb
Sourcepub fn from_hex_str(s: &str) -> Result<Rgb, ParseError>
pub fn from_hex_str(s: &str) -> Result<Rgb, ParseError>
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());Sourcepub fn to_css_hex_string(&self) -> String
pub fn to_css_hex_string(&self) -> String
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§
Source§impl AlphaColor for Rgb
impl AlphaColor for Rgb
Source§impl Color for Rgb
impl Color for Rgb
Source§fn to_css_string(&self) -> String
fn to_css_string(&self) -> String
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)");type TupleA = (f32, f32, f32, f32)
Source§fn get_saturation(&self) -> f32
fn get_saturation(&self) -> f32
Returns saturation value of color (
0.0..100.00)Source§fn get_lightness(&self) -> f32
fn get_lightness(&self) -> f32
Returns lightness value of color (
0.0..100.00)Source§fn set_saturation(&self, val: f32) -> Rgb
fn set_saturation(&self, val: f32) -> Rgb
Sets saturation value of color (
0.0..100.00). Returns ColorSource§fn set_lightness(&self, val: f32) -> Rgb
fn set_lightness(&self, val: f32) -> Rgb
Sets lightness value of color (
0.0..100.00). Returns Colorfn to_rgb(&self) -> Rgb
fn to_hsl(&self) -> Hsl
Source§fn from_tuple(t: &ColorTuple) -> Rgb
fn from_tuple(t: &ColorTuple) -> Rgb
Creates a color from tuple. Read more
fn from_tuple_with_alpha(t: &ColorTupleA) -> Rgb
Source§fn as_tuple(&self) -> ColorTuple
fn as_tuple(&self) -> ColorTuple
Returns tuple representation of color Read more
fn lighten(&self, amt: f32) -> Rgb
fn saturate(&self, amt: f32) -> Rgb
fn adjust_hue(&self, amt: f32) -> Rgb
fn adjust_color(&self, name: RgbUnit, val: f32) -> Rgb
fn invert(&self) -> Rgb
impl Copy for Rgb
impl StructuralPartialEq for Rgb
Auto Trait Implementations§
impl Freeze for Rgb
impl RefUnwindSafe for Rgb
impl Send for Rgb
impl Sync for Rgb
impl Unpin for Rgb
impl UnwindSafe for Rgb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more