Trait color_conv::Color[][src]

pub trait Color {
    fn to_rgb(self) -> Rgb;
fn to_cmyk(self) -> Cmyk;
fn to_hsl(self) -> Hsl;
fn to_hex_string(self) -> String; }

Unifying Color trait which encompasses each of the structs provided by this crate.

Required methods

fn to_rgb(self) -> Rgb[src]

Convert to Rgb

Examples

use color_conv::Color;
use color_conv::Cmyk;
use color_conv::Rgb;

let cyan = Cmyk::new_unchecked(100, 0, 0, 0);
let cyan_rgb = cyan.to_rgb();

assert_eq!(Rgb::new(0, 255, 255), cyan_rgb);

fn to_cmyk(self) -> Cmyk[src]

Convert to Cmyk with the possibility of failing if any of the percentage values are above 100

Examples

use color_conv::Color;
use color_conv::Rgb;
use color_conv::Cmyk;

let cyan = Rgb::new(0, 255, 255);
let cyan_cmyk = cyan.to_cmyk();

assert_eq!(cyan_cmyk, Cmyk::new_unchecked(100, 0, 0, 0));

fn to_hsl(self) -> Hsl[src]

Convert to Hsl with the possibility of failing if any of the percentage values are above 100 or degree values are above 360

Examples

use color_conv::Color;
use color_conv::Hsl;
use color_conv::Cmyk;

let cyan = Hsl::new_unchecked(180, 100, 50);
let cyan_cmyk = cyan.to_cmyk();

assert_eq!(cyan_cmyk, Cmyk::new_unchecked(100, 0, 0, 0));

fn to_hex_string(self) -> String[src]

Convert to a String containing the hex code of the color prefixed with a hashtag (#)

Examples

use color_conv::Color;
use color_conv::Rgb;

let cyan = Rgb::new(0, 255, 255);
let cyan_hex = cyan.to_hex_string();

assert_eq!(cyan_hex, String::from("#00ffff"));
Loading content...

Implementors

impl Color for Cmyk[src]

impl Color for Hsl[src]

impl Color for Rgb[src]

Loading content...