[][src]Struct wasm_svg_graphics::color::Color

pub struct Color { /* fields omitted */ }

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]

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]

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

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

impl<T> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.