[][src]Trait colors_transform::Color

pub trait Color {
    type Tuple;
    type TupleA;
    fn new() -> Self;
fn from_tuple(tuple: &Self::Tuple) -> Self;
fn from_tuple_with_alpha(tuple: &Self::TupleA) -> Self;
fn as_tuple(&self) -> Self::Tuple;
fn get_red(&self) -> f32;
fn get_green(&self) -> f32;
fn get_blue(&self) -> f32;
fn set_red(&self, val: f32) -> Self;
fn set_green(&self, val: f32) -> Self;
fn set_blue(&self, val: f32) -> Self;
fn get_hue(&self) -> f32;
fn get_saturation(&self) -> f32;
fn get_lightness(&self) -> f32;
fn set_hue(&self, val: f32) -> Self;
fn set_saturation(&self, val: f32) -> Self;
fn set_lightness(&self, val: f32) -> Self;
fn to_rgb(&self) -> Rgb;
fn to_hsl(&self) -> Hsl;
fn to_css_string(&self) -> String;
fn adjust_hue(&self, amt: f32) -> Self;
fn saturate(&self, amt: f32) -> Self;
fn lighten(&self, amt: f32) -> Self;
fn adjust_color(&self, col_name: RgbUnit, val: f32) -> Self;
fn invert(&self) -> Self; }

Common to all trait

Associated Types

type Tuple

ColorTuple or ColorTupleA.

type TupleA

Loading content...

Required methods

fn new() -> Self

Creates a black color

Example

use colors_transform::{Rgb,Color};

let black = Rgb::from(0.0,0.0,0.0);
assert_eq!(black, Rgb::new());

fn from_tuple(tuple: &Self::Tuple) -> Self

Creates a color from tuple.

Example

use colors_transform::{Rgb,Hsl,Color};

let rgb = Rgb::from_tuple(&(10.0,11.0,12.0));
let hsl = Hsl::from(310.0,50.0,50.0);

fn from_tuple_with_alpha(tuple: &Self::TupleA) -> Self

fn as_tuple(&self) -> Self::Tuple

Returns tuple representation of color

Example

use colors_transform::{Hsl,Color};
let hsl_tuple = (10.0,11.0,12.0);
let hsl = Hsl::from_tuple(&hsl_tuple);
assert_eq!(hsl_tuple,hsl.as_tuple());

fn get_red(&self) -> f32

Returns red value of color (0.0..255.00)

fn get_green(&self) -> f32

Returns green value of color (0.0..255.00)

fn get_blue(&self) -> f32

Returns blue value of color (0.0..255.00)

fn set_red(&self, val: f32) -> Self

Sets red value of color (0.0..255.00). Returns Color

fn set_green(&self, val: f32) -> Self

Sets green value of color (0.0..255.00). Returns Color

fn set_blue(&self, val: f32) -> Self

Sets blue value of color (0.0..255.00). Returns Color

fn get_hue(&self) -> f32

Returns hue value of color (0.0..359.00)

fn get_saturation(&self) -> f32

Returns saturation value of color (0.0..100.00)

fn get_lightness(&self) -> f32

Returns lightness value of color (0.0..100.00)

fn set_hue(&self, val: f32) -> Self

Sets hue value of color (0.0..359.00). Returns Color

fn set_saturation(&self, val: f32) -> Self

Sets saturation value of color (0.0..100.00). Returns Color

fn set_lightness(&self, val: f32) -> Self

Sets lightness value of color (0.0..100.00). Returns Color

fn to_rgb(&self) -> Rgb

fn to_hsl(&self) -> Hsl

fn to_css_string(&self) -> String

Returns css string

Example

use colors_transform::{Hsl,Color};

let hsl = Hsl::from_tuple(&(301.0,27.0,91.0));
assert_eq!(hsl.to_css_string(), "hsl(301,27%,91%)");

fn adjust_hue(&self, amt: f32) -> Self

fn saturate(&self, amt: f32) -> Self

fn lighten(&self, amt: f32) -> Self

fn adjust_color(&self, col_name: RgbUnit, val: f32) -> Self

fn invert(&self) -> Self

Loading content...

Implementors

impl Color for Hsl[src]

type Tuple = ColorTuple

type TupleA = ColorTupleA

impl Color for Rgb[src]

type Tuple = ColorTuple

type TupleA = ColorTupleA

fn to_css_string(&self) -> String[src]

Returns css string

Example

use colors_transform::{Rgb,Color};

let rgb = Rgb::from_tuple(&(225.0,101.7, 21.0));
assert_eq!(rgb.to_css_string(), "rgb(225,102,21)");
Loading content...