[−][src]Struct wasm_svg_graphics::color::Color
Represents colors within the WASM SVG GRAPHICS lib
Methods
impl Color
[src]
pub fn new(red: u8, green: u8, blue: u8) -> Color
[src]
Constructor for color
pub fn from_hex(input_string: &str) -> Option<Color>
[src]
Constructor for color from hex
Example
use wasm_svg_graphics::color::Color; // 6 character definition let black_coral = Color::from_hex("565676"); // 7 character definition let pale_lavender = Color::from_hex("#d8dcff"); // Generated with https://coolors.co/
pub fn r(&self) -> u8
[src]
Returns the red component of the color
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.r()); // 172
pub fn red(&self) -> u8
[src]
Returns the red component of the color
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.red()); // 172
pub fn g(&self) -> u8
[src]
Returns the green component of the color
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.g()); // 159
pub fn green(&self) -> u8
[src]
Returns the green component of the color
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.green()); // 159
pub fn b(&self) -> u8
[src]
Returns the blue component of the color
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.b()); // 187
pub fn blue(&self) -> u8
[src]
Returns the blue component of the color
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.blue()); // 187
pub fn rgb(&self) -> (u8, u8, u8)
[src]
Returns a tuple with red, green and blue, respectively
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{:?}", pastel_purple.rgb()); // (172, 159, 187)
pub fn to_rgb_string(&self) -> String
[src]
Returns a string a string containing the u8 variant of the colors
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.to_rgb_string()); // rgb(172, 159, 187)
pub fn to_hex_string(&self) -> String
[src]
Returns a string a string containing the hex variant of the colors
Example
use wasm_svg_graphics::color::Color; let pastel_purple = Color::new(172, 159, 187); println!("{}", pastel_purple.to_hex_string()); // #ac9fbb
Trait Implementations
impl Clone for Color
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Color
[src]
impl Debug for Color
[src]
impl Display for Color
[src]
impl Eq for Color
[src]
impl PartialEq<Color> for Color
[src]
Auto Trait Implementations
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> 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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,