pub struct Color { /* private fields */ }Expand description
This represents an RGB color, stored as it’s individual color values and it’s hexadecimal string
Implementations§
Source§impl Color
impl Color
Sourcepub fn rgb(r: u8, g: u8, b: u8) -> Self
pub fn rgb(r: u8, g: u8, b: u8) -> Self
Create a new Color from a red color value, a green color value and a blue color
value
Sourcepub fn from_color_string(string: &str) -> Result<Self, Error>
pub fn from_color_string(string: &str) -> Result<Self, Error>
Sourcepub fn from_rgb_string(string: &str) -> Result<Self, Error>
pub fn from_rgb_string(string: &str) -> Result<Self, Error>
Create a new Color from a string slice formatted this way :
“(r,g,b)”
- “()” are necessary
- Each value must be seperated by a comma
- Each value must be at most 255
- whitespace is irrelevant
This will result in an error if the string cannot be parsed
Sourcepub fn from_hexadecimal(hexadecimal_color: &str) -> Result<Self, FromHexError>
pub fn from_hexadecimal(hexadecimal_color: &str) -> Result<Self, FromHexError>
Sourcepub fn hexadecimal_value(&self) -> String
pub fn hexadecimal_value(&self) -> String
Returns the hexadecimal value of the color
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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