Struct tint::Color
[−]
[src]
pub struct Color { pub red: f64, pub green: f64, pub blue: f64, pub alpha: f64, }
Color value
Fields
red: f64
Red component [0,1]
green: f64
Green component [0,1]
blue: f64
Blue component [0,1]
alpha: f64
Alpha component [0,1]
Methods
impl Color
[src]
fn new(red: f64, green: f64, blue: f64, alpha: f64) -> Color
[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);
fn from_rgb1(r: f64, g: f64, b: f64) -> Color
[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);
fn from_rgb1v(rgb: &[f64]) -> Color
[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]);
fn to_rgb1(&self) -> (f64, f64, f64)
[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));
fn from_rgb255(red: u8, green: u8, blue: u8) -> Color
[src]
Create new Color from RGB [0 .. 255] alpha value set to 1.0
let purple = Color::from_rgb255(255, 0, 255);
fn from_rgb255v(rgb: &[u8]) -> Color
[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);
fn to_rgb255(&self) -> (u8, u8, u8)
[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));
fn from_hex(hex: &str) -> Color
[src]
Create new Color from Hex String
let facade = Color::from_hex("#facade"); assert_eq!(facade.to_rgb255(), (250, 202, 222));
fn to_hex(&self) -> String
[src]
Convert Color into Hex String
let coffee = Color::from_rgb255(192, 255, 238); assert_eq!(coffee.to_hex(), "#c0ffee");
fn name(name: &str) -> Option<Color>
[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));
fn to_hsv(&self) -> (f64, f64, f64)
[src]
Convert Color to HSV
fn from_hsv(&self) -> Color
[src]
Create new Color from HSV alpha value set to 1.0
fn to_hsl(&self) -> (f64, f64, f64)
[src]
Convert Color to HSL
fn from_hsl(&self) -> Color
[src]
Create new Color from HSL alpha value set to 1.0
fn to_yiq(&self) -> (f64, f64, f64)
[src]
Convert Color to YIQ
fn from_yiq(&self) -> Color
[src]
Create new Color from YIQ alpha value set to 1.0
Trait Implementations
impl Debug for Color
[src]
impl Copy for Color
[src]
impl Clone for Color
[src]
fn clone(&self) -> Color
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
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
impl<'a> From<&'a String> for Color
[src]
Convert from named color or a hex string
This may fail
impl<'a> From<&'a str> for Color
[src]
Convert from named color or a hex string
This may fail
impl From<(u8, u8, u8)> for Color
[src]
Convert from a u8 triple, red, green, blue
impl From<(f64, f64, f64)> for Color
[src]
Convert from a f64 triple, red, green, blue
impl From<(f32, f32, f32)> for Color
[src]
Convert from a f32 triple, red, green, blue
impl<'a> From<&'a [u8; 3]> for Color
[src]
Convert from a u8 triple, red, green, blue
impl<'a> From<&'a [f64; 3]> for Color
[src]
Convert from a f64 triple, red, green, blue
impl<'a> From<&'a [f32; 3]> for Color
[src]
Convert from a f32 triple, red, green, blue
impl From<[u8; 3]> for Color
[src]
Convert from a u8 triple, red, green, blue
impl From<[f64; 3]> for Color
[src]
Convert from a f64 triple, red, green, blue
impl From<[f32; 3]> for Color
[src]
Convert from a f32 triple, red, green, blue
impl<'a> From<&'a Vec<f64>> for Color
[src]
Convert from a f64 Vec, red, green, blue, maybe alpha
This may fail
impl<'a> From<&'a Vec<f32>> for Color
[src]
Convert from a f32 Vec, red, green, blue, maybe alpha
This may fail
impl From<Vec<f64>> for Color
[src]
Convert from a f32 Vec, red, green, blue, maybe alpha
This may fail
impl From<Vec<f32>> for Color
[src]
Convert from a f32 Vec, red, green, blue, maybe alpha
This may fail
impl PartialEq for Color
[src]
fn eq(&self, other: &Color) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.