Trait colorsys::ColorAlpha[][src]

pub trait ColorAlpha {
    fn alpha(&self) -> f64;
fn get_alpha(&self) -> f64;
fn set_alpha(&mut self, val: f64);
fn opacify(&mut self, val: f64); }

Methods to work with alpha channel in color.

Required methods

fn alpha(&self) -> f64[src]

Returns alpha channel. If it not set will returns 1.0

fn get_alpha(&self) -> f64[src]

👎 Deprecated since 0.7.0:

Please use alpha instead

Returns alpha channel. If it not set will returns 1.0

fn set_alpha(&mut self, val: f64)[src]

Sets alpha channel

use colorsys::{Hsl,ColorAlpha};
let mut hsl = Hsl::default(); // Hsl { a: None, .. }
hsl.set_alpha(0.45); // Hsl { a: 0.45, .. }
hsl.set_alpha(123.015); // Hsl { a: 1.0, .. }
hsl.set_alpha(-123.3); // Hsl { a: 0.0, .. }

fn opacify(&mut self, val: f64)[src]

Increase/decrease color alpha channel with specified value. Value can be negative.

Example

use colorsys::{Hsl,ColorAlpha};
let mut hsl = Hsl::default(); // Hsl { a: None, .. }
hsl.opacify(-0.3); // Hsl { a: 0.7, .. }
hsl.opacify(0.015); // Hsl { a: 0.715, .. }
Loading content...

Implementors

impl<T> ColorAlpha for T where
    T: GetColorUnits, 
[src]

Loading content...