Struct tint::Color [] [src]

pub struct Color {
    pub red: f64,
    pub green: f64,
    pub blue: f64,
    pub alpha: f64,
}

Color value

Fields

Red component [0,1]

Green component [0,1]

Blue component [0,1]

Alpha component [0,1]

Methods

impl Color
[src]

[src]

Create new color from components

use tint::Color;
let red = Color::new(1.0, 0.0, 0.0, 1.0);
let fushcia = Color::new(1.0, 0.0, 1.0, 1.0);

[src]

Create new color from RGB components [0. .. 1.0], alpha value set to 1.0

let blue = Color::from_rgb1(0.0, 0.0, 1.0);

[src]

Create new color from RGB f64 vector [0. .. 1.0], alpha value set to 1.0

let green = Color::from_rgb1v(&[0.0, 1.0, 0.0]);

[src]

Convert Color to (f64,f64,f64)

let purple = Color::new(1.0, 0.0, 1.0, 1.0);
let rgb = purple.to_rgb1();
assert_eq!(rgb, (1.0, 0.0, 1.0));

[src]

Create new Color from RGB [0 .. 255] alpha value set to 1.0

let purple = Color::from_rgb255(255, 0, 255);

[src]

Create new Color from RGB u8 vector [0 .. 255] alpha value set to 1.0

let purple = Color::from_rgb255v(&[255, 0, 255]);
assert_eq!(purple.red,   1.0);
assert_eq!(purple.green, 0.0);
assert_eq!(purple.blue,  1.0);

[src]

Convert color to (u8,u8,u8)

let purple = Color::new(1.0, 0.0, 1.0, 1.0);
assert_eq!(purple.to_rgb255(), (255,0,255));

[src]

Create new Color from Hex String

let facade = Color::from_hex("#facade");
assert_eq!(facade.to_rgb255(), (250, 202, 222));

[src]

Convert Color into Hex String

let coffee = Color::from_rgb255(192, 255, 238);
assert_eq!(coffee.to_hex(), "#c0ffee");

[src]

Get Color from exiting named colors Colors are defined from w3c Basic and Extended colors and colors from the XKCD database if loaded

let chartreuse = Color::name("chartreuse");
assert_eq!(chartreuse, Some(Color::from_hex("7fff00")));
let olive_drab = Color::name("olivedrab").unwrap();
assert_eq!(olive_drab.to_rgb255(), (107,142,35));

tint::xkcd();
let butterscotch = Color::name("butterscotch").unwrap();
assert_eq!(butterscotch.to_hex(), "#fdb147");

let avocado = Color::name("avocado green").unwrap();
assert_eq!(avocado.to_rgb255(), (135, 169, 34));

[src]

Convert Color to HSV

[src]

Create new Color from HSV alpha value set to 1.0

[src]

Convert Color to HSL

[src]

Create new Color from HSL alpha value set to 1.0

[src]

Convert Color to YIQ

[src]

Create new Color from YIQ alpha value set to 1.0

Trait Implementations

impl Debug for Color
[src]

[src]

Formats the value using the given formatter.

impl Copy for Color
[src]

impl Clone for Color
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<String> for Color
[src]

Convert from named color or a hex string

This may fail

[src]

Performs the conversion.

impl<'a> From<&'a String> for Color
[src]

Convert from named color or a hex string

This may fail

[src]

Performs the conversion.

impl<'a> From<&'a str> for Color
[src]

Convert from named color or a hex string

This may fail

[src]

Performs the conversion.

impl From<(u8, u8, u8)> for Color
[src]

Convert from a u8 triple, red, green, blue

[src]

Performs the conversion.

impl From<(f64, f64, f64)> for Color
[src]

Convert from a f64 triple, red, green, blue

[src]

Performs the conversion.

impl From<(f32, f32, f32)> for Color
[src]

Convert from a f32 triple, red, green, blue

[src]

Performs the conversion.

impl<'a> From<&'a [u8; 3]> for Color
[src]

Convert from a u8 triple, red, green, blue

[src]

Performs the conversion.

impl<'a> From<&'a [f64; 3]> for Color
[src]

Convert from a f64 triple, red, green, blue

[src]

Performs the conversion.

impl<'a> From<&'a [f32; 3]> for Color
[src]

Convert from a f32 triple, red, green, blue

[src]

Performs the conversion.

impl From<[u8; 3]> for Color
[src]

Convert from a u8 triple, red, green, blue

[src]

Performs the conversion.

impl From<[f64; 3]> for Color
[src]

Convert from a f64 triple, red, green, blue

[src]

Performs the conversion.

impl From<[f32; 3]> for Color
[src]

Convert from a f32 triple, red, green, blue

[src]

Performs the conversion.

impl<'a> From<&'a Vec<f64>> for Color
[src]

Convert from a f64 Vec, red, green, blue, maybe alpha

This may fail

[src]

Performs the conversion.

impl<'a> From<&'a Vec<f32>> for Color
[src]

Convert from a f32 Vec, red, green, blue, maybe alpha

This may fail

[src]

Performs the conversion.

impl From<Vec<f64>> for Color
[src]

Convert from a f32 Vec, red, green, blue, maybe alpha

This may fail

[src]

Performs the conversion.

impl From<Vec<f32>> for Color
[src]

Convert from a f32 Vec, red, green, blue, maybe alpha

This may fail

[src]

Performs the conversion.

impl PartialEq for Color
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Display for Color
[src]

[src]

Formats the value using the given formatter. Read more